SA-MP Forums Archive
GetPlayerWeaponData problem. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: GetPlayerWeaponData problem. (/showthread.php?tid=119636)



GetPlayerWeaponData problem. - Eazy_Efolife - 08.01.2010

Hi, I've been working on a weapon saving system. Well anyway, the Variable that stores the weapon ID always becomes 1. Even with any weapon. The ammo saves though. Anyone got an idea why this is not working?

Код:
PlayerInfo[playerid][pGun1] = GetPlayerWeaponData(playerid, 2, PlayerInfo[playerid][pGun1], PlayerInfo[playerid][pAmmo1]);
NOTE: I spawned a 9mm (( Which is slot 2 )) to test the saving.


Re: GetPlayerWeaponData problem. - Joe Staff - 08.01.2010

You're using the function wrong.

pawn Код:
new ammo, gun;
GetPlayerWeaponData(playerid,0,gun,ammo);
printf("%d,%d",gun,ammo);
This will print (to the console) the gun and ammo of slot 0 for 'playerid'


Re: GetPlayerWeaponData problem. - Eazy_Efolife - 08.01.2010

Quote:
Originally Posted by Joe Staff
You're using the function wrong.

pawn Код:
new ammo, gun;
GetPlayerWeaponData(playerid,0,gun,ammo);
printf("%d,%d",gun,ammo);
This will print (to the console) the gun and ammo of slot 0 for 'playerid'
Ah, It's returning -1 for ammo, So it couldnt get the ammo correct? And the gun is just returning 1.


Re: GetPlayerWeaponData problem. - Joe Staff - 08.01.2010

Most likely because you're trying to get player information as the disconnect from the server, ammo specifically is client sided and the server has to request that information.


Re: GetPlayerWeaponData problem. - Eazy_Efolife - 08.01.2010

Quote:
Originally Posted by Joe Staff
Most likely because you're trying to get player information as the disconnect from the server, ammo specifically is client sided and the server has to request that information.
No, I use it as a timer, Every second everybodys account saves..


Re: GetPlayerWeaponData problem. - Joe Staff - 08.01.2010

Every second? Horrible idea, but whatever. I don't think I've ever heard of WeaponPlayerData returning -1... Make sure you hold your weapon, this might update the server on how much ammo you have.


Re: GetPlayerWeaponData problem. - Eazy_Efolife - 08.01.2010

Quote:
Originally Posted by Joe Staff
Every second? Horrible idea, but whatever. I don't think I've ever heard of WeaponPlayerData returning -1... Make sure you hold your weapon, this might update the server on how much ammo you have.
What's wrong with every second, and yes I do hold it..

EDIT: FIXED!


Re: GetPlayerWeaponData problem. - Eazy_Efolife - 08.01.2010

Quote:
Originally Posted by » ραωпsтαг «
So how did you fix it? D;
Removed:
Код:
PlayerInfo[playerid][pGun1] =



Re: GetPlayerWeaponData problem. - Joe Staff - 08.01.2010

..., Did you not see my example of how to use that function? lol


Re: GetPlayerWeaponData problem. - adsy - 08.01.2010

Quote:
Originally Posted by Compton's Eazy E
Quote:
Originally Posted by Joe Staff
You're using the function wrong.

pawn Код:
new ammo, gun;
GetPlayerWeaponData(playerid,0,gun,ammo);
printf("%d,%d",gun,ammo);
This will print (to the console) the gun and ammo of slot 0 for 'playerid'
Ah, It's returning -1 for ammo, So it couldnt get the ammo correct? And the gun is just returning 1.
slot 0 is your hands isnt it? -1 is your hands as a weapon and -1 ammo would be correct