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:
- #include <zombie_escape>
- public plugin_init()
- {
- register_plugin("Round End Forward Example", "1.0", "Raheem")
- }
- public ze_roundend(WinTeam)
- {
- if (WinTeam == ZE_TEAM_HUMAN)
- {
- client_print(0, print_chat, "Humans Win and Forward Works :)")
- }
- else if (WinTeam == ZE_TEAM_ZOMBIE)
- {
- client_print(0, print_chat, "Zombies Win and Forward Works :)")
- }
- }
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.
- #include <zombie_escape>
- public plugin_init()
- {
- register_plugin("User Humanized Forward Example", "1.0", "Raheem")
- }
- public ze_user_humanized(id)
- {
- client_print(id, print_chat, "You are now HUMAN Forward Works :)")
- }
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.
- #include <zombie_escape>
- public plugin_init()
- {
- register_plugin("User Infected Forward Example", "1.0", "Raheem")
- }
- public ze_user_infected(iVictim, iInfector)
- {
- if (iInfector == 0)
- {
- client_print(iVictim, print_chat, "Random zombies infected")
- }
- }
- Another simple Example: I need to print message to the infected player tell him who infect him.
- #include <zombie_escape>
- public plugin_init()
- {
- register_plugin("User Infected Forward Example", "1.0", "Raheem")
- }
- public ze_user_infected(iVictim, iInfector)
- {
- if (iInfector == 0)
- {
- client_print(iVictim, print_chat, "You have been infected by Server!")
- }
- else
- {
- client_print(iVictim, print_chat, "You have been infected by Player!")
- }
- }
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:
- #include <zombie_escape>
- public plugin_init()
- {
- register_plugin("Zombie Appear Forward Example", "1.0", "Raheem")
- }
- public ze_zombie_appear()
- {
- client_print(0, print_chat, "Zombie Chosen! RUN!!!!")
- }
5-
forward ze_zombie_release()
- Simple Example, Post message tell all players that zombies released:
- #include <zombie_escape>
- public plugin_init()
- {
- register_plugin("Zombie Release Forward Example", "1.0", "Raheem")
- }
- public ze_zombie_release()
- {
- client_print(0, print_chat, "Zombie Released!! RUN!!!!")
- }
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.
- #include <zombie_escape>
- public plugin_init()
- {
- register_plugin("Game Started Forward Example", "1.0", "Raheem")
- }
- public ze_game_started()
- {
- client_print(0, print_chat, "New Round! and Game Already Started! and I'am a Spam message!")
- }
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.
- #include <zombie_escape>
- new g_iItemID
- public plugin_init()
- {
- register_plugin("Human Extra-Item Example", "1.0", "Raheem")
- // Register the item and save it's id
- g_iItemID = ze_register_item("Ak47", 10, 0)
- }
- public ze_select_item_pre(id, itemid)
- {
- // This not our item?
- if (itemid != g_iItemID)
- return ZE_ITEM_AVAILABLE
- // Available for Humans only, So don't show it for zombies
- if (ze_is_user_zombie(id))
- return ZE_ITEM_DONT_SHOW
- // Finally return that it's available
- return ZE_ITEM_AVAILABLE
- }
- public ze_select_item_post(id, itemid)
- {
- // This is not our item, Block it here and don't execute the blew code
- if (itemid != g_iItemID)
- return
- rg_give_item(id, "weapon_ak47", GT_APPEND)
- }
8-
forward ze_fire_pre(id)
- Let's make example, in specific case you need zombie not to get fired.
- #include <zombie_escape>
- // Make this variable true in the case you need to block zombie from get fired
- new bool:g_bPreventFire
- public plugin_init()
- {
- register_plugin("Prevent Fire Event", "1.0", "Raheem")
- }
- public ze_fire_pre(id)
- {
- // Now we check if preventfire is true we block the event
- // Note that id is the zombie that will be fired id
- if (g_bPreventFire)
- {
- // Block the fire event on this zombie
- return ZE_STOP;
- }
- // Here the PreventFire false then allow fire this zombie
- return ZE_CONTINUE;
- }
9-
forward ze_user_infected_pre(iVictim, iInfector, iDamage)
- Example, don't infect zombie in specific case.
- #include <zombie_escape>
- // Make this variable true in the case you need to block human from being infected
- new bool:g_bStopInfection
- public plugin_init()
- {
- register_plugin("Prevent Fire Event", "1.0", "Raheem")
- }
- public ze_user_infected_pre(iVictim, iInfector, iDamage)
- {
- if (g_bStopInfection)
- {
- return ZE_STOP;
- }
- return ZE_CONTINUE;
- }
Another good example is armor: viewtopic.php?p=4218#p4218
Another example, if you need to block the infection of first zombies that are chosen by the server:
- #include <zombie_escape>
- public plugin_init()
- {
- register_plugin("[ZE] Block Zombies Appear", "1.0", "Raheem")
- }
- public ze_user_infected_pre(iVictim, iInfector, iDamage)
- {
- // Block first infection
- if (iInfector == 0)
- {
- StopSound()
- set_task(0.11, "DelayRemoveMessage")
- return ZE_STOP
- }
- return ZE_CONTINUE
- }
- public DelayRemoveMessage()
- {
- ze_remove_zombie_freeze_msg()
- }
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:
- #include <zombie_escape>
- // Cvars
- new g_pCvarHumanSpeed
- public plugin_init()
- {
- register_plugin("Humans Speed", "1.0", "Raheem")
- // Here we get the default factor to be added to new factor
- g_pCvarHumanSpeed = get_cvar_pointer("ze_human_speed_factor") // This cvar in core.sma
- }
- public ze_user_humanized(id)
- {
- // Now we will give humans +20 factor on humanized + the default factor
- ze_set_human_speed_factor(id, get_pcvar_num(g_pCvarHumanSpeed) + 20)
- }
Another example, let's add 20 speed to zombies:
- #include <zombie_escape>
- // Cvars
- new g_pCvarZombieSpeed
- // Variables
- new g_iMaxPlayers
- public plugin_init()
- {
- register_plugin("Zombies Speed", "1.0", "Raheem")
- // Here we get the default factor to be added to new factor
- g_pCvarZombieSpeed = get_cvar_pointer("ze_zombie_speed") // This cvar in core.sma
- g_iMaxPlayers = get_member_game(m_nMaxPlayers)
- }
- // When the first chosen zombie released we set speed (This is the right time for setting speed)
- public ze_zombie_release()
- {
- for(new id = 1; id <= g_iMaxPlayers; id++)
- {
- if (!ze_is_user_zombie(id))
- continue;
- // Here we get the default zombies speed and add to it 10
- ze_set_zombie_speed(id, get_pcvar_num(g_pCvarZombieSpeed) + 10)
- }
- }
- // If human infected, here we will set his speed also
- public ze_user_infected(id, iInfector)
- {
- // This to ensure it's not infected by the server
- if (iInfector == 0)
- return
- // Add 10 to default speed
- ze_set_zombie_speed(id, get_pcvar_num(g_pCvarZombieSpeed) + 10)
- }
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.
Note also that you can't set your speed withze_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.