CMD:giveallweapons(playerid, params[]) { new weaponid,model[50],ammo; if(pInfo[playerid][Admin]<4) return SendClientMessage(playerid, RED, "ERROR: You are not authorized to use this command"); if(sscanf(params, "si", model, ammo)) return SendClientMessage(playerid, RED, "ERROR: /giveallweapon [weaponid] [ammo]"); weaponid = GetWeaponNameID(model); if(weaponid > 47 || weaponid < 1) return SendClientMessage (playerid, RED, "ERROR: Invailed weapon name"); foreach(Player,i) { GivePlayerWeapon(i, weaponid, ammo); PlayerPlaySound(i, 1057,0.0,0.0,0.0); } format(str, SOS, "Administrator %s has given all players weapon [%s] with [%i] ammo ", pInfo[playerid][Name], weaponid, ammo); SendClientMessageToAll(BLUE, str); format(str, SOS, "Admin: %s has used command GIVEALLWEAPONS", pInfo[playerid][Name]); SendCMDAdmin(BLUE, str); return 1; } |
stock GetWeaponNameID(wname[]) { for(new i = 0; i < 42; i++) { if (strfind(WeaponNames[i], wname, true) != -1) return i+4; } return -1; } |
new GunName[47][20] =
{
"Fist","Brass Knuckles","Golf Club","Nightstick","Knife","Basebal Bat","Shovel","Pool Cue","Katana","Chainsaw","Double-ended Dildo","Dildo","Vibrator",
"Silver Vibrator","Flowers","Cane","Grenade","Tear Gas","Molotv Cocktail","?","?","?","9mm","Silenced 9mm","Desert Eagle","Shotgun","Sawnoff-Shotgun",
"Combat Shotgun","Micro-SMG","MP5","Ak-47","M4","Tec9","Country Rifle","Sniper Rifle","RPG","HS-RPG","Flame-Thrower","Minigun","Satchel Charge","Detonator",
"Spray Can","Fire Extinguisher","Camera","Night Goggles","Thermal Goggles","Parachute"
};
// Example of use:
CMD:mygun(playerid)
{
new text[48];
format(text,sizeof text,"You've got a nice: {FFFFFF}%s",GunName[GetPlayerWeapon(playerid)]);
SendClientMessage(playerid,0xFFDD22FF,text);
return 1;
}
CMD:giveallweapons(playerid, params[])
{
new weaponid,model[50],ammo;
if(pInfo[playerid][Admin]<4) return SendClientMessage(playerid, RED, "ERROR: You are not authorized to use this command");
if(sscanf(params, "si", model, ammo)) return SendClientMessage(playerid, RED, "ERROR: /giveallweapon [weaponid] [ammo]");
weaponid = GetWeaponNameID(model);
if(weaponid > 47 || weaponid < 1) return SendClientMessage (playerid, RED, "ERROR: Invailed weapon name");
foreach(Player,i)
{
GivePlayerWeapon(i, weaponid, ammo);
PlayerPlaySound(i, 1057,0.0,0.0,0.0);
}
format(str, SOS, "Administrator %s has given all players weapon [%s] with [%i] ammo ", pInfo[playerid][Name], GunName[weaponid], ammo);
SendClientMessageToAll(BLUE, str);
format(str, SOS, "Admin: %s has used command GIVEALLWEAPONS", pInfo[playerid][Name]);
SendCMDAdmin(BLUE, str);
return 1;
}
SSCANF:weapon(string[])
{
...
}
new weaponid, ammo;
if (sscanf(params, "k<weapon>i", weaponid, ammo)) return ... // send usage
if (weaponid == -1) return ... // invalid weapon name/ID