/*================================================================================ --------------------------------------------------- -*- Zombie Plague Nightmare 2.1.3 Includes File -*- --------------------------------------------------- ~~~~~~~~~~ - How To - ~~~~~~~~~~ To make use of the Zombie Plague API features in your plugin, just add the following line at the beginning of your script: #include ~~~~~~~~~~~ - Natives - ~~~~~~~~~~~ These work just like any other functions: you may have to pass parameters and they usually return values. Example: if ( zpnm_get_user_alive( id ) && zp_get_user_zombie( id ) ) { server_print( "Player %d is alive and a zombie", id ) } ~~~~~~~~~~~~ - Forwards - ~~~~~~~~~~~~ Forwards get called whenever an event happens during the game. You need to make a public callback somewhere on your script, and it will automatically be triggered when the event occurs. Example: public zp_user_infected_post( id, infector, nemesis, assassin, nade ) { if ( !infector || nemesis || assassin ) return; server_print( "Player %d just got infected by %d!", id, infector ) } Also, take note of cases when there's a suffix: * _pre : means the forward will be called BEFORE the event happens * _post : means it will be called AFTER the event takes place =================================================================================*/ #if defined _zombieplaguenightmare_included #endinput #endif #define _zombieplaguenightmare_included /* Teams for zp_register_extra_item() */ #define ZP_TEAM_ZOMBIE (1<<0) #define ZP_TEAM_HUMAN (1<<1) #define ZP_TEAM_NEMESIS (1<<2) #define ZP_TEAM_SURVIVOR (1<<3) #define ZP_TEAM_SNIPER (1<<4) #define ZP_TEAM_ASSASSIN (1<<5) /* Game modes for zp_round_started() */ enum { MODE_NONE = 0, MODE_INFECTION, MODE_NEMESIS, MODE_SURVIVOR, MODE_SWARM, MODE_MULTI, MODE_PLAGUE, MODE_SNIPER, MODE_ASSASSIN } /* Winner teams for zp_round_ended() */ enum { WIN_NO_ONE = 0, WIN_ZOMBIES, WIN_HUMANS } /* Hard coded extra item IDs */ enum { EXTRA_BPAMMO = -1, EXTRA_NVISION, EXTRA_ANTIDOTE, EXTRA_MADNESS, EXTRA_INFBOMB, EXTRA_WEAPONS_STARTID } /* How the player received ammo packs */ enum { AMMO_DAMAGE = 0, AMMO_KILL, AMMO_INFECT, AMMO_MAIN, AMMO_SUB } /* Custom forward return values */ #define ZP_PLUGIN_HANDLED 97 /** * Returns whether a player is a zombie. * * @param id Player index. * @return True if it is, false otherwise. */ native zp_get_user_zombie(id) /** * Returns whether a player is a nemesis. * * @param id Player index. * @return True if it is, false otherwise. */ native zp_get_user_nemesis(id) native zpnm_get_user_assassin(id) /** * Returns whether a player is a survivor. * * @param id Player index. * @return True if it is, false otherwise. */ native zp_get_user_survivor(id) native zpnm_get_user_sniper(id) /** * Returns whether a player is the first zombie. * * @param id Player index. * @return True if it is, false otherwise. */ native zp_get_user_first_zombie(id) /** * Returns whether a player is the last zombie. * * @param id Player index. * @return True if it is, false otherwise. */ native zp_get_user_last_zombie(id) /** * Returns whether a player is the last human. * * @param id Player index. * @return True if it is, false otherwise. */ native zp_get_user_last_human(id) /** * Returns a player's current zombie class ID. * * @param id Player index. * @return Internal zombie class ID, or -1 if not yet chosen. */ native zp_get_user_zombie_class(id) native zpnm_get_user_human_class(id) /** * Returns a player's next zombie class ID (for the next infection). * * @param id Player index. * @return Internal zombie class ID, or -1 if not yet chosen. */ native zp_get_user_next_class(id) native zpnm_get_user_next_hclass(id) /** * Sets a player's next zombie class ID (for the next infection). * * @param id Player index. * @param classid A valid zombie class ID. * @return True on success, false otherwise. */ native zp_set_user_zombie_class(id, classid) native zpnm_set_user_human_class(id, classid) /** * Returns a player's ammo pack count. * * @param id Player index. * @return Number of ammo packs owned. */ native zp_get_user_ammo_packs(id) /** * Sets a player's ammo pack count. * * @param id Player index. * @param amount New quantity of ammo packs owned. */ native zp_set_user_ammo_packs(id, amount) /** * Returns the default maximum health of a zombie. * * Note: Takes into account first zombie's HP multiplier. * * @param id Player index. * @return Maximum amount of health points, or -1 if not a normal zombie. */ native zp_get_zombie_maxhealth(id) native zpnm_get_human_maxhealth(id) /** * Returns a player's custom flashlight batteries charge. * * @param id Player index. * @return Charge percent (0 to 100). */ native zp_get_user_batteries(id) /** * Sets a player's custom flashlight batteries charge. * * @param id Player index. * @param value New charge percent (0 to 100). */ native zp_set_user_batteries(id, charge) /** * Returns whether a player has night vision. * * @param id Player index. * @return True if it has, false otherwise. */ native zp_get_user_nightvision(id) /** * Sets whether a player has night vision. * * @param id Player index. * @param set True to give, false for removing it. */ native zp_set_user_nightvision(id, set) /** * Forces a player to become a zombie. * * Note: Unavailable for last human/survivor/sniper. * * @param id Player index to be infected. * @param infector Player index who infected him (optional). * @param silent If set, there will be no HUD messages or infection sounds. * @param rewards Whether to show DeathMsg and reward frags, hp, and ammo packs to infector. * @return True on success, false otherwise. */ native zp_infect_user(id, infector = 0, silent = 0, rewards = 0) /** * Forces a player to become a human. * * Note: Unavailable for last zombie/nemesis/assassin. * * @param id Player index to be cured. * @param silent If set, there will be no HUD messages or antidote sounds. * @return True on success, false otherwise. */ native zp_disinfect_user(id, silent = 0) /** * Forces a player to become a nemesis. * * Note: Unavailable for last human/survivor/sniper. * * @param id Player index to turn into nemesis. * @return True on success, false otherwise. */ native zp_make_user_nemesis(id) native zpnm_make_user_assassin(id) /** * Forces a player to become a survivor. * * Note: Unavailable for last zombie/nemesis/assassin. * * @param id Player index to turn into survivor. * @return True on success, false otherwise. */ native zp_make_user_survivor(id) native zpnm_make_user_sniper(id) /** * Respawns a player into a specific team. * * @param id Player index to be respawned. * @param team Team to respawn the player into (ZP_TEAM_ZOMBIE or ZP_TEAM_HUMAN). * Can now use 0(or not specify) for auto detection. * @return True on success, false otherwise. */ native zp_respawn_user(id, team = 0) /** * Forces a player to buy an extra item. * * @param id Player index. * @param itemid A valid extra item ID. * @param ignorecost If set, item's cost won't be deduced from player. * @return True on success, false otherwise. */ native zp_force_buy_extra_item(id, itemid, ignorecost = 0) /** * Overrides ZP player model with a different custom model. * * Note: This will last until player's next infection/humanization/respawn. * * Note: Don't call more often than absolutely needed. * * @param id Player index. * @param newmodel Model name. * @param modelindex Modelindex (optional). */ native zp_override_user_model(id, const newmodel[], modelindex = 0) /** * Returns whether the ZP round has started, i.e. first zombie * has been chosen or a game mode has begun. * * @return 0 - Round not started * 1 - Round started * 2 - Round starting */ native zp_has_round_started() /** * Returns whether the current round is a nemesis round. * * @return True if it is, false otherwise. */ native zp_is_nemesis_round() native zpnm_is_assassin_round() /** * Returns whether the current round is a survivor round. * * @return True if it is, false otherwise. */ native zp_is_survivor_round() native zpnm_is_sniper_round() /** * Returns whether the current round is a swarm round. * * @return True if it is, false otherwise. */ native zp_is_swarm_round() /** * Returns whether the current round is a plague round. * * @return True if it is, false otherwise. */ native zp_is_plague_round() /** * Returns number of alive zombies. * * @return Zombie count. */ native zp_get_zombie_count() /** * Returns number of alive humans. * * @return Human count. */ native zp_get_human_count() /** * Returns number of alive nemesis. * * @return Nemesis count. */ native zp_get_nemesis_count() native zpnm_get_assassin_count() /** * Returns number of alive survivors. * * @return Survivor count. */ native zp_get_survivor_count() native zpnm_get_sniper_count() /** * Registers a custom item which will be added to the extra items menu of ZP. * * Note: The returned extra item ID can be later used to catch item * purchase events for the zp_extra_item_selected() forward. * * Note: ZP_TEAM_NEMESIS and ZP_TEAM_SURVIVOR can be used to make * an item available to Nemesis and Survivors respectively. * ZP_TEAM_SNIPER for Sniper and ZP_TEAM_ASSASSIN for Assassin. * * @param name Caption to display on the menu. * @param cost Ammo packs to be deducted on purchase. * @param teams Bitsum of teams it should be available for. * @return An internal extra item ID, or -1 on failure. */ native zp_register_extra_item(const name[], cost, teams) /** * Registers a custom class which will be added to the zombie classes menu of ZP. * * Note: The returned zombie class ID can be later used to identify * the class when calling the zp_get_user_zombie_class() natives. * * @param name Caption to display on the menu. * @param info Brief description of the class. * @param model Player model to be used. * @param clawmodel Claws model to be used. * @param hp Initial health points. * @param speed Maximum speed. * @param gravity Gravity multiplier. * @param knockback Knockback multiplier. * @return An internal zombie class ID, or -1 on failure. */ native zp_register_zombie_class(const name[], const info[], const model[], const clawmodel[], hp, speed, Float:gravity, Float:knockback) native zpnm_register_human_class(const name[], const info[], const model[], const handmodel[], hp, speed, Float:gravity) /** * Returns an extra item's ID. * * @param name Item name to look for. * @return Internal extra item ID, or -1 if not found. */ native zp_get_extra_item_id(const name[]) /** * Returns a zombie class' ID. * * @param name Class name to look for. * @return Internal zombie class ID, or -1 if not found. */ native zp_get_zombie_class_id(const name[]) native zpnm_get_human_class_id(const name[]) /** * Returns a zombie class' description (passed by reference). * * @param classid Internal zombie class ID. * @param info The buffer to store the string in. * @param len Character size of the output buffer. * @return True on success, false otherwise. */ native zp_get_zombie_class_info(classid, info[], len) native zpnm_get_human_class_info(classid, info[], len) /** * Called when the ZP round starts, i.e. first zombie * is chosen or a game mode begins. * * @param gamemode Mode which has started. * @param id Affected player's index (if applicable). */ forward zp_round_started(gamemode, id) /** * Called when the round ends. * * @param winteam Team which has won the round. */ forward zp_round_ended(winteam) /** * Called when a player gets infected. * * @param id Player index who was infected. * @param infector Player index who infected him (if applicable). * @param nemesis Whether the player was turned into a nemesis. * @param assassin Whether the player was turned into an assassin. */ forward zp_user_infected_pre(id, infector, nemesis, assassin, nade) forward zp_user_infected_post(id, infector, nemesis, assassin, nade) /** * Called when a player turns back to human. * * @param id Player index who was cured. * @param survivor Whether the player was turned into a survivor. * @param sniper Whether the player was turned into a sniper. */ forward zp_user_humanized_pre(id, survivor, sniper) forward zp_user_humanized_post(id, survivor, sniper) /** * Called on a player infect/cure attempt. You can use this to block * an infection/humanization by returning ZP_PLUGIN_HANDLED in your plugin. * * Note: Right now this is only available after the ZP round starts, since some * situations (like blocking a first zombie's infection) are not yet handled. */ forward zp_user_infect_attempt(id, infector, nemesis, assassin, nade) forward zp_user_humanize_attempt(id, survivor, sniper) /** * Called when a player buys an extra item from the ZP menu. * * Note: You can now return ZP_PLUGIN_HANDLED in your plugin to block * the purchase and the player will be automatically refunded. * * Note #2: You can now even block the hard coded extra items using * the new "buy attempt" forward. Check above for their IDs. * The new forward is executed before the "item selected", so you can * use it to overwrite the plugins that use the older one * without having to move them around in the list. * * @param id Player index of purchaser. * @param itemid Internal extra item ID. * @param ignorecost Wheter the player was not charged. * @param cost How much the item costs. */ forward zp_extra_item_selected(id, itemid, ignorecost, cost) forward zpnm_extra_item_buy_attempt(id, itemid, ignorecost, cost) /** * Called when a player gets unfrozen (frostnades). * * @param id Player index. * @param attacker Attacker index. */ forward zp_user_unfrozen(id, attacker) /** * Called when a player becomes the last zombie. * * Note: This is called for the first zombie too. * * @param id Player index. */ forward zp_user_last_zombie(id) /** * Called when a player becomes the last human. * * @param id Player index. */ forward zp_user_last_human(id) /** * @deprecated - Do not use! * For backwards compatibility only. */ #define ZP_TEAM_ANY 0 /** * Note: Setting the health lower than 1 will kill * the player using ExecuteHamB(Ham_Killed, ...). * In this case you can specify the killer * and whether the player should gib or not. */ native zpnm_set_user_health(id, health, killer = 0, shouldgib = 0) native zpnm_set_user_armor(id, armor) native zpnm_get_user_burning(id) native zpnm_set_user_burning(id, timer, attacker = 0) native zpnm_get_user_frozen(id) native zpnm_set_user_frozen(id, set, attacker = 0) native zpnm_get_user_no_damage(id) /** * Note: Can be used for both zombies and humans. * * Param timer Duration of immunity. * 0.0 or lower means off. * Param effects Visual and audio effects * madness-like when timer > 0.0 * 1 - on | 0 - off */ native zpnm_set_user_no_damage(id, Float:timer, effects = 0) native zpnm_get_user_model(id, model[], len) native zpnm_get_user_maxspeed(id) native zpnm_set_user_maxspeed(id, maxspeed) native zpnm_reset_user_maxspeed(id) native zpnm_get_user_gravity(id) native zpnm_set_user_gravity(id, gravity) native Float:zpnm_get_user_knockback(id) /** * Note: For normal zombies, this will last until player's next infection, * so you will need to set it every zp_user_infected_post if you want to keep it. * A value lower than 0.0 of knockback means to reset the player's knockback */ native zpnm_set_user_knockback(id, Float:knockback) native zpnm_strip_user_weapons(id) /** * Item in weapon_X format * Ammo parameter means: 0 = don't give ammo, 1 = give */ native zpnm_give_user_item(id, const item[], ammo = 0) native zpnm_get_user_valid(id) native zpnm_get_user_connected(id) native zpnm_get_user_alive(id) /** * Teams: 0 = zombies, 1 = humans */ native zpnm_get_class_name(team, classid, info[], len) /** * Type means: 1 = Primary or 2 = Secondary */ native zpnm_drop_user_weapons(id, type) /** * Manually start a game mode if none is currently running. * * @param gamemode Mode to start. * @param id Affected player's index (if applicable). * * Note: Set gamemode to -1 if you only want to prevent the round mode from starting. */ native zpnm_set_game_mode(gamemode, id = 0) forward zpnm_user_spawn_pre(id) forward zpnm_user_spawn_post(id) forward zpnm_user_killed_pre(victim, attacker, shouldgib) forward zpnm_user_killed_post(victim, attacker, shouldgib) forward zpnm_user_take_damage_attempt(victim, inflictor, attacker, Float:damage, damage_type) forward zpnm_user_take_damage_post(victim, inflictor, attacker, Float:damage, damage_type) /** * Note: This is called every 0.2 seconds and does * the amount of damage returned by the "damage" parameter("zp_fire_damage" cvar) * When "post" is 0 it means that the player hasn't taken damage yet * and that you can stop the fire using the provided native above * When "post" is 1 it means that the player has already taken damage, but you * can still stop the fire and prevent further damage with the same native */ forward zpnm_user_burn(victim, attacker, damage, post) forward zpnm_user_frozen(victim, attacker) /** * Type means: 1 = Primary, 2 = Secondary * Wname means weapon name in weapon_X format */ forward zpnm_user_get_weapons(id, type, wname) /** * From: 0 - damage done(applies for both humans and zombies) * 1 - kill(only zombies) * 2 - infect * 3 - set by the main plugin(can have negative values) * 4 - set by sub-plugins(can have negative values) * * NOTE!!!: 4 is called when the zp_set_user_ammo_packs native is used, * so if you plan on using it inside this forward, make sure parameter * "from" is equal with 0, 1, 2 or 3(NOT 4!) to avoid an infinite loop */ forward zpnm_user_get_ammo_packs(id, amount, from) /** * For registering special Ham forwards on CZ bots. * Note: This forward will only be called once, when the first CZ bot connects. */ forward zpnm_register_ham_czbots(id) /** * Teleports a player to his base or to a CSDM spawn point(if available). * * @param id Affected player's index. * @param base 1 teleports to base, 0 to a CSDM spawn * * Note: Player must be valid and alive. */ native zpnm_teleport_user(id, base = 0) native zpnm_get_user_unlimited_ammo(id) /** * Sets a player's unlimited ammo. * * @param id Affected player's index. * @param set 0 off * 1 unlimited reloads * 2 unlimited clip * * Note: Player must be valid and alive. */ native zpnm_set_user_unlimited_ammo(id, set)