Zombie Escape - Forwards/Natives Examples

Helping Topics
Post Reply
User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1950
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 21
Contact:

Zombie Escape - Forwards/Natives Examples

#1

Post by Raheem » 2 Years Ago

Zombie Escape - Forwards/Natives Examples

Here you will find some useful examples on some forwards/natives, please take time to visit Zombie Escape API to know more about forwards/natives usage.

Forwards:

1- forward ze_roundend(WinTeam)
  • Example of how to use this forward. I'll make simple plugin that will print at the round end the winner team in chat message:

    1. #include <zombie_escape>
    2.  
    3. public plugin_init()
    4. {
    5.     register_plugin("Round End Forward Example", "1.0", "Raheem")
    6. }
    7.  
    8. public ze_roundend(WinTeam)
    9. {
    10.     if (WinTeam == ZE_TEAM_HUMAN)
    11.     {
    12.         client_print(0, print_chat, "Humans Win and Forward Works :)")
    13.     }
    14.     else if (WinTeam == ZE_TEAM_ZOMBIE)
    15.     {
    16.         client_print(0, print_chat, "Zombies Win and Forward Works :)")
    17.     }
    18. }

2- forward ze_user_humanized(id)
  • Example of how to use this forward. I'll make simple plugin that will print message to the humanized player tell him that he now human.

    1. #include <zombie_escape>
    2.  
    3. public plugin_init()
    4. {
    5.     register_plugin("User Humanized Forward Example", "1.0", "Raheem")
    6. }
    7.  
    8. public ze_user_humanized(id)
    9. {
    10.     client_print(id, print_chat, "You are now HUMAN Forward Works :)")
    11. }

3- forward ze_user_infected(iVictim, iInfector)
  • Example of how to use this forward. I'll make simple plugin that will print message "Random zombies infected" when they chosen (Message will be printed to the infected players, iVictims). and note this message will be printed X times. X times is depend on how much players infected in the round start.

    1. #include <zombie_escape>
    2.  
    3. public plugin_init()
    4. {
    5.     register_plugin("User Infected Forward Example", "1.0", "Raheem")
    6. }
    7.  
    8. public ze_user_infected(iVictim, iInfector)
    9. {
    10.     if (iInfector == 0)
    11.     {
    12.         client_print(iVictim, print_chat, "Random zombies infected")
    13.     }
    14. }
  • Another simple Example: I need to print message to the infected player tell him who infect him.

    1. #include <zombie_escape>
    2.  
    3. public plugin_init()
    4. {
    5.     register_plugin("User Infected Forward Example", "1.0", "Raheem")
    6. }
    7.  
    8. public ze_user_infected(iVictim, iInfector)
    9. {
    10.     if (iInfector == 0)
    11.     {
    12.         client_print(iVictim, print_chat, "You have been infected by Server!")
    13.     }
    14.     else
    15.     {
    16.         client_print(iVictim, print_chat, "You have been infected by Player!")
    17.     }
    18. }

4- forward ze_zombie_appear()
  • Simple Example, If i need to post message to all players when zombie appear tell them that zombie appear i do:

    1. #include <zombie_escape>
    2.  
    3. public plugin_init()
    4. {
    5.     register_plugin("Zombie Appear Forward Example", "1.0", "Raheem")
    6. }
    7.  
    8. public ze_zombie_appear()
    9. {
    10.     client_print(0, print_chat, "Zombie Chosen! RUN!!!!")
    11. }

5- forward ze_zombie_release()
  • Simple Example, Post message tell all players that zombies released:

    1. #include <zombie_escape>
    2.  
    3. public plugin_init()
    4. {
    5.     register_plugin("Zombie Release Forward Example", "1.0", "Raheem")
    6. }
    7.  
    8. public ze_zombie_release()
    9. {
    10.     client_print(0, print_chat, "Zombie Released!! RUN!!!!")
    11. }

6- forward ze_game_started()
  • Simple example, Just this message will be printed every round if game started if not it won't printed till game started.

    1. #include <zombie_escape>
    2.  
    3. public plugin_init()
    4. {
    5.     register_plugin("Game Started Forward Example", "1.0", "Raheem")
    6. }
    7.  
    8. public ze_game_started()
    9. {
    10.     client_print(0, print_chat, "New Round! and Game Already Started! and I'am a Spam message!")
    11. }

7- forward ze_select_item_pre(id, itemid, ignorecost), forward ze_select_item_post(id, itemid, ignorecost)
  • Example of the Extra-Item Forwards: If player is human this item will show for him also if he have enough escape coins the item will be available for him else the item won't be available but it's already shown.

    1. #include <zombie_escape>
    2.  
    3. new g_iItemID
    4.  
    5. public plugin_init()
    6. {
    7.     register_plugin("Human Extra-Item Example", "1.0", "Raheem")
    8.    
    9.     // Register the item and save it's id
    10.     g_iItemID = ze_register_item("Ak47", 10, 0)
    11. }
    12.  
    13. public ze_select_item_pre(id, itemid)
    14. {
    15.     // This not our item?
    16.     if (itemid != g_iItemID)
    17.         return ZE_ITEM_AVAILABLE
    18.    
    19.     // Available for Humans only, So don't show it for zombies
    20.     if (ze_is_user_zombie(id))
    21.         return ZE_ITEM_DONT_SHOW
    22.    
    23.     // Finally return that it's available
    24.     return ZE_ITEM_AVAILABLE
    25. }
    26.  
    27. public ze_select_item_post(id, itemid)
    28. {
    29.     // This is not our item, Block it here and don't execute the blew code
    30.     if (itemid != g_iItemID)
    31.         return
    32.    
    33.     rg_give_item(id, "weapon_ak47", GT_APPEND)
    34. }

8- forward ze_fire_pre(id)
  • Let's make example, in specific case you need zombie not to get fired.

    1. #include <zombie_escape>
    2.  
    3. // Make this variable true in the case you need to block zombie from get fired
    4. new bool:g_bPreventFire
    5.  
    6. public plugin_init()
    7. {
    8.     register_plugin("Prevent Fire Event", "1.0", "Raheem")
    9. }
    10.  
    11. public ze_fire_pre(id)
    12. {
    13.     // Now we check if preventfire is true we block the event
    14.     // Note that id is the zombie that will be fired id
    15.     if (g_bPreventFire)
    16.     {
    17.         // Block the fire event on this zombie
    18.         return 1;
    19.     }
    20.    
    21.     // Here the PreventFire false then allow fire this zombie
    22.     return 0;
    23. }

9- forward ze_user_infected_pre(iVictim, iInfector, iDamage)
  • Example, don't infect zombie in specific case.

    1. #include <zombie_escape>
    2.  
    3. // Make this variable true in the case you need to block human from being infected
    4. new bool:g_bStopInfection
    5.  
    6. public plugin_init()
    7. {
    8.     register_plugin("Prevent Fire Event", "1.0", "Raheem")
    9. }
    10.  
    11. public ze_user_infected_pre(iVictim, iInfector, iDamage)
    12. {
    13.     if (g_bStopInfection)
    14.     {
    15.         return 1;
    16.     }
    17.    
    18.     return 0;
    19. }

    Another good example is armor: viewtopic.php?p=4218#p4218
Natives:

1- native ze_set_human_speed_factor(id, iFactor)
  • Please note that will set a factor that will be added to player current speed. And you should note that there is another factor is added by default in our Mod by this cvar ze_human_speed_factor "20.0" so you should add this factor to your new factor. Let's take example to add 20 speed factor to humans current speed:

    1. #include <zombie_escape>
    2.  
    3. // Cvars
    4. new g_pCvarHumanSpeed
    5.  
    6. public plugin_init()
    7. {
    8.     register_plugin("Humans Speed", "1.0", "Raheem")
    9.    
    10.     // Here we get the default factor to be added to new factor
    11.     g_pCvarHumanSpeed = get_cvar_pointer("ze_human_speed_factor") // This cvar in core.sma
    12. }
    13.  
    14. public ze_user_humanized(id)
    15. {
    16.     // Now we will give humans +20 factor on humanized + the default factor
    17.     ze_set_human_speed_factor(id, get_pcvar_num(g_pCvarHumanSpeed) + 20)
    18. }

    Another example, let's add 20 speed to zombies:

    1. #include <zombie_escape>
    2.  
    3. // Cvars
    4. new g_pCvarZombieSpeed
    5.  
    6. // Variables
    7. new g_iMaxPlayers
    8.  
    9. public plugin_init()
    10. {
    11.     register_plugin("Zombies Speed", "1.0", "Raheem")
    12.    
    13.     // Here we get the default factor to be added to new factor
    14.     g_pCvarZombieSpeed = get_cvar_pointer("ze_zombie_speed") // This cvar in core.sma
    15.    
    16.     g_iMaxPlayers = get_member_game(m_nMaxPlayers)
    17. }
    18.  
    19. // When the first chosen zombie released we set speed (This is the right time for setting speed)
    20. public ze_zombie_release()
    21. {
    22.     for(new id = 1; id <= g_iMaxPlayers; id++)
    23.     {
    24.         if (!ze_is_user_zombie(id))
    25.             continue;
    26.        
    27.         // Here we get the default zombies speed and add to it 10
    28.         ze_set_zombie_speed(id, get_pcvar_num(g_pCvarZombieSpeed) + 10)
    29.     }
    30. }
    31.  
    32. // If human infected, here we will set his speed also
    33. public ze_user_infected(id, iInfector)
    34. {
    35.     // This to ensure it's not infected by the server
    36.     if (iInfector == 0)
    37.         return
    38.    
    39.     // Add 10 to default speed
    40.     ze_set_zombie_speed(id, get_pcvar_num(g_pCvarZombieSpeed) + 10)
    41. }

    Please note:
    • ze_set_human_speed_factor(id, 10) same as get user weapon speed + 10.
    • ze_set_zombie_speed(id, 10) same as set user speed to 10.
    Also please note that the speed is reset when player disconnect, not reset at new round.
    Note also that you can't set your speed with ze_set_human_speed_factor() native, it's only to add factor to it's speed.

    Please consider using native ze_reset_human_speed(id) to reset human speed to the original values default in Mod. And native ze_reset_zombie_speed(id) to reset zombies speed to default values in the Mod.
You don't know? Learn and you will know.

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1950
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 21
Contact:

#2

Post by Raheem » 2 Years Ago

Updated this guide with the new natives in our new version of mod:
  • Code: Select all

    native ze_register_item(const szItemName[], iCost, iLimit);
    native ze_add_text_to_item(const szText[]);
    native ze_get_item_limit(iItemid);
    native ze_get_escape_leader_id();
You don't know? Learn and you will know.

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1950
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 21
Contact:

#3

Post by Raheem » 1 Year Ago

Updated this topic, Check our new page for Zombie Escape API: https://escapers-zone.net/api/

I'll update this and add much examples whenever i find time to do that.
You don't know? Learn and you will know.

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1950
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 21
Contact:

#4

Post by Raheem » 11 Months Ago

Speed explanation added with examples. Also added example of using ze_set_item_vip() here: api/zombie_escape/ze_set_item_vip
You don't know? Learn and you will know.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest