So This Plugin Works ?
Code:
#include <amxmodx>
#include <fakemeta_util>
#include <zombieplague>
new g_item_name[] = { "Shield" }
new g_itemid_shield
new bool:g_hasShield[33]
#define COST 5
public plugin_init()
{
register_plugin("[ZP] Extra Item: Buy Shield", "1.1", "Johnny")
g_itemid_shield = zp_register_extra_item(g_item_name, COST, ZP_TEAM_HUMAN)
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
}
public client_connect(id)
{
g_hasShield[id] = false
}
public client_disconnect(id)
{
g_hasShield[id] = false
}
public event_round_start()
{
for (new i = 1; i <= 32; i++)
g_hasShield[i] = false
}
public zp_extra_item_selected(player, itemid)
{
if ( itemid == g_itemid_shield )
{
if ( g_hasShield[player] == true )
{
new ammo_packs = zp_get_user_ammo_packs(player)
zp_set_user_ammo_packs(player, ammo_packs + COST)
zp_colored_print(player, "^x04[ZP]^x01 You already have a Shield")
}
else
{
g_hasShield[player] = true
fm_give_item(player, "weapon_shield")
zp_colored_print(player, "^x04[ZP]^x01 You now have a Shield")
}
}
}
// Colored Print (zp_colored_print)
stock zp_colored_print(target, const message[], any:...)
{
static g_msgSayText, maxplayers;
if ( !g_msgSayText )
g_msgSayText = get_user_msgid("SayText")
if ( !maxplayers )
maxplayers = get_maxplayers();
static buffer[512], i, argscount;
argscount = numargs();
// Send to everyone
if (!target)
{
static player;
for (player = 1; player <= 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, sizeof buffer - 1, 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, sizeof buffer - 1, message, 3);
// Send it
message_begin(MSG_ONE, g_msgSayText, _, target);
write_byte(target);
write_string(buffer);
message_end();
}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang3082\\ f0\\ fs16 \n\\ par }
*/
I Cant Test It Myself - Server Is Down For A Week...