Help command
#1

how to create command like /giveallweapon
Reply
#2

PHP код:
CMD:giveallweapon(playerid,params[]) {
    if(
pInfo[playerid][pLevel] >= 4) {
    new 
Weapammoweaponname[50] , string[128];
        if(
sscanf(params,"ii",Weapammo)) 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 
0MAX_PLAYERSi++) {
        if(
IsPlayerConnected(i))
        {
            
GivePlayerWeapon(i,Weap,ammo) && PlayerPlaySound(i1057,0.0,0.0,0.0);
        }
        }
        
GetWeaponName(Weapweaponnamesizeof(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;

Try this maybe it work
Reply
#3

pawn Код:
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;
}
Reply
#4

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 Код:
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;
}
It's very simple.
Use IsPlayerAdmin to check if player is RCON admin, and you can limit it to RCON admins only.
Reply
#5

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
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 Код:
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;
}
It's very simple.
Use IsPlayerAdmin to check if player is RCON admin, and you can limit it to RCON admins only.

Really Appreciate +rep for telling my mistake and helping me to make my self good in forum.samp <3

Btw i already help him and i know he is using pInfo[playerid][pLevel] but once again thanks
Reply
#6

thanks
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)