/giveallweapon
#1

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..
Reply
#2

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.
Reply
#3

Compiles fine. I'll test tomorrow.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)