/split - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /split (
/showthread.php?tid=537552)
/split -
litmanen - 16.09.2014
Hey there, i'm willing to make a /split command to split ammo to other players, this is what i've did so far, but i', just not able to continue as i dont know what ill be doing, can anyone help me out?
Код:
CMD:split(playerid, params[])
{
new playerb, gunid, ammo, string[128];
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(sscanf(params, "uii", playerb, ammo))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /split [playerid] [ammo]");
return 1;
}
if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
GiveZaiatWeapon(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;
}
Re: /split -
SilentSoul - 16.09.2014
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;
}
Not tested yet. but i think it should work, also you used extra parameter in sscanf "ui
i".