Version 1.7

Community News/Announcements
User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#21

Post by Raheem » 2 years ago

[mention]Z0uha1r_LK[/mention], I'm giving u access on github to commit these optimizations, OK?
He who fails to plan is planning to fail

User avatar
z0h1r-LK
Mod Developer
Mod Developer
Morocco
Posts: 473
Joined: 5 years ago
Location: The Red City ❤
Contact:

#22

Post by z0h1r-LK » 2 years ago

Raheem wrote: 2 years ago @Z0uha1r_LK, I'm giving u access on github to commit these optimizations, OK?
can I open new Topic in forum and post any update !

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#23

Post by Raheem » 2 years ago

Z0uha1r_LK wrote: 2 years ago Switch Fake Meta/Ham Sandwich API to ReAPI

Ex:
  1. if (!pev_valid(iEnt)) return;
in reapi
  1. if (!is_entity(iEnt)) return;
I find pev_valid() is better in security than is_enitity() from my old tests. And no problem to switch to is_entity. Engine sometimes thinks that the entity is still there while it has been removed. So the problem generally will be from the engine and how it updates the status of entities. But for something in my mind IDK what I prefer using pev_valid.
Z0uha1r_LK wrote: 2 years ago Try delete repeats "rg_round_end" in ze_core, Use it:
ze_message_win (1=Text/2=HUD/3=DHUD)
  1. #include <amxmodx>
  2. #include <reapi>
  3.  
  4. Finish_Round({255, 0, 0}, "ESCAPE_SUCCESS", WINSTATUS_CTS, 3)
  5.  
  6. public Finish_Round(iColor[3], const szMessage[], WinStatus:iWin, iPrintType) {
  7.     // Finish a round.
  8.     rg_round_end(5.0, iWin, ROUND_NONE, "");
  9.    
  10.     // Show HUD
  11.     switch (iPrintType) {
  12.         case 1: engclient_print(0, engprint_center, "%L", LANG_PLAYER, szMessage)
  13.         case 2: {
  14.             set_hudmessage(iColor[0], iColor[1], iColor[2], -1.0, 0.3, 1, 5.0, 5.0, 0.0, 0.0)
  15.             show_hudmessage(0, "%L", LANG_PLAYER, szMessage)
  16.         }
  17.         case 3: {
  18.             set_dhudmessage(iColor[0], iColor[1], iColor[2], -1.0, 0.3, 1, 5.0, 5.0, 0.0, 0.0)
  19.             show_dhudmessage(0, "%L", LANG_PLAYER, szMessage)
  20.         }
  21.     }
  22. }
This is a good suggestion, it will add a new feature and it is the control in the final message type (HUD, DHUD, chat_center). At the same time, it will make the code more human-readable.
Z0uha1r_LK wrote: 2 years ago
Update cvar '"ze_coins_save_type"

0 = nVault
1 = MySQL
2 = No Save
I wonder how this can be useful, but in past, I saw some ZP servers that had no ammo-packs bank and the APs are only for one map. This was a bad idea from my point of view, however, this can be an option and everyone is free to use it or not. So generally, no problem to add it.
Z0uha1r_LK wrote: 2 years ago Add this in zombie_escape.inc
  1. #define ZE_SETTING_RESOURCES "zombie_escape.ini"
Good idea to make the code more organized.
Z0uha1r_LK wrote: 2 years ago Fix this in ze_resources.amxx
  1. // Play Ready sound only if game started
  2. public ze_game_started()
  3. {
  4.     // Play Ready Sound For All Players
  5.     new szSound[SOUND_MAX_LENGTH]
  6.     ArrayGetString(g_szReadySound, random_num(0, ArraySize(g_szReadySound) - 1), szSound, charsmax(szSound))
  7.    
  8.     for(new id = 1; id <= g_iMaxPlayers; id++)
  9.     {
  10.         if(!is_user_connected(id) && !g_bReadySound[id])
  11.             continue
  12.  
  13.         PlaySound(id, szSound)
  14.     }
  15. }
You forgot this !g_bReadySound[id]:
  1. if(!is_user_connected(id) && !g_bReadySound[id])
This suggestion is somehow not correct. Because we are in a new round and we directly terminated any sound and sent the ready sound. So there is no chance that the ready sound is already on to check it before sending it again.
Z0uha1r_LK wrote: 2 years ago We need optimize codes and switch more natives FakeMeta & Ham Sandwich to ReAPI.
I definitely agree, you can do this for more optimization.
Z0uha1r_LK wrote: 2 years ago ze_core is use more CPU usage!
You got full permission to optimize it :grinning:.
Z0uha1r_LK wrote: 2 years ago We need fix this error in v1.7:
Reason: When use last version of the ReAPI:
Solution: viewtopic.php?f=22&p=12179#p12179
or
change set_member and get_member ----> set_member_s and get_member_s

  1. L 11/15/2021 - 12:13:08: [ReAPI] get_member_s: 'm_iTeam' has no refs to the base class of an entity 'worldspawn'
  2. L 11/15/2021 - 12:13:08: [AMXX] Run time error 10 (plugin "ze_coins_system.amxx") (native "get_member_s") - debug not enabled!
Just make sure first that the id you are getting its member is connected, and such an error will not be there. Anyway, this error is not in our core or other main Mod plugins in any way.
Z0uha1r_LK wrote: 2 years ago Plugin: ze_core.amxx
  1. public Fw_TraceAttack_Pre(iVictim, iAttacker, Float:flDamage, Float:flDirection[3], iTracehandle, bitsDamageType)
  2. {
  3.     if (iVictim == iAttacker || !is_user_connected(iVictim) || !is_user_connected(iAttacker))
  4.         return HC_CONTINUE
  5.    
  6.     // Attacker and Victim is in same teams? Skip code blew
  7.     if (get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))
  8.         return HC_CONTINUE
  9.  
  10.     // ...
Now, It's better:
  1. public Fw_TraceAttack_Pre(iVictim, iAttacker, Float:flDamage, Float:flDirection[3], iTracehandle, bitsDamageType)
  2. {
  3.     // Invalid player or Attacker is himself.
  4.     if (iVictim == iAttacker || !is_user_connected(iVictim) || !is_user_connected(iAttacker))
  5.         return HC_CONTINUE;
  6.    
  7.     // Attacker and Victim is in same teams? Skip code blew
  8.     if (g_bIsZombie[iVictim] || !g_bIsZombie[iAttacker])
  9.         return HC_CONTINUE;
  10.  
  11.     // ...
  12. }
I'm trying to understand this, assuming the victim is a zombie you will skip the code. Assuming the attacker is human you will skip the code. If both are satisfied you also will skip the code. I don't know what it means. We need to ensure that they are not in the same team. Please explain your code.
Z0uha1r_LK wrote: 2 years ago I tried optimize this and check from all codes, I haven't tried it:
zombie_escape_stocks.inc

Updated: 28/03/2022
Please test it, and state your optimizations.
Z0uha1r_LK wrote: 2 years ago I optimize code using ReAPI :100:
ze_block_events_messages.sma

Required: Last version of ReAPI
State what you optimized, and test it.
Z0uha1r_LK wrote: 2 years ago Add this feature in resource.amxx, to set player model using ze_set_user_model
  1. #include <zombie_escape>
  2.  
  3. // Defintions.
  4. #define MAX_MODEL_LENGTH 64
  5.  
  6. // Variables.
  7. new bool:g_bHumanCustomModel[MAX_CLIENTS+1]
  8. new bool:g_bZombieCustomModel[MAX_CLIENTS+1]
  9. new g_szHumanCustomModel[MAX_CLIENTS+1][MAX_MODEL_LENGTH]
  10. new g_szZombieCustomModel[MAX_CLIENTS+1][MAX_MODEL_LENGTH]
  11.  
  12. // Forward called after server activation.
  13. public plugin_init() {
  14.     // Load plugin.
  15.     register_plugin("[ZE] Resource", "0.1", "Escapers-Zone.NET")
  16. }
  17.  
  18. // Forward allows registering natives.
  19. public plugin_natives() {
  20.     register_native("ze_set_user_model", "_native_set_user_model", 0)
  21.     register_native("ze_reset_user_model", "_native_reset_user_model", 0)
  22. }
  23.  
  24. // Forward called when set player Human (when cure).
  25. public ze_user_humanized(id) {
  26.     // Human Custom Model is enabled?
  27.     if (g_bHumanCustomModel[id])  {
  28.         // Set player new Human Model.
  29.         rg_set_user_model(id, g_szHumanCustomModel[id])
  30.     }
  31. }
  32.  
  33. // Forward called after infect Human.
  34. public ze_user_infected(iVictim, iAttacker)
  35. {
  36.     // Zombie Custom Model is enabled?
  37.     if (g_bZombieCustomModel[id]) {
  38.         // Set player new Zombie Model.
  39.         rg_set_user_model(id, g_szZombieCustomModel[id])       
  40.     }
  41. }
  42.  
  43. public _native_set_user_model(id, szModel[], iTeam) {
  44.     // Player not found?
  45.     if (!is_user_connected(id)) {
  46.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
  47.         return 0; // Return false.
  48.     }
  49.  
  50.     // Set player Human/Zombie Model.
  51.     switch (iTeam) {
  52.         case ZE_TEAM_HUMAN: {
  53.             g_bHumanCustomModel[id] = true
  54.             copy(g_szHumanCustomModel[id], charsmax(g_szHumanCustomModel[]), szModel)
  55.         } case ZE_TEAM_ZOMBIE: {
  56.             g_bZombieCustomModel[id] = true
  57.             copy(g_szZombieCustomModel[id], charsmax(g_szZombieCustomModel[]), szModel)
  58.         } default: {
  59.             log_error(AMX_ERR_NATIVE, "[ZE] Invalid Team (%d)", iTeam)
  60.             return 0; // Return false.
  61.         }
  62.     }
  63.  
  64.     // Return true.
  65.     return 1;
  66. }
  67.  
  68. public _native_reset_user_model(id, iTeam) {
  69.     // Player not found?
  70.     if (!is_user_connected(id)) {
  71.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
  72.         return 0; // Return false.
  73.     }
  74.  
  75.     // Set player Human/Zombie Model.
  76.     switch (iTeam) {
  77.         case ZE_TEAM_HUMAN: {
  78.             g_bHumanCustomModel[id] = false
  79.             g_szHumanCustomModel[id] = '^0'
  80.         } case ZE_TEAM_ZOMBIE: {
  81.             g_bZombieCustomModel[id] = false
  82.             g_szZombieCustomModel[id] = '^0'
  83.         } default: {
  84.             log_error(AMX_ERR_NATIVE, "[ZE] Invalid Team (%d)", iTeam)
  85.             return 0; // Return false.
  86.         }
  87.     }
  88.  
  89.     // Return true.
  90.     return 1;
  91. }
Why not use the ReAPI function direct, explain your point of view to create a function for it.
Z0uha1r_LK wrote: 2 years ago Add new native ze_infection_status(bool:bStatus) to enable or disabled infection.

Do this in ze_core
  1. #include <zombie_escape>
  2.  
  3. // Variables.
  4. new bool:g_bStatusInfection
  5.  
  6. // Hook Chains Variable.
  7. new HookChain:g_hcTraceAttack
  8.  
  9. // Forward allows registering natives.
  10. public plugin_natives() {
  11.     register_native("ze_infection_status", "_native_infection_status", 1)
  12. }
  13.  
  14. // Forward called after server activation.
  15. public plugin_init() {
  16.     // ...
  17.  
  18.     // Hook Chains.
  19.     g_hcTraceAttack = RegisterHookChain(RG_CBasePlayer_TraceAttack, "Fw_TraceAttack_Pre", 0)
  20.  
  21.     // Static Values.
  22.     g_bStatusInfection = true
  23. }
  24.  
  25. public _native_infection_status(bool:bStatus) {
  26.     if (!bStatus) {
  27.         g_bStatusInfection = false
  28.         DisableHookChain(g_hcTraceAttack)
  29.     } else {
  30.         g_bStatusInfection = true
  31.         EnableHookChain(g_hcTraceAttack)
  32.     }
  33. }
We can suppress the infection in ze_game_started_pre() forward, however not a bad idea.

Z0uha1r_LK wrote: 2 years ago I see this is better method to chosen player in previous round.

Change this:
  1. // Dynamic Arrays
  2. new Array:g_aChosenPlayers
By this:
  1. // Trie Variables.
  2. new Trie:g_tChosenPlayers
No need to check, If smart random is Enabled, can Owner enable it in any time, and change dyanmic array to Triepublic
  1. public DelaySmartRandom() {
  2.     // Create our Trie to store SteamIDs in
  3.     g_tChosenPlayers = TrieCreate()
  4. }
This better:
  1. Choose_Zombies() {
  2.     new szAuthID[35], iAliveCount, iReqZombies, iZombies, id
  3.    
  4.     // Get total alive players and required players
  5.     iAliveCount  = GetAllAlivePlayersNum()
  6.     iReqZombies = RequiredZombies()
  7.    
  8.     // Get integer value from cvar.
  9.     new iSmartRandom = get_pcvar_num(g_pCvarSmartRandom)
  10.  
  11.     // Get float value (first zombie health) from cvar
  12.     new Float:flFirstZombieHealth = get_pcvar_float(g_pCvarFirstZombiesHealth)
  13.  
  14.     // Loop till we find requires players
  15.     while (iZombies < iReqZombies) {
  16.         // Get random player index.
  17.         id = GetRandomAlive(random_num(1, iAliveCount))
  18.        
  19.         // Get auth (SteamID) of player.
  20.         get_user_authid(id, szAuthID, charsmax(szAuthID))
  21.  
  22.         // Player is died or is already Zombie?
  23.         if (!is_user_alive(id) || g_bIsZombie[id])
  24.             continue;
  25.        
  26.         // Check if CVAR enabled and if player in the Trie, it means he chosen previous round so skip him this round
  27.         if (iSmartRandom && TrieKeyExists(g_tChosenPlayers, szAuthID))
  28.             continue;
  29.  
  30.         // Infect player.
  31.         Set_User_Zombie(id)
  32.  
  33.         // Set zombie health.
  34.         set_entvar(id, var_health, flFirstZombieHealth)
  35.  
  36.         // Set zombie frozen flag.
  37.         g_bIsZombieFrozen[id] = true
  38.         set_entvar(id, var_maxspeed, 1.0)
  39.  
  40.         // New Zombie
  41.         iZombies++
  42.     }
  43.    
  44.     if (iZombies > 0) {
  45.         g_bZombieFreezeTime = true
  46.         set_task(0.1, "Zombies_Speed", ZOMBIES_SPEED, _, _, "b") // Better than PreThink
  47.         ExecuteForward(g_iForwards[FORWARD_ZOMBIE_APPEAR], g_iFwReturn)
  48.     }
  49.  
  50.     // Check from Smart Random is enable?
  51.     if (iSmartRandom) {
  52.         // Clear the Trie first
  53.         TrieClear(g_tChosenPlayers)
  54.        
  55.         new szAuthID[35], id
  56.        
  57.         // Add steamid of chosen zombies, so we don't choose them next round again (using steamid means it support reconnect)
  58.         for (id = 1; id <= g_iMaxClients; id++) {
  59.             // Player not found or is a Zombie?
  60.             if(!is_user_connected(id) || !g_bIsZombie[id])
  61.                 continue
  62.            
  63.             // Get authid (SteamID) of player.
  64.             get_user_authid(id, szAuthID, charsmax(szAuthID))
  65.            
  66.             // Stors SteamIDs of chosen players in Trie.
  67.             TrieSetCell(g_tChosenPlayers, szAuthID, 0)
  68.         }
  69.     }
  70.    
  71.     // 2 is Hardcoded Value, It's Fix for the countdown to work correctly
  72.     g_iCountDown = get_pcvar_num(g_pCvarZombieReleaseTime) - 2
  73.    
  74.     // Show release time.
  75.     set_task(1.0, "ReleaseZombie_CountDown", TASK_COUNTDOWN2, _, _, "b")
  76. }
Test it and ensure this is working without issues.
Z0uha1r_LK wrote: 2 years ago in cs_weap_models_api
change this:
  1. // cstrike
  2. cs_get_weapon_id(entity_id)
to this:
  1. #define EXTRAOFFSET_WEAPONS 4
  2. #define OFFSET_WEAPONTYPE 43
  3.  
  4. // fakemeta.
  5. get_pdata_int(entity_id, OFFSET_WEAPONTYPE, EXTRAOFFSET_WEAPONS)
OK, no doubt that fakemeta is better than cstrike.

Finally to say, you got full access to github. You can now commit every change you do, and make sure to fully describe your commit and to commit only edits you tested and found it 100% running. I'm sorry for late reply, and great job bro that you are trying to continue the project :smiley: :v: :thumbsup: .
He who fails to plan is planning to fail

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#24

Post by Raheem » 2 years ago

If someone is interested to share in the development of the next version, here is the telegram group: https://t.me/escapers_zone
He who fails to plan is planning to fail

User avatar
z0h1r-LK
Mod Developer
Mod Developer
Morocco
Posts: 473
Joined: 5 years ago
Location: The Red City ❤
Contact:

#25

Post by z0h1r-LK » 1 year ago


Locked

Who is online

Users browsing this forum: No registered users and 4 guests