gives wrong ammo
#1

gives the wrong ammo
I'm giving 50
0 gives
How to resolve




PHP код:
dcmd_giveallweapon(playerid,params[]) {
    if(
PlayerInfo[playerid][Level] >= 3) {
        new 
tmp[256], tmp2[256], IndexammoweapWeapName[32], string[128]; tmp strtok(params,Index), tmp2 strtok(params,Index);
        if(!
strlen(tmp) ) return SendClientMessage(playeridred"USAGE: /giveallweapon [weapon id/weapon name] [ammo]");
        if(!
strlen(tmp2) || !IsNumeric(tmp2) || strval(tmp2) <= || strval(tmp2) > 99999ammo 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 
0MAX_PLAYERSi++) {
            if(
IsPlayerConnected(i)) {
                
PlayerPlaySound(i,1057,0.0,0.0,0.0);
                
GivePlayerWeapon(i,weap,ammo);
            }
        }
        
GetWeaponName(weapWeapNamesizeof(WeapName) );
        
format(string,sizeof(string),"Administrator \"%s\" has given all players a %s (%d) with %d rounds of ammo"pName(playerid), WeapNameweapammo);
        return 
SendClientMessageToAll(bluestring);
    } else return 
SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");

Reply
#2

Does it actually give you the weapon and the ammo?
Reply
#3

Quote:
Originally Posted by Luis-
Посмотреть сообщение
Does it actually give you the weapon and the ammo?
yes ammo did not write gives (/giveallweapon 26) yes gives
I write ammo to give (/giveallweapon 26 50) no
Reply
#4

You're simply not converting the ammo string to integer, add this
pawn Код:
ammo = strval(tmp2);
Reply
#5

Quote:
Originally Posted by OrMisicL
Посмотреть сообщение
You're simply not converting the ammo string to integer, add this
pawn Код:
ammo = strval(tmp2);
where to add code??
Reply
#6

help
Reply
#7

right before "for(new i = 0; i < MAX_PLAYERS; i++) { "
Reply
#8

Get sscanf. It will make your life much easier, trust me.
Reply
#9

Quote:
Originally Posted by OrMisicL
Посмотреть сообщение
right before "for(new i = 0; i < MAX_PLAYERS; i++) { "
many thank you very much
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)