zombie_plague_advance.inc

Original include source with line numbers.

Back Download .inc
1 /***************************************************************************\
2 ===============================================
3 * || Zombie Plague Advance Includes File || *
4 ===============================================
5
6
7 ---------------
8 *||How to ||*
9 ---------------
10
11 To make use of the Zombie Plague Advance API features in your plugin,
12 just add the following line at the beginning of your script:
13
14 #include <zombie_plague_advance>
15
16 ---------------
17 *||Natives||*
18 ---------------
19
20 These work just like any other functions: you may have to pass
21 parameters and they usually return values.
22
23 Example:
24
25 if ( is_user_alive( id ) && zp_get_user_zombie( id ) )
26 {
27 server_print( "Player %d is alive and a zombie", id )
28 }
29
30 ----------------
31 *||Forwards||*
32 ----------------
33
34 Forwards get called whenever an event happens during the game.
35 You need to make a public callback somewhere on your script,
36 and it will automatically be triggered when the event occurs.
37
38 Example:
39
40 public zp_user_infected_post( id, infector, nemesis )
41 {
42 if ( !infector || nemesis )
43 return;
44
45 server_print( "Player %d just got infected by %d!", id, infector )
46 }
47
48 Also, take note of cases when there's a suffix:
49 [These suffixes are only available in some forwards]
50
51 * _pre : means the forward will be called BEFORE the event happens
52 * _post : means it will be called AFTER the event takes place
53
54 \***************************************************************************/
55
56 #if defined _zombie_plague_advance_included
57 #endinput
58 #endif
59 #define _zombie_plague_advance_included
60
61 /* Teams for zp_register_extra_item() */
62 #define ZP_TEAM_ZOMBIE (1<<0)
63 #define ZP_TEAM_HUMAN (1<<1)
64 #define ZP_TEAM_NEMESIS (1<<2)
65 #define ZP_TEAM_SURVIVOR (1<<3)
66 #define ZP_TEAM_SNIPER (1<<4)
67 #define ZP_TEAM_ASSASSIN (1<<5)
68
69 /* Death Match modes for zp_register_game_mode */
70 enum
71 {
72 ZP_DM_NONE = 0, // Disable death match during the custom mode round
73 ZP_DM_HUMAN, // Respawn as human only
74 ZP_DM_ZOMBIE, // Respawn as zombie only
75 ZP_DM_RANDOM, // Respawn randomly as humans or zombies
76 ZP_DM_BALANCE // Respawn as humans or zombies to keep both team balanced
77 }
78
79 /* Game modes for zp_round_started() */
80 enum
81 {
82 MODE_NONE = 0,
83 MODE_INFECTION,
84 MODE_NEMESIS,
85 MODE_ASSASSIN,
86 MODE_SURVIVOR,
87 MODE_SNIPER,
88 MODE_SWARM,
89 MODE_MULTI,
90 MODE_PLAGUE,
91 MODE_LNJ
92 }
93
94 /* Winner teams for zp_round_ended() */
95 enum
96 {
97 WIN_NO_ONE = 0,
98 WIN_ZOMBIES,
99 WIN_HUMANS
100 }
101
102 /* Custom forward return values */
103 #define ZP_PLUGIN_HANDLED 97
104
105 /**
106 * Returns whether a player is a zombie.
107 *
108 * @param id Player index.
109 * @return True if it is, false otherwise.
110 */
111 native zp_get_user_zombie(id)
112
113 /**
114 * Returns whether a player is a nemesis.
115 *
116 * @param id Player index.
117 * @return True if it is, false otherwise.
118 */
119 native zp_get_user_nemesis(id)
120
121 /**
122 * Returns whether a player is a survivor.
123 *
124 * @param id Player index.
125 * @return True if it is, false otherwise.
126 */
127 native zp_get_user_survivor(id)
128
129 /**
130 * Returns whether a player is the first zombie.
131 *
132 * @param id Player index.
133 * @return True if it is, false otherwise.
134 */
135 native zp_get_user_first_zombie(id)
136
137 /**
138 * Returns whether a player is the last zombie.
139 *
140 * @param id Player index.
141 * @return True if it is, false otherwise.
142 */
143 native zp_get_user_last_zombie(id)
144
145 /**
146 * Returns whether a player is the last human.
147 *
148 * @param id Player index.
149 * @return True if it is, false otherwise.
150 */
151 native zp_get_user_last_human(id)
152
153 /**
154 * Returns a player's current zombie class ID.
155 *
156 * @param id Player index.
157 * @return Internal zombie class ID, or -1 if not yet chosen.
158 */
159 native zp_get_user_zombie_class(id)
160
161 /**
162 * Returns a player's next zombie class ID (for the next infection).
163 *
164 * @param id Player index.
165 * @return Internal zombie class ID, or -1 if not yet chosen.
166 */
167 native zp_get_user_next_class(id)
168
169 /**
170 * Sets a player's next zombie class ID (for the next infection).
171 *
172 * @param id Player index.
173 * @param classid A valid zombie class ID.
174 * @return True on success, false otherwise.
175 */
176 native zp_set_user_zombie_class(id, classid)
177
178 /**
179 * Returns a player's ammo pack count.
180 *
181 * @param id Player index.
182 * @return Number of ammo packs owned.
183 */
184 native zp_get_user_ammo_packs(id)
185
186 /**
187 * Sets a player's ammo pack count.
188 *
189 * @param id Player index.
190 * @param amount New quantity of ammo packs owned.
191 */
192 native zp_set_user_ammo_packs(id, amount)
193
194 /**
195 * Returns the default maximum health of a zombie.
196 *
197 * Note: Takes into account first zombie's HP multiplier.
198 *
199 * @param id Player index.
200 * @return Maximum amount of health points, or -1 if not a normal zombie.
201 */
202 native zp_get_zombie_maxhealth(id)
203
204 /**
205 * Returns a player's custom flashlight batteries charge.
206 *
207 * @param id Player index.
208 * @return Charge percent (0 to 100).
209 */
210 native zp_get_user_batteries(id)
211
212 /**
213 * Sets a player's custom flashlight batteries charge.
214 *
215 * @param id Player index.
216 * @param value New charge percent (0 to 100).
217 */
218 native zp_set_user_batteries(id, charge)
219
220 /**
221 * Returns whether a player has night vision.
222 *
223 * @param id Player index.
224 * @return True if it has, false otherwise.
225 */
226 native zp_get_user_nightvision(id)
227
228 /**
229 * Sets whether a player has night vision.
230 *
231 * @param id Player index.
232 * @param set True to give, false for removing it.
233 */
234 native zp_set_user_nightvision(id, set)
235
236 /**
237 * Forces a player to become a zombie.
238 *
239 * Note: Unavailable for last human/survivor/sniper.
240 *
241 * @param id Player index to be infected.
242 * @param infector Player index who infected him (optional).
243 * @param silent If set, there will be no HUD messages or infection sounds.
244 * @param rewards Whether to show DeathMsg and reward frags, hp, and ammo packs to infector.
245 * @return True on success, false otherwise.
246 */
247 native zp_infect_user(id, infector = 0, silent = 0, rewards = 0)
248
249 /**
250 * Forces a player to become a human.
251 *
252 * Note: Unavailable for last zombie/nemesis.
253 *
254 * @param id Player index to be cured.
255 * @param silent If set, there will be no HUD messages or antidote sounds.
256 * @return True on success, false otherwise.
257 */
258 native zp_disinfect_user(id, silent = 0)
259
260 /**
261 * Forces a player to become a nemesis.
262 *
263 * Note: Unavailable for last human/survivor/sniper.
264 *
265 * @param id Player index to turn into nemesis.
266 * @return True on success, false otherwise.
267 */
268 native zp_make_user_nemesis(id)
269
270 /**
271 * Forces a player to become a survivor.
272 *
273 * Note: Unavailable for last zombie/nemesis.
274 *
275 * @param id Player index to turn into survivor.
276 * @return True on success, false otherwise.
277 */
278 native zp_make_user_survivor(id)
279
280 /**
281 * Respawns a player into a specific team.
282 *
283 * @param id Player index to be respawned.
284 * @param team Team to respawn the player into (ZP_TEAM_ZOMBIE or ZP_TEAM_HUMAN).
285 * @return True on success, false otherwise.
286 */
287 native zp_respawn_user(id, team)
288
289 /**
290 * Forces a player to buy an extra item.
291 *
292 * @param id Player index.
293 * @param itemid A valid extra item ID.
294 * @param ignorecost If set, item's cost won't be deduced from player.
295 * @return True on success, false otherwise.
296 */
297 native zp_force_buy_extra_item(id, itemid, ignorecost = 0)
298
299 /**
300 * Returns whether a player is a sniper.
301 *
302 * @param id Player index.
303 * @return True if it is, false otherwise.
304 */
305 native zp_get_user_sniper(id)
306
307 /**
308 * Forces a player to become a sniper.
309 *
310 * Note: Unavailable for last zombie/nemesis/assassin.
311 *
312 * @param id Player index to turn into sniper.
313 * @return True on success, false otherwise.
314 */
315 native zp_make_user_sniper(id)
316
317 /**
318 * Returns whether a player is an assassin.
319 *
320 * @param id Player index.
321 * @return True if it is, false otherwise.
322 */
323 native zp_get_user_assassin(id)
324
325 /**
326 * Forces a player to become a assassin.
327 *
328 * Note: Unavailable for last human/survivor/sniper.
329 *
330 * @param id Player index to turn into assassin.
331 * @return True on success, false otherwise.
332 */
333 native zp_make_user_assassin(id)
334
335 /**
336 * Returns whether the ZP round has started, i.e. first zombie
337 * has been chosen or a game mode has begun.
338 *
339 * @return 0 - Round not started
340 * 1 - Round started
341 * 2 - Round starting
342 */
343 native zp_has_round_started()
344
345 /**
346 * Returns whether the current round is a nemesis round.
347 *
348 * @return True if it is, false otherwise.
349 */
350 native zp_is_nemesis_round()
351
352 /**
353 * Returns whether the current round is a survivor round.
354 *
355 * @return True if it is, false otherwise.
356 */
357 native zp_is_survivor_round()
358
359 /**
360 * Returns whether the current round is a swarm round.
361 *
362 * @return True if it is, false otherwise.
363 */
364 native zp_is_swarm_round()
365
366 /**
367 * Returns whether the current round is a plague round.
368 *
369 * @return True if it is, false otherwise.
370 */
371 native zp_is_plague_round()
372
373 /**
374 * Returns whether the current round is a Armageddon round.
375 *
376 * @return True if it is, false otherwise.
377 */
378 native zp_is_lnj_round()
379
380 /**
381 * Returns number of alive zombies.
382 *
383 * @return Zombie count.
384 */
385 native zp_get_zombie_count()
386
387 /**
388 * Returns number of alive humans.
389 *
390 * @return Human count.
391 */
392 native zp_get_human_count()
393
394 /**
395 * Returns number of alive nemesis.
396 *
397 * @return Nemesis count.
398 */
399 native zp_get_nemesis_count()
400
401 /**
402 * Returns number of alive survivors.
403 *
404 * @return Survivor count.
405 */
406 native zp_get_survivor_count()
407
408 /**
409 * Returns whether the current round is a sniper round.
410 *
411 * @return True if it is, false otherwise.
412 */
413 native zp_is_sniper_round()
414
415 /**
416 * Returns whether the current round is a assassin round.
417 *
418 * @return True if it is, false otherwise.
419 */
420 native zp_is_assassin_round()
421
422 /**
423 * Returns number of alive snipers.
424 *
425 * @return Sniper count.
426 */
427 native zp_get_sniper_count()
428
429 /**
430 * Returns number of alive assassins.
431 *
432 * @return Assassin count.
433 */
434 native zp_get_assassin_count()
435
436 /**
437 * Returns the current game mode ID
438 *
439 * Note: For default game modes you can use, for eg. MODE_SWARM,
440 * to check if the current round is swarm mode.
441 *
442 * Note: For custom game modes you must have the custom game
443 * mode ID to detect it
444 *
445 * @return Current game mode ID
446 */
447 native zp_get_current_mode()
448
449 /**
450 * Allows you to properly retrieve a player's model
451 *
452 * Note: You should use this native for retrieving a player's
453 * current model instead of other methods
454 *
455 * Note: The model name which is retrieved is the model's folder
456 * name for eg: zombie_source and is not the model's actual name.
457 *
458 * @param id Player index who's model is to be retrieved.
459 * @param model String in which the model name will be copied.
460 * @param maxlen Number of characters (of the string) to copy.
461 */
462 native zp_get_user_model(id, const model[], maxlen)
463
464 /**
465 * Properly sets the given model for the player.
466 *
467 * Note: You should use this native for setting a player's model
468 * instead of other methods.
469 *
470 * Note: The model name which is passed should be the model's folder
471 * name for eg: zombie_source and the folder should contain the
472 * actual model file in it eg: zombie_source.mdl
473 *
474 * Note: The model you are setting should be precached in the
475 * sub-plugin using the plugin_precache forward to prevent problems.
476 *
477 * Note: It is highly advised to set the models with an additional
478 * delay during round start to prevent SVC_BAD errors/kicks.
479 *
480 * @param id Player index who's model needs to be set.
481 * @param model String containing the model folder name.
482 */
483 native zp_set_user_model(id, const model[])
484
485 /**
486 * Returns an extra item's ID.
487 *
488 * @param name Item name to look for.
489 * @return Internal extra item ID, or -1 if not found.
490 */
491 native zp_get_extra_item_id(const name[])
492
493 /**
494 * Returns a zombie class' ID.
495 *
496 * @param name Class name to look for.
497 * @return Internal zombie class ID, or -1 if not found.
498 */
499 native zp_get_zombie_class_id(const name[])
500
501 /**
502 * Registers a custom game mode which will be added to the admin menu of ZP
503 *
504 * Note: The returned game mode ID can later be used to detect the game mode
505 * which is called in zp_round_started_pre. There you can start the game mode
506 * externally by using this game mode ID.
507 *
508 * @param name The game mode's name which will help in identifing it.
509 * @param flags Access flags required by the admins to start this game mode.
510 * @param chance Chance level of this game mode. (1 in X).
511 * @param allow Whether to permit infection after zombie to player attacks.
512 * @param dm_mode Death match mode which will be used during this game.
513 * @return An internal game mode ID or -1 on failure.
514 */
515 native zp_register_game_mode( const name[], flags, chance, allow, dm_mode)
516
517 /**
518 * Registers a custom item which will be added to the extra items menu of ZP.
519 *
520 * Note: The returned extra item ID can be later used to catch item
521 * purchase events for the zp_extra_item_selected() forward.
522 *
523 * Note: ZP_TEAM_NEMESIS, ZP_TEAM_SURVIVOR, ZP_TEAM_ASSASSIN and ZP_TEAM_SNIPER
524 * can be used to make an item available to Nemesis,
525 * Survivors, Assassins and Snipers.
526 *
527 * @param name Caption to display on the menu.
528 * @param cost Ammo packs to be deducted on purchase.
529 * @param teams Bitsum of teams it should be available for.
530 * @return An internal extra item ID, or -1 on failure.
531 */
532 native zp_register_extra_item(const name[], cost, teams)
533
534 /**
535 * Registers a custom class which will be added to the zombie classes menu of ZP.
536 *
537 * Note: The returned zombie class ID can be later used to identify
538 * the class when calling the zp_get_user_zombie_class() natives.
539 *
540 * @param name Caption to display on the menu.
541 * @param info Brief description of the class.
542 * @param model Player model to be used.
543 * @param clawmodel Claws model to be used.
544 * @param hp Initial health points.
545 * @param speed Maximum speed.
546 * @param gravity Gravity multiplier.
547 * @param knockback Knockback multiplier.
548 * @return An internal zombie class ID, or -1 on failure.
549 */
550 native zp_register_zombie_class(const name[], const info[], const model[], const clawmodel[], hp, speed, Float:gravity, Float:knockback)
551
552 /**
553 * Called when the ZP round starts, i.e. first zombie
554 * is chosen or a game mode begins.
555 *
556 * @param gamemode Mode which has started.
557 * @param id Affected player's index (if applicable).
558 */
559 forward zp_round_started(gamemode, id)
560
561 /**
562 * Called before the ZP round starts. This is only
563 * called for custom game modes.
564 *
565 * Note: The custom game mode id can be used to start
566 * the game mode externally
567 *
568 * Note: returning ZP_PLUGIN_HANDLED will cause the
569 * game mode to be blocked and other game modes will
570 * be given a chance.
571 *
572 * @param gameid Custom mode id which is called
573 */
574 forward zp_round_started_pre(gameid)
575
576 /**
577 * Called when the round ends.
578 *
579 * @param winteam Team which has won the round.
580 */
581 forward zp_round_ended(winteam)
582
583 /**
584 * Called when a player gets infected.
585 *
586 * @param id Player index who was infected.
587 * @param infector Player index who infected him (if applicable).
588 * @param nemesis Whether the player was turned into a nemesis.
589 */
590 forward zp_user_infected_pre(id, infector, nemesis)
591 forward zp_user_infected_post(id, infector, nemesis)
592
593 /**
594 * Called when a player turns back to human.
595 *
596 * @param id Player index who was cured.
597 * @param survivor Whether the player was turned into a survivor.
598 */
599 forward zp_user_humanized_pre(id, survivor)
600 forward zp_user_humanized_post(id, survivor)
601 forward zp_user_humanized_pre(id, sniper)
602 forward zp_user_humanized_post(id, sniper)
603
604 /**
605 * Called on a player infect/cure attempt. You can use this to block
606 * an infection/humanization by returning ZP_PLUGIN_HANDLED in your plugin.
607 *
608 * Note: Right now this is only available after the ZP round starts, since some
609 * situations (like blocking a first zombie's infection) are not yet handled.
610 */
611 forward zp_user_infect_attempt(id, infector, nemesis)
612 forward zp_user_humanize_attempt(id, survivor)
613 forward zp_user_humanize_attempt(id, sniper)
614
615 /**
616 * Called when an admin selects a custom game mode from the ZP admin menu.
617 *
618 * Note: You should trigger the custom game mode here with out any checks
619 *
620 * @param gameid Internal custom game mode ID
621 * @param id Player index who selected the game mode
622 */
623 forward zp_game_mode_selected(gameid, id)
624
625 /**
626 * Called when a player buys an extra item from the ZP menu.
627 *
628 * Note: You can now return ZP_PLUGIN_HANDLED in your plugin to block
629 * the purchase and the player will be automatically refunded.
630 *
631 * @param id Player index of purchaser.
632 * @param itemid Internal extra item ID.
633 */
634 forward zp_extra_item_selected(id, itemid)
635
636 /**
637 * Called when a player gets unfrozen (frostnades).
638 *
639 * @param id Player index.
640 */
641 forward zp_user_unfrozen(id)
642
643 /**
644 * Called when a player becomes the last zombie.
645 *
646 * Note: This is called for the first zombie too.
647 *
648 * @param id Player index.
649 */
650 forward zp_user_last_zombie(id)
651
652 /**
653 * Called when a player becomes the last human.
654 *
655 * @param id Player index.
656 */
657 forward zp_user_last_human(id)
658
659 /**
660 * Called when a player spawns. This is also called for CZ bots
661 * which are spawning.
662 *
663 * Note: You should use this, instead of other spawn forwards,
664 * for changing a player's class after the player's spawn.
665 *
666 * @param id Player index who has spawned
667 */
668 forward zp_player_spawn_post(id, resp_zombie)
669
670 /**
671 * @deprecated - Do not use!
672 * For backwards compatibility only.
673 */
674 #define ZP_TEAM_ANY 0
675