GetPlayerWeaponData fails. -_-
#1

Hello guys, I have a bug to report at GetPlayerWeaponData(playerid, slot, weapon, ammo);

Description:
The function returns wrong values when you make a drive-by (e.g. At a bike).

Reproduce:
Get this into a FS:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/give", cmdtext, true) == 0)
    {
        ResetPlayerWeapons(playerid);
        GivePlayerWeapon(playerid,28,500);
        GivePlayerWeapon(playerid,35,500);
        return 1;
    }
    if (strcmp("/check", cmdtext, true) == 0)
    {
        new weap, ammo;
        GetPlayerWeaponData(playerid,4,weap,ammo);
        new weap2, ammo2;
        GetPlayerWeaponData(playerid,7,weap2,ammo2);
        new string[128], string2[128];
        format(string, 128, "Uzi: %d ammo", ammo);
        format(string2, 128, "Rockets: %d ammo", ammo2);
        SendClientMessage(playerid,0x0000FFFF, string);
        SendClientMessage(playerid,0x0000FFFF, string2);
        print(string); print(string2);
        return 1;
    }
    return 0;
}
Whatever, thats just to give you a weapon, and check the ammo.

Now you do this:

Connect to the server and spawn, then type /give and /check:
Код:
[14:44:46] Uzi: 500 ammo
[14:44:46] Rockets: 500 ammo
Now shoot a rocket, and /check:
Код:
[14:44:54] Uzi: 500 ammo
[14:44:54] Rockets: 499 ammo
Now an UZI shot, and /check:
Код:
[14:44:57] Uzi: 498 ammo
[14:44:57] Rockets: 499 ammo
Now you switch your weapon to Rocket again, and you take a bike and take it as driver.
Then your weapon will be automatically the UZI, as rocket launcher is not a drive-by weapon.
Now make some shots with the UZI, and /check again:
Код:
[14:45:09] Uzi: 498 ammo
[14:45:09] Rockets: 468 ammo
Leave the bike, and do /check:
(Note: You should now hold the Rocket again, when you have left the bike.)
Код:
[14:45:19] Uzi: 445 ammo
[14:45:19] Rockets: 499 ammo
Enter it as driver again, and /check:
(Note: Still holding the Rocket.)
Код:
[14:45:25] Uzi: 445 ammo
[14:45:25] Rockets: 445 ammo
Same thing goes on again: ...
Код:
[14:45:41] Uzi: 445 ammo
[14:45:41] Rockets: 439 ammo
If you have any questions, or if you don't understand a part, just ask.

I'd appreciate it, if someone could confirm this, by checking it.
And I hope that this will be fixed in future releases.

Regards,
Jeffry
Reply
#2

GetPlayerWeaponState is -1 (unknown) in vehicles, so weapon functions doesn't work very good.
Reply
#3

Add this just before GetPlayerWeaponData:
Код:
OnPlayerUpdate(playerid);
Worth ago.
Reply
#4

Still the same bug.
Reply
#5

Confirming, anybody who has a tip?
Reply
#6

Edit Just realised the poster above bumped this...

Why would you bump a year old post (though I don't know whether the bug was fixed, if it hasn't been then you're alright) that's probably been fixed by now?!

Anyway, my original post:

You could force it to set a drive-by weapon, I guess.

pawn Код:
SetPlayerArmedWeapon(..);
I can't remember the parameters or anything, as I don't touch weapons, but still: (https://sampwiki.blast.hk/wiki/SetPlayerArmedWeapon)

I can't think of any other way round this.

I haven't tested this, but theoretically it should work. As the game, although changing the weapon automatically, will be then set by the server too, so should synchronise the current weapon correctly?

I don't know I just thought I'd drop this in here!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)