[NOT v0.3.7 ISSUE] GetPlayerWeaponData false results -
Correlli - 13.03.2015
I don't remember "GetPlayerWeaponData" function acting like this before 0.3.7 version. I've noticed this thing in 0.3.7 RC2.
Okey, so here's the thing. Player connects to a server, he gets weapons, let's say these:
pawn Код:
GivePlayerWeapon(playerid, WEAPON_SILENCED, 25);
GivePlayerWeapon(playerid, WEAPON_SHOTGSPA, 30);
GivePlayerWeapon(playerid, WEAPON_M4, 50);
GivePlayerWeapon(playerid, WEAPON_RIFLE, 15);
We run this code:
pawn Код:
new
w_data[13][2];
for(new a = 0; a < 13; a++)
{
GetPlayerWeaponData(playerid, a, w_data[a][0], w_data[a][1]);
printf("Weaponry for slot %i: weapon (%i), amount (%i)", a, w_data[a][0], w_data[a][1]);
}
And we get these results:
Код:
Weaponry for slot 0: weapon (0), amount (0)
Weaponry for slot 1: weapon (0), amount (0)
Weaponry for slot 2: weapon (23), amount (25)
Weaponry for slot 3: weapon (27), amount (30)
Weaponry for slot 4: weapon (0), amount (0)
Weaponry for slot 5: weapon (31), amount (50)
Weaponry for slot 6: weapon (33), amount (15)
Weaponry for slot 7: weapon (0), amount (0)
Weaponry for slot 8: weapon (0), amount (0)
Weaponry for slot 9: weapon (0), amount (0)
Weaponry for slot 10: weapon (0), amount (0)
Weaponry for slot 11: weapon (0), amount (0)
Weaponry for slot 12: weapon (0), amount (0)
Everything fine for now.
Then the player shoots all the bullets (or we remove them with "ResetPlayerWeapons" function) and we run the same code again, only to get these (false) results:
Код:
Weaponry for slot 0: weapon (0), amount (0)
Weaponry for slot 1: weapon (0), amount (0)
Weaponry for slot 2: weapon (23), amount (0)
Weaponry for slot 3: weapon (27), amount (0)
Weaponry for slot 4: weapon (0), amount (0)
Weaponry for slot 5: weapon (31), amount (0)
Weaponry for slot 6: weapon (33), amount (0)
Weaponry for slot 7: weapon (0), amount (0)
Weaponry for slot 8: weapon (0), amount (0)
Weaponry for slot 9: weapon (0), amount (0)
Weaponry for slot 10: weapon (0), amount (0)
Weaponry for slot 11: weapon (0), amount (0)
Weaponry for slot 12: weapon (0), amount (0)
No ammunition, and when there's no ammunition, then there is no weapon, but "GetPlayerWeaponData" function still returns the latest weapons in player's weapon inventory.
Re: GetPlayerWeaponData false results -
Lightning[SV] - 13.03.2015
Its always been like that.
Re: GetPlayerWeaponData false results -
Correlli - 13.03.2015
Quote:
Originally Posted by Lightning[SV]
Its always been like that.
|
You're right. I've just tried it on the 0.3z version and it's the same. Still, false results if you ask me, but easily fixed on our own.
Re: GetPlayerWeaponData false results -
beckzy - 14.03.2015
When a player uses all their bullets in real life they still have the weapon. So I'd say this is pretty realistic.
Re: GetPlayerWeaponData false results -
CyNiC - 14.03.2015
Quote:
Originally Posted by BeckzyBoi
When a player uses all their bullets in real life they still have the weapon. So I'd say this is pretty realistic.
|
Computers works with binary logic, fu** the realistic. These functions should work perfectly.
Re: GetPlayerWeaponData false results -
beckzy - 14.03.2015
Quote:
Originally Posted by CyNiC
Computers works with binary logic, fu** the realistic. These functions should work perfectly.
|
I am only quoting what ****** said on the matter some years ago when it was first reported.
Re: GetPlayerWeaponData false results -
Jay_ - 14.03.2015
Quote:
Originally Posted by BeckzyBoi
When a player uses all their bullets in real life they still have the weapon. So I'd say this is pretty realistic.
|
That's not how the game engine works so this statement is irrelevant really.
Re: GetPlayerWeaponData false results -
Correlli - 14.03.2015
Quote:
Originally Posted by BeckzyBoi
When a player uses all their bullets in real life they still have the weapon. So I'd say this is pretty realistic.
|
Indeed, but in SA-MP they don't (not visible in hand/inventory).
Re : GetPlayerWeaponData false results -
S4t3K - 14.03.2015
This problem has been asked 1-2 weeks ago in the French part.
Actually, GetPlayerWeaponData loops through player "weapon" stats slot per slot.
Then, it puts in "weapon" (passed by reference) the weaponid in the stats and in "ammo" (passed by reference) the ammo in the stats.
When you use "SetPlayerAmmo", it just sets the ammo in the player stats to the value you specified. It doesn't do anything about the weapon itself. And it works the same way when a player runs out of ammo.
Moreover, the game engine works such way as if you don't have ammo in a weapon, your character can't arm it (said just above).
But as ****** said, the "real" problem you pointed out is with "ResetPlayerWeapons".
EDIT : All I said is true if GetPlayerWeaponData and SetPlayerAmmo (and more mainly the weapon data management) hasn't changed since 0.3d
Re : GetPlayerWeaponData false results -
S4t3K - 14.03.2015
@****** : These ways aren't that numerous. The only legit ways are through GivePlayerWeapon, AddPlayerClass(Ex) and SetSpawnInfo.