GetPlayerWeaponData problem.
#1

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.
Reply
#2

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'
Reply
#3

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.
Reply
#4

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.
Reply
#5

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..
Reply
#6

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.
Reply
#7

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!
Reply
#8

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

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)