Code:
#include <amxmodx>
#include <fun>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <zombie_plague_special>
#define PLUGIN "[ZP] Extra Item: Golden AK e M4"
#define VERSION "1.0"
#define AUTHOR "Wilian M."
#define PREFIXCHAT "!g[CS Revo!]"
#define xValidPlayer(%1) (1 <= %1 <= xMaxPlayers)
new xGAk47_V[64] = "models/csr/itens/v_gak47.mdl"
new xGAk47_P[64] = "models/csr/itens/p_gak47.mdl"
new xGM4A1_V[64] = "models/csr/itens/v_gm4a1.mdl"
new xGM4A1_P[64] = "models/csr/itens/p_gm4a1.mdl"
new xCvars[2], xHasGolden[33][2], xBullets[33], xItemIdAk, xItemIdM4, xMaxPlayers, xSprDot
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("HLTV", "xNewRound", "a", "1=0", "2=0")
register_event("CurWeapon", "xCurWeapon", "be", "1=1", "3>0")
RegisterHam(Ham_TakeDamage, "player", "xHamTakeDamagePre")
xItemIdAk = zp_register_extra_item("Golden AK47", 25, ZP_TEAM_HUMAN)
xItemIdM4 = zp_register_extra_item("Golden M4A1", 20, ZP_TEAM_HUMAN)
xCvars[0] = register_cvar("zp_gak47_dmg_multiplier", "2.5")
xCvars[1] = register_cvar("zp_gm4a1_dmg_multiplier", "2.0")
xMaxPlayers = get_maxplayers()
}
public xNewRound()
{
new i
for(i = 1; i < xMaxPlayers; i++)
{
xHasGolden[i][0] = false
xHasGolden[i][1] = false
}
}
public client_disconnected(id)
{
xHasGolden[id][0] = false
xHasGolden[id][1] = false
xBullets[id] = false
}
public zp_user_humanized_post(id, classid)
{
xHasGolden[id][0] = false
xHasGolden[id][1] = false
}
public zp_user_infected_post(id, infector, classid)
{
xHasGolden[id][0] = false
xHasGolden[id][1] = false
}
public plugin_precache()
{
precache_model(xGAk47_V)
precache_model(xGAk47_P)
precache_model(xGM4A1_V)
precache_model(xGM4A1_P)
xSprDot = precache_model("sprites/dot.spr")
}
public zp_extra_item_selected(id, itemid)
{
if(itemid == xItemIdAk)
{
if(xValidPlayer(id))
{
give_item(id, "weapon_ak47")
cs_set_user_bpammo(id, CSW_AK47, 90)
xClientPrintColor(id, "%s !yVocê comprou uma !tGolden AK-47!y.", PREFIXCHAT)
client_cmd(id, "spk items/ammopickup1")
xHasGolden[id][0] = true
}
}
if(itemid == xItemIdM4)
{
if(xValidPlayer(id))
{
give_item(id, "weapon_m4a1")
cs_set_user_bpammo(id, CSW_M4A1, 90)
xClientPrintColor(id, "%s !yVocê comprou uma !tGolden M4A1!y.", PREFIXCHAT)
client_cmd(id, "spk items/ammopickup1")
xHasGolden[id][1] = true
}
}
}
public zp_extra_item_selected_pre(id, itemid)
{
if(itemid == xItemIdAk)
{
static text[32]
if(zp_get_zombie_count() < 4)
{
formatex(text, charsmax (text) , "[Min: 4 Zombies!]")
zp_extra_item_textadd(text)
return ZP_PLUGIN_HANDLED
}
if(xHasGolden[id][0])
{
formatex(text, charsmax (text) , "[Você já possui este item!]")
zp_extra_item_textadd(text)
return ZP_PLUGIN_HANDLED
}
}
if(itemid == xItemIdM4)
{
static text[32]
if(zp_get_zombie_count() < 4)
{
formatex(text, charsmax (text) , "[Min: 4 Zombies!]")
zp_extra_item_textadd(text)
return ZP_PLUGIN_HANDLED
}
if(xHasGolden[id][1])
{
formatex(text, charsmax (text) , "[Você já possui este item!]")
zp_extra_item_textadd(text)
return ZP_PLUGIN_HANDLED
}
}
return PLUGIN_CONTINUE
}
public xHamTakeDamagePre(victim, inflictor, attacker, Float:damage)
{
if(xValidPlayer(attacker))
{
if(get_user_weapon(attacker) == CSW_M4A1 && xHasGolden[attacker][1])
SetHamParamFloat(4, damage * get_pcvar_float(xCvars[1]))
if(get_user_weapon(attacker) == CSW_AK47 && xHasGolden[attacker][0])
SetHamParamFloat(4, damage * get_pcvar_float(xCvars[0]))
}
}
public xCurWeapon(id)
{
new xWpnId, clip, ammo
xWpnId = get_user_weapon(id, clip, ammo)
if(xWpnId == CSW_AK47 && xHasGolden[id][0])
{
set_pev(id, pev_viewmodel2, xGAk47_V)
set_pev(id, pev_weaponmodel2, xGAk47_P)
}
if(xWpnId == CSW_M4A1 && xHasGolden[id][1])
{
set_pev(id, pev_viewmodel2, xGM4A1_V)
set_pev(id, pev_weaponmodel2, xGM4A1_P)
}
if((xBullets[id] > clip) && (xWpnId == CSW_M4A1 && xHasGolden[id][1]) || (xWpnId == CSW_AK47 && xHasGolden[id][0]))
{
new vec1[3], vec2[3]
get_user_origin(id, vec1, 1)
get_user_origin(id, vec2, 4)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(0)
write_coord(vec1[0])
write_coord(vec1[1])
write_coord(vec1[2])
write_coord(vec2[0])
write_coord(vec2[1])
write_coord(vec2[2])
write_short(xSprDot)
write_byte(1)
write_byte(5)
write_byte(2)
write_byte(5) // def 10
write_byte(0)
write_byte(255)
write_byte(215)
write_byte(0)
write_byte(200)
write_byte(100) // def 150
message_end()
}
xBullets[id] = clip
}
stock xClientPrintColor(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, "!g", "^4")
replace_all(msg, 190, "!y", "^1")
replace_all(msg, 190, "!t", "^3")
replace_all(msg, 190, "!t2", "^0")
if (id) players[0] = id; else get_players(players, count, "ch")
new i
for(i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
write_byte(players[i])
write_string(msg)
message_end()
}
}
}