/giveallweapon - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /giveallweapon (
/showthread.php?tid=236684)
/giveallweapon -
Snipa - 08.03.2011
pawn Код:
command(giveallweapon,playerid,params[])
{
if(PInfo[playerid][Level] >= 4 || IsPlayerAdmin(playerid)) {
new Weap, ammo, name[MAX_PLAYER_NAME], string[50];
if(sscanf(params,"ii",Weap, ammo)) return SendClientMessage(playerid,RED,"Usage: /giveallweapon [weapon name] [ammo]");
foreach(Player, i)
{
GivePlayerWeapon(i,Weap,ammo);
}
format(string,sizeof(string),"Administrator %s has given all players weapon: %d with %d ammo",name,Weap,ammo);
SendClientMessageToAll(blue,string);
}
else SendClientMessage(playerid,RED,"You are not a high enough level to use this command");
return 1;
}
This is what I have currently, BUT, I want the admin that uses it to instead of typing the weapon id, they can type the name. I know you use
pawn Код:
stock GetWeaponIDFromName(WeaponName[])
{
if(strfind("molotov",WeaponName,true)!=-1) return 18;
for(new i = 0; i <= 46; i++)
{
switch(i)
{
case 0,19,20,21,44,45: continue;
default:
{
new name[32]; GetWeaponName(i,name,32);
if(strfind(name,WeaponName,true) != -1) return i;
}
}
}
return -1;
}
but eh, dunno how to use it with my command..
Re: /giveallweapon -
[WF]Demon - 08.03.2011
pawn Код:
command(giveallweapon,playerid,params[])
{
if(PInfo[playerid][Level] >= 4 || IsPlayerAdmin(playerid)) {
new Weap[15], ammo, name[MAX_PLAYER_NAME], string[50];
if(sscanf(params,"si",Weap, ammo)) return SendClientMessage(playerid,RED,"Usage: /giveallweapon [weapon name] [ammo]");
foreach(Player, i)
{
GivePlayerWeapon(i,GetWeaponIDFromName(Weap),ammo);
}
format(string,sizeof(string),"Administrator %s has given all players weapon: %d with %d ammo",name,Weap,ammo);
SendClientMessageToAll(blue,string);
}
else SendClientMessage(playerid,RED,"You are not a high enough level to use this command");
return 1;
}
Try that.
Re: /giveallweapon -
Snipa - 08.03.2011
Compiles fine. I'll test tomorrow.