Ammo bug? - 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: Ammo bug? (
/showthread.php?tid=467653)
Ammo bug? -
gotwarzone - 04.10.2013
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?
Re: Ammo bug? -
iZN - 04.10.2013
What you mean? Show your script.
Re: Ammo bug? -
gotwarzone - 04.10.2013
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)
Re: Ammo bug? -
gotwarzone - 04.10.2013
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.
Re: Ammo bug? -
Tropicali - 05.10.2013
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.
Re: Ammo bug? -
Threshold - 05.10.2013
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.
Re: Ammo bug? -
RajatPawar - 05.10.2013
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?