SA-MP Forums Archive
gives wrong ammo - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: gives wrong ammo (/showthread.php?tid=489325)



gives wrong ammo - pors - 21.01.2014

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");




Re: gives wrong ammo - Luis- - 21.01.2014

Does it actually give you the weapon and the ammo?


Re: gives wrong ammo - pors - 21.01.2014

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


Re: gives wrong ammo - OrMisicL - 21.01.2014

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



Re: gives wrong ammo - pors - 21.01.2014

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??


Re: gives wrong ammo - pors - 21.01.2014

help


Re: gives wrong ammo - OrMisicL - 21.01.2014

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


Re: gives wrong ammo - Vince - 21.01.2014

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


Re: gives wrong ammo - pors - 21.01.2014

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