/giveallweapon
#1

Hi everyone, I'm having a little trouble with my /giveallweapon command.
When I give everyone a weapon (e.g a m4 or anything) it says 'Administrator "name" has given all players a M4 (31) with 0 rounds of ammo'

When I use /giveallweapon m4 100 it doesn't give the player the weapon with the selected ammo and it also says 'with 0 rounds of ammo'

Here is the command:

pawn Код:
CMD:giveallweapon(playerid,params[]) {
    if(PlayerInfo[playerid][Level] >= 6) {
        new tmp[128], tmp2[128], Index, ammo, weap, WeapName[32], string[128]; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
        if(isnull(tmp) ) return SendClientMessage(playerid, red, "USAGE: /giveallweapon [weapon id/weapon name] [ammo]");
        if(isnull(tmp2) || !IsNumeric(tmp2) || strval(tmp2) <= 0 || strval(tmp2) > 99999) ammo = 500;
        if(!IsNumeric(tmp)) weap = GetWeaponIDFromName(tmp); else weap = strval(tmp);
        if(!IsValidWeapon(weap)) return SendClientMessage(playerid,red,"ERROR: Invalid weapon ID");
        CMDMessageToAdmins(playerid,"GIVEALLWEAPON");
        for(new i = 0; i < MAX_PLAYERS; i++) {
            if(IsPlayerConnected(i)) {
                PlayerPlaySound(i,1057,0.0,0.0,0.0);
                GivePlayerWeapon(i,weap,ammo);
            }
        }
        GetWeaponName(weap, WeapName, sizeof(WeapName) );
        format(string,sizeof(string),"Administrator \"%s\" has given all players a %s (%d) with %d rounds of ammo", pName(playerid), WeapName, weap, ammo);
        return SendClientMessageToAll(blue, string);
    } else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
Thanks
Reply
#2

Use sscanf.

pawn Код:
if(sscanf(params, "dd", weaponid, ammo))
Reply
#3

Quote:
Originally Posted by Abagail
Посмотреть сообщение
Use sscanf.

pawn Код:
if(sscanf(params, "dd", weaponid, ammo))
No I don't want to..
Reply
#4

Add this to your command then before returning anything:

pawn Код:
printf("%d %d", weaponid, ammo);
If it isn't what you typed, the issue is strok.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)