Código PHP:
/*============================================================
Donar!
============================================================*/
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,"/donar", 7))
donar(id, arg2)
}
public donar(id, arg[])
{
new to[32], count[10]
strbreak(arg, to, 31, count, 9)
if (!to[0] || !count[0])
{
ChatColor(id, "!g[DONAR] !yTo donate ammo packs write in chat:/g /donate <nickname> <amount>")
return
}
new g_jbpacks_sender = g_jbpacks(id) [b]<------------------ ACA SERIA EL ERROR[/b]
if (equal(count, "all"))
g_jbpacks = g_jbpacks_sender
else
g_jbpacks = str_to_num(count)
if (g_jbpacks <= 0)
{
ChatColor(id, "!g[DONAR] !yInvalid amount !")
return
}
g_jbpacks_sender -= g_jbpacks
if (g_jbpacks_sender < 0)
{
g_jbpacks+=g_jbpacks_sender
g_jbpacks_sender = 0
}
new reciever = cmd_target(id, to, (CMDTARGET_OBEY_IMMUNITY|CMDTARGET_ALLOW_SELF))
if (!reciever || reciever == id)
{
ChatColor(id, "!g[DONAR] !yClient with that username is not found")
return
}
g_jbpacks(reciever, g_jbpacks(reciever) + g_jbpacks)
g_jbpacks(id, g_jbpacks_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 Dono %d JBPacks To %s", aName, g_jbpacks, vName)
set_hudmessage(255, 10, 10, -1.0, 0.3, 1, 6.0, 6.0)
show_hudmessage(reciever, "%s Donated %d Ammo Packs To %s", aName, g_jbpacks, vName)
}