16.09.2014, 13:01
pawn Код:
CMD:split(playerid, params[])
{
new playerb, ammo, string[128];
if(sscanf(params, "ui", playerb, ammo))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /split [playerid] [ammo]");
return 1;
}
if(playerb == playerid) return SendClientMesage(playerid,-1,"You can't split ammo to yourself.");
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
if(!IsPlayerConnected(playerb)) return SendClientMessage(playerid,-1,"This player is not connected.");
if(GetPlayerWeapon(playerid) == 0) return SendClientMessage(playerid,-1,"ERROR: You don't hold a weapon.");
if(GetPlayerWeapon(playerb) == 0) return SendClientMessage(playerid,-1,"ERROR: The other player not holding a weapon.");
if(GetPlayerAmmo(playerid) < ammo) return SendClientMessage(playerid,-1,"You don't have enough ammo.");
SetPlayerAmmo(playerid,GetPlayerWeapon(playerid),GetPlayerAmmo(playerid)-ammo);
SetPlayerAmmo(playerb,GetPlayerWeapon(playerb),GetPlayerAmmo(playerb)+ammo);
format(string, sizeof(string), " You have given %s %d ammo.", RPN(playerb), ammo);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " %s has given you %d ammo.", RPN(playerid), ammo);
SendClientMessage(playerb, COLOR_WHITE, string);
return 1;
}