PHP Code:
/*================================================================================
------------------------------------
-*- [ZP] Extra Item: Buy Classes -*-
------------------------------------
~~~~~~~~~~~~~~~
- Description -
~~~~~~~~~~~~~~~
This Zombie Plague extension gives the players the possibility
to buy one of the special characters from the mod.
They will become the class chosen.
The classes can be bought only before a round mode starts.
Another simple, but useful plug-in by 93()|29!/<.
Enjoy it and have fun!
Official forum thread: http://forums.alliedmods.net/showthread.php?p=1228682
~~~~~~~~~~~
- Credits -
~~~~~~~~~~~
MeRcyLeZZ - For such an awesome mod like Zombie Plague
Let's hope he will update it soon...
Hezerf - For helping me correct a mistake
I probably would of never seen...
~~~~~~~~~
- Cvars -
~~~~~~~~~
1. zp_buy_classes_delay 15 // Delay (in rounds) before the items will
be buyable again after being selected
~~~~~~~~~~~~~
- Changelog -
~~~~~~~~~~~~~
* v1.0 (25 Jun 2010) [Private]
- First release
* v1.1 (1 Jul 2010) [Released to public]
- Added round buying delay
- Fixed printing messages when
selecting other extra items
- Fixed delay & added cvar for it
~~~~~~~~~~~~~~
- To do list -
~~~~~~~~~~~~~~
* Make it multi-lingual
* Make separate delay for each class
* Make the classes appear in the extra
items menu only before round mode start
* Make an auto-exec cfg file containing all the cvars
~~~~~~~~~
- Notes -
~~~~~~~~~
Plug-in can be seen on my server: Zm.LcSNeT.Ro (93.187.143.167:27015)
Also if you want check out and join my Steam group: Lost World Zombie Hunters
(http://steamcommunity.com/groups/lwzh)
================================================================================*/
#include <amxmodx>
#include <zombie_plague_advance>
new g_item_nemesis, g_item_survivor, g_item_assassin, g_item_sniper, g_maxplayers, g_msgSayText
new const g_item_nem_name[] = "Buy Nemesis"
const g_item_nem_cost = 35
new const g_item_surv_name[] = "Buy Survivor"
const g_item_surv_cost = 35
new const g_item_assassin_name[] = "Buy Assassin"
const g_item_assassin_cost = 57
new const g_item_sniper_name[] = "Buy Sniper"
const g_item_sniper_cost = 57
new g_buyable, g_endround, RoundCount, cvar_delay
public plugin_init()
{
register_plugin("[ZP] Extra Item: Buy Classes", "1.1", "93()|29!/<")
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
register_logevent("logevent_round_end", 2, "1=Round_End")
g_maxplayers = get_maxplayers()
g_msgSayText = get_user_msgid("SayText")
g_buyable = true
RoundCount = 0
}
public plugin_precache()
{
g_item_nemesis = zp_register_extra_item(g_item_nem_name, g_item_nem_cost, ZP_TEAM_HUMAN)
g_item_survivor = zp_register_extra_item(g_item_surv_name, g_item_surv_cost, ZP_TEAM_HUMAN)
g_item_assassin = zp_register_extra_item(g_item_assassin_name, g_item_assassin_cost, ZP_TEAM_HUMAN)
g_item_sniper = zp_register_extra_item(g_item_sniper_name, g_item_sniper_cost, ZP_TEAM_HUMAN)
cvar_delay = register_cvar("zp_buy_classes_delay", "2")
}
public zp_extra_item_selected(id, itemid)
{
if (itemid != g_item_nemesis && itemid != g_item_survivor && itemid != g_item_sniper)
return PLUGIN_CONTINUE;
if (!g_buyable)
{
if (RoundCount == get_pcvar_num(cvar_delay))
zp_colored_print(id, "^x04[ZP]^x01 You have to wait one more round before you can buy this item")
else
zp_colored_print(id, "^x04[ZP]^x01 You have to wait %d rounds until you can buy this item", get_pcvar_num(cvar_delay) - RoundCount + 1)
return ZP_PLUGIN_HANDLED;
}
if (zp_has_round_started() == 1 || g_endround)
{
zp_colored_print(id, "^x04[ZP]^x01 This item can only be bought before the round mode starts")
return ZP_PLUGIN_HANDLED;
}
new name[32]
get_user_name(id, name, 31)
if (itemid == g_item_nemesis)
{
zp_make_user_nemesis(id)
zp_colored_print(0, "^x04[ZP]^x03 %s^x01 has bought^x04 Nemesis", name)
}
else if (itemid == g_item_survivor)
{
zp_make_user_survivor(id)
zp_colored_print(0, "^x04[ZP]^x03 %s^x01 has bought^x04 Survivor", name)
}
else if (itemid == g_item_assassin)
{
zp_make_user_assassin(id)
zp_colored_print(0, "^x04[ZP]^x03 %s^x01 has bought^x04 Assassin", name)
}
else if (itemid == g_item_sniper)
{
zp_make_user_sniper(id)
zp_colored_print(0, "^x04[ZP]^x03 %s^x01 has bought^x04 Sniper", name)
}
g_buyable = false
return PLUGIN_CONTINUE;
}
public event_round_start()
g_endround = false
public logevent_round_end()
{
g_endround = true
if (g_buyable)
return;
if (RoundCount < get_pcvar_num(cvar_delay))
RoundCount++
else if (RoundCount >= get_pcvar_num(cvar_delay))
{
g_buyable = true
RoundCount = 0
}
}
// Colored chat print by MeRcyLeZZ
zp_colored_print(target, const message[], any:...)
{
static buffer[512], i, argscount
argscount = numargs()
// Send to everyone
if (!target)
{
static player
for (player = 1; player <= g_maxplayers; player++)
{
// Not connected
if (!is_user_connected(player))
continue;
// Remember changed arguments
static changed[5], changedcount // [5] = max LANG_PLAYER occurencies
changedcount = 0
// Replace LANG_PLAYER with player id
for (i = 2; i < argscount; i++)
{
if (getarg(i) == LANG_PLAYER)
{
setarg(i, 0, player)
changed[changedcount] = i
changedcount++
}
}
// Format message for player
vformat(buffer, charsmax(buffer), message, 3)
// Send it
message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, player)
write_byte(player)
write_string(buffer)
message_end()
// Replace back player id's with LANG_PLAYER
for (i = 0; i < changedcount; i++)
setarg(changed[i], 0, LANG_PLAYER)
}
}
// Send to specific target
else
{
// Format message for player
vformat(buffer, charsmax(buffer), message, 3)
// Send it
message_begin(MSG_ONE, g_msgSayText, _, target)
write_byte(target)
write_string(buffer)
message_end()
}
}