30.01.2015, 13:44
how to create command like /giveallweapon
CMD:giveallweapon(playerid,params[]) {
if(pInfo[playerid][pLevel] >= 4) {
new Weap, ammo, weaponname[50] , string[128];
if(sscanf(params,"ii",Weap, ammo)) return SendClientMessage(playerid,red,"Usage: /giveallweapon [weapon name] [ammo]");
if(Weap == 38 || Weap == 36) return SendClientMessage(playerid,red,"You are not allowed to give these weapons");
for(new i = 0; i < MAX_PLAYERS; i++) {
if(IsPlayerConnected(i))
{
GivePlayerWeapon(i,Weap,ammo) && PlayerPlaySound(i, 1057,0.0,0.0,0.0);
}
}
GetWeaponName(Weap, weaponname, sizeof(weaponname));
format(string,sizeof(string),"Administrator %s has given all players weapon %s (%d) with %d round of ammo.",GetName(playerid),weaponname,Weap,ammo);
SendClientMessageToAll(blue,string);
}
else SendClientMessage(playerid,red,"You are not a high enough level to use this command");
return 1;
}
CMD:giveallweapon(playerid, params[])
{
new Weapon, Ammo, string[144], name[MAX_PLAYER_NAME], WeaponName[30];
GetPlayerName(playerid, name, sizeof(name));
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}You aren't authorized to use this command.");
if(sscanf(params, "ii", Weapon, Ammo)) return SendClientMessage(playerid, -1, "{FF0000}USAGE: {FFFFFF}/GiveAllWeapon [Weapon ID] [Ammo]");
if(Weapon > 46) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}Invalid Weapon. [1-46]");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
GivePlayerWeapon(i, Weapon, Ammo);
}
}
GetWeaponName(Weapon, WeaponName, sizeof(WeaponName));
format(string, sizeof(string), "{FF0000}[WEAPONS]: {FFFFFF}Administrator {FF0000}%s {FFFFFF}has gave to all players a {FF0000}%s (%i) with %i ammo.", name, WeaponName, Weapon, Ammo);
SendClientMessageToAll(-1, string);
return 1;
}
CMD:giveallweapon(playerid, params[])
{
new weapon, ammo;
if(sscanf(params, "ii", weapon, ammo)) return SendClientMessage(playerid, -1, "USAGE: /giveallweapon [weapon id] [ammo]");
foreach(Player, i)
{
GivePlayerWeapon(i, weapon, ammo);
}
return 1;
}
You can't just give a script like that Humza, pInfo[playerid][pLevel] will have to be changed, SendClientMessageToAll(blue,string); will have to be changed and such.
This is a very simple command made with foreach and zcmd. pawn Код:
Use IsPlayerAdmin to check if player is RCON admin, and you can limit it to RCON admins only. |