/************************************************\
==================================
* || [ZP] Donate Plugin v1.0|| *
==================================
*by @bdul!*
-------------------
*||DESCRIPTION||*
-------------------
With this plugin u can donate ammo packs
to others. Usage say:
/donate <nickname> <amount>
\************************************************/
#include <amxmodx>
#include <amxmisc>
#include <zombieplague>
new const PLUGIN[] = "[ZP] Donate Plugin"
new const AUTHOR[] = "@bdul!"
new const VERSION[] = "1.0"
new g_msgSayText
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say", "handleSay")
register_clcmd("say_team", "handleSay")
g_msgSayText = get_user_msgid("SayText")
}
public handleSay(id)
{
new args[64]
read_args(args, charsmax(args))
remove_quotes(args)
new arg1[16]
new arg2[32]
strbreak(args, arg1, charsmax(arg1), arg2, charsmax(arg2))
if (equal(arg1,"/kuldes", 7))
donate(id, arg2)
}
public donate(id, arg[])
{
new to[32], count[10]
strbreak(arg, to, 31, count, 9)
if (!to[0] || !count[0])
{
client_printcolor(0, "/g[ZP KULDES] /yLoszer csomag kuldesehez ird chatbe:/g /kuldes <NEV> <LOSZERCSOMAG>")
return
}
new ammo_sender = zp_get_user_ammo_packs(id)
new ammo
if (equal(count, "all"))
ammo = ammo_sender
else
ammo = str_to_num(count)
if (ammo <= 0)
{
client_printcolor(id, "/g[ZP Donate] /yValami hibas,nez meg ujra mennyit akarsz kuldeni,meg hogy van e annyid! !")
return
}
ammo_sender -= ammo
if (ammo_sender < 0)
{
ammo+=ammo_sender
ammo_sender = 0
}
new reciever = cmd_target(id, to, (CMDTARGET_OBEY_IMMUNITY|CMDTARGET_ALLOW_SELF))
if (!reciever || reciever == id)
{
client_printcolor(id, "/g[ZP Donate] /yNincs ilyen nev . ! Valamit elge'pelte'l")
return
}
zp_set_user_ammo_packs(reciever, zp_get_user_ammo_packs(reciever) + ammo)
zp_set_user_ammo_packs(id, ammo_sender)
new aName[32], vName[32]
get_user_name(id, aName, 31)
get_user_name(reciever, vName, 31)
set_hudmessage(255, 10, 10, -1.0, 0.3, 1, 6.0, 6.0)
show_hudmessage(id, "%s Kuldott %d Loszercsomagot neki %s", aName, ammo, vName)
set_hudmessage(255, 10, 10, -1.0, 0.3, 1, 6.0, 6.0)
show_hudmessage(reciever, "%s Kuldott %d Loszercsomagot neki %s", aName, ammo, vName)
}
stock client_printcolor(id, const input[], any:...)
{
new iCount = 1, iPlayers[32]
static szMsg[191]
vformat(szMsg, charsmax(szMsg), input, 3)
replace_all(szMsg, 190, "/g", "^4") // green txt
replace_all(szMsg, 190, "/y", "^1") // orange txt
replace_all(szMsg, 190, "/ctr", "^3") // team txt
replace_all(szMsg, 190, "/w", "^0") // team txt
if(id) iPlayers[0] = id
else get_players(iPlayers, iCount, "ch")
for (new i = 0; i < iCount; i++)
{
if (is_user_connected(iPlayers[i]))
{
message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, iPlayers[i])
write_byte(iPlayers[i])
write_string(szMsg)
message_end()
}
}
}