Ammo bug?
#1

Wep0 = 0
Wep1 = 0
Wep2 = 22
Wep3 = 0
Wep4 = 0
Wep5 = 30
Wep6 = 0
Wep7 = 0
Wep8 = 0
Wep9 = 0
Wep10 = 0
Wep11 = 0
Wep12 = 0
Ammo0 = 0
Ammo1 = 0
Ammo2 = -31073
Ammo3 = 0
Ammo4 = 0
Ammo5 = -31073
Ammo6 = 0
Ammo7 = 0
Ammo8 = 0
Ammo9 = 0
Ammo10 = 0
Ammo11 = 0
Ammo12 = 0

Now I can't switch my weapons to one another. Its like lock. Ammo bug?
Reply
#2

What you mean? Show your script.
Reply
#3

Quote:
Originally Posted by iZN
Посмотреть сообщение
What you mean? Show your script.
This is in my scriptfiles/users. that saves players weapon.

this is my script sample...

Код:
    if(dialogid == DIALOGID+6) // Shotguns
    {
        if(response)
        {
            if(listitem == 0)
            {
                GivePlayerWeapon(playerid, 25, 60000);
            }
            if(listitem == 1)
            {
                GivePlayerWeapon(playerid, 26, 60000);
            }
            if(listitem == 2)
            {
                GivePlayerWeapon(playerid, 27, 60000);
            }
everytime I switch weapon. It suddenly switches back to fist. and I see when I switch its 0 - -41324 (negative)
Reply
#4

Okay guys can you just please help me. Make a limit ammo so It wont let it bug like negative?

When

I choose a gun that has 5000 ammo. Then let say I fired 300 now its 4700 ammo. When I choose again the same weapon it should return to 5000 ammo. NOT 10000 or doubled.
Reply
#5

In order for us to help you, you need to explain properly what the issue is and post proper pieces of code so we can understand what you need.

Do that and we can help.
Reply
#6

You should be using ResetPlayerWeapons before using GivePlayerWeapon. This way, ammo won't be stacked, eventually giving you unlimited (negative) ammo.

EDIT:
Similar situation: https://sampforum.blast.hk/showthread.php?pid=2690150#pid2690150

EDIT #2:
I just realised that the guy's problem was still existant after he did a SafeResetPlayerWeapons, but nobody ever helped him... oh well.
Reply
#7

When you give weapons AFTER retrieving them from your saving system, probably add something like this?
pawn Код:
new player_ammo = // retreived ammo value which is -31000 in your case?
// store ammo value in this variable, then

if( player_ammo <  0 )
 player_ammo = - ( player_ammo );
Would this work?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)