31.12.2013, 08:20
pawn Код:
CMD:givegun(playerid, params[])
{
new id, slot, wepid, ammo, wepname[128];
if(!CheckAdmin(playerid, ADMIN_LEVEL_5)) return NotAuthMSG(playerid);
if(sscanf(params,"uddd", id, slot, wepid, ammo)) return SyntaxMSG(playerid, "/givegun [playerid] [WepSlot (1-Melee,2-Primary,3-Secondary)] [WepID] [Ammo]");
if(!PlayerIsOn(id)) return NotConnectedMSG(playerid);
if(wepid >= 35 && wepid <= 40 || wepid >= 42 && wepid <= 46) return SendClientMessage(playerid, -1, "[ERROR]: You may not give him these weapons.");
if(slot == 1 && !IsMeleeWeapon(wepid)) return SendClientMessage(playerid, -1, "[ERROR]: Invalid melee weapon, (1-15).");
if(slot == 2 && !IsPrimaryWeapon(wepid)) return SendClientMessage(playerid, -1, "[ERROR]: Invalid primary weapon, (22-24).");
if(slot == 3 && !IsSecondaryWeapon(wepid)) return SendClientMessage(playerid, -1, "[ERROR]: Invalid secondary weapon, (25/28-32).");
GetWeaponName(wepid, wepname, sizeof(wepname));
if(slot == 1)
{
GiveMeleeWeapon(id, wepid);
}
else if(slot == 2)
{
GivePermWeapon(id, 2, wepid, ammo);
}
else if(slot == 3)
{
GivePermWeapon(id, 3, wepid, ammo);
}
format(msg, sizeof(msg), "[SERVER]: You've just gave %s a perm weapon, Weapon: %s, Ammo: %d. [He will now spawn with it].", GetName(id), wepname, ammo);
SendClientMessage(playerid, COLOR_LIGHTGREEN, msg);
format(msg, sizeof(msg), "[SERVER]: Admin %s gave you a perm weapon, Weapon: %s, Ammo: %d. [You will now spawn with it].", GetName(playerid), wepname, ammo);
SendClientMessage(id, COLOR_LIGHTGREEN, msg);
format(msg, sizeof(msg), "AdmCmd: %s has just given %s a perm weapon. (%s, Ammo: %d)", GetName(playerid), GetName(id), wepname, ammo);
AMSG(COLOR_LIGHTRED, msg);
return 1;
}