Help, SetPlayerAmmo Don't work
#1

I wanted to create Ammo System save n load with mysql. Everything it's ok but only one little solve is can't not SetAmmo for player when he's logined. Anyone can help me sovle that. Thanks you then +rep back.

This stock im create for Load in OnPlayerConnect, it's worked i can check my ammo system (pAmmo) inside game but my weapon can't got the ammo still 0-0.
PHP код:
stock SetPlayerWeapons(playerid)
{
    if(
GetPVarInt(playerid"IsInArena") >= 0) { return 1; }
    
ResetPlayerWeapons(playerid);
    for (new 
weaponid 16weaponid 44weaponid++)
    {
        for(new 
012s++)
        {
            if(
PlayerInfo[playerid][pGuns][s] > && PlayerInfo[playerid][pAGuns][s] == 0)
            {
                
GivePlayerValidWeapon(playeridPlayerInfo[playerid][pGuns][s], 0);
                
SetPlayerAmmos(playeridweaponid);
            }
        }
    }
    return 
1;

There is stock to load ammo to gun from my system. I don't know why this can't work for give ammo.

PHP код:
stock SetPlayerAmmos(playeridweaponid)
{
    if(
GetPVarInt(playerid"IsInArena") >= 0) { return 1; }
    switch(
weaponid)
        {
              case 
16:
            {
                if(
PlayerInfo[playerid][pAmmo][ 22 ] > 0)
                    {
                        
SetPlayerAmmoEx(playerid16PlayerInfo[playerid][pAmmo][ 22 ]);
                    }
                else
                    {
                                            
                    }
            }
            case 
17:
            {
                if(
PlayerInfo[playerid][pAmmo][ 23 ] > 0)
                    {
                        
SetPlayerAmmoEx(playerid17PlayerInfo[playerid][pAmmo][ 23 ]);
                    }
                else
                    {
                                    
                    }
            }
            case 
18:
            {
                if(
PlayerInfo[playerid][pAmmo][ 24 ] > 0)
                    {
                        
SetPlayerAmmoEx(playerid18PlayerInfo[playerid][pAmmo][ 24 ]);
                    }
                else
                    {
                                    
                    }
            }
            case 
22:
            {
                if(
PlayerInfo[playerid][pAmmo][ ] > 0)
                    {
                        
SetPlayerAmmoEx(playerid22PlayerInfo[playerid][pAmmo][ ]);
                    }
                else
                    {
                                    
                    }
            }
            case 
23://SDpid
            
{
                if(
PlayerInfo[playerid][pAmmo][ ] > 0)
                    {
                        
SetPlayerAmmoEx(playerid23PlayerInfo[playerid][pAmmo][ ]);
                    }
                else
                    {
                    }
            }
            case 
24://DE
            
{
                if(
PlayerInfo[playerid][pAmmo][ ] > 0)
                    {
                        
SetPlayerAmmoEx(playerid24PlayerInfo[playerid][pAmmo][ ]);
                    }
                else
                    {
                    }
            }
            case 
25://Shotgun
            
{
                if(
PlayerInfo[playerid][pAmmo][ ] > 0)
                    {
                        
SetPlayerAmmoEx(playerid25PlayerInfo[playerid][pAmmo][ ]);
                    }
                else
                    {
                    }
            }
            case 
26://uzi
            
{
                if(
PlayerInfo[playerid][pAmmo][ ] > 0)
                {
                    
SetPlayerAmmoEx(playerid26PlayerInfo[playerid][pAmmo][ ]);
                }
                else
                {
                }
            }
            case 
27://uzi
            
{
                if(
PlayerInfo[playerid][pAmmo][ ] > 0)
                {
                    
SetPlayerAmmoEx(playerid27PlayerInfo[playerid][pAmmo][ ]);
                }
                else
                {
                }
            }
            case 
28://shotgun 
            
{
                if(
PlayerInfo[playerid][pAmmo][ ] > 0)
                {
                    
SetPlayerAmmoEx(playerid28PlayerInfo[playerid][pAmmo][ ]);
                }
                else
                {
                }
            }
            case 
29:
            {
                if(
PlayerInfo[playerid][pAmmo][ ] > 0)
                {
                    
SetPlayerAmmoEx(playerid29PlayerInfo[playerid][pAmmo][ ]);
                }
                else
                {
                    
                }
            }
            case 
30:
            {
                if(
PlayerInfo[playerid][pAmmo][ ] > 0)
                {
                    
SetPlayerAmmoEx(playerid30PlayerInfo[playerid][pAmmo][ ]);
                }
                else
                {
                    
                }
            }
            case 
31:
            {
                if(
PlayerInfo[playerid][pAmmo][ ] > 0)
                {
                    
SetPlayerAmmoEx(playerid31PlayerInfo[playerid][pAmmo][ ]);
                }
                else
                {
                    
                }
            }
            case 
32:
            {
                if(
PlayerInfo[playerid][pAmmo][ 10 ] > 0)
                {
                    
SetPlayerAmmoEx(playerid32PlayerInfo[playerid][pAmmo][ 10 ]);
                }
                else
                {
                    
                }
            }
            case 
33:
            {
                if(
PlayerInfo[playerid][pAmmo][ 11 ] > 0)
                {
                    
SetPlayerAmmoEx(playerid33PlayerInfo[playerid][pAmmo][ 11 ]);
                }
                else
                {
                    
                }
            }
            case 
34:
            {
                if(
PlayerInfo[playerid][pAmmo][ 12 ] > 0)
                {
                    
SetPlayerAmmoEx(playerid34PlayerInfo[playerid][pAmmo][ 12 ]);
                }
                else
                {
                    
                }
            }
            case 
35:
            {
                if(
PlayerInfo[playerid][pAmmo][ 13 ] > 0)
                {
                    
SetPlayerAmmoEx(playerid35PlayerInfo[playerid][pAmmo][ 13 ]);
                }
                else
                {
                    
                }
            }
            case 
36:
            {
                if(
PlayerInfo[playerid][pAmmo][ 14 ] > 0)
                {
                    
SetPlayerAmmoEx(playerid36PlayerInfo[playerid][pAmmo][ 14 ]);
                }
                else
                {
                    
                }
            }
            case 
37:
            {
                if(
PlayerInfo[playerid][pAmmo][ 15 ] > 0)
                {
                    
SetPlayerAmmoEx(playerid37PlayerInfo[playerid][pAmmo][ 15 ]);
                }
                else
                {
                    
                }
            }
            case 
38:
            {
                if(
PlayerInfo[playerid][pAmmo][ 16 ] > 0)
                {
                    
SetPlayerAmmoEx(playerid38PlayerInfo[playerid][pAmmo][ 16 ]);
                }
                else
                {
                    
                }
            }
            case 
39:
            {
                if(
PlayerInfo[playerid][pAmmo][ 17 ] > 0)
                {
                    
SetPlayerAmmoEx(playerid39PlayerInfo[playerid][pAmmo][ 17 ]);
                }
                else
                {
                    
                }
            }
            case 
40:
            {
                if(
PlayerInfo[playerid][pAmmo][ 18 ] > 0)
                {
                    
SetPlayerAmmoEx(playerid40PlayerInfo[playerid][pAmmo][ 18 ]);
                }
                else
                {
                    
                }
            }
            case 
41:
            {
                if(
PlayerInfo[playerid][pAmmo][ 19 ] > 0)
                {
                    
SetPlayerAmmoEx(playerid41PlayerInfo[playerid][pAmmo][ 19 ]);
                }
                else
                {
                    
                }
            }
            case 
42:
            {
                if(
PlayerInfo[playerid][pAmmo][ 20 ] > 0)
                {
                    
SetPlayerAmmoEx(playerid42PlayerInfo[playerid][pAmmo][ 20 ]);
                }
                else
                {
                    
                }
            }
            case 
43:
            {
                if(
PlayerInfo[playerid][pAmmo][ 21 ] > 0)
                {
                    
SetPlayerAmmoEx(playerid43PlayerInfo[playerid][pAmmo][ 21 ]);
                }
                else
                {
                    
                }
        }
    }
    return 
1;

PHP код:
stock SetPlayerAmmoEx(Playerweaponammo)
{
    
SetPlayerAmmo(Playerweaponammo);

Reply
#2

Anyone can help me to solved that pls. I can't see what worng in there.
Reply
#3

https://sampwiki.blast.hk/wiki/SetPlayerAmmo

SetPlayerAmmo not Ammos
Reply
#4

Quote:
Originally Posted by Arastair
Посмотреть сообщение
im using Ammos to change structure for anti infinitive Ammo. This stock still be SetPlayerAmmo
Reply
#5

The last stock SetPlayerAmmoEx, no need for it, you can use SetPlayerAmmo in SetPlayerAmmos.

Is it purpose that in SetPlayerAmmos after else comes nothing?

Well, try to remove the brackets after you get the pvar 'IsInArena' and also remove the return 1 there.

Or just remove the brackets, change the >= to <=, and let the return 1 there.

Or you open a bracket, but close the bracket at the end of the stock. Then there is no need for the return 1

*I didn't explained in depth, but i think you know what i mean.
Reply
#6

Quote:
Originally Posted by Flori
Посмотреть сообщение
The last stock SetPlayerAmmoEx, no need for it, you can use SetPlayerAmmo in SetPlayerAmmos.

Is it purpose that in SetPlayerAmmos after else comes nothing?

Well, try to remove the brackets after you get the pvar 'IsInArena' and also remove the return 1 there.

Or just remove the brackets, change the >= to <=, and let the return 1 there.

Or you open a bracket, but close the bracket at the end of the stock. Then there is no need for the return 1

*I didn't explained in depth, but i think you know what i mean.
Thanks you, im try to shorten code form 20+ ammo type to 8 ammo type. It's worked with GivePlayerWeapon, now im try to test with GivePlayerAmmo.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)