View Issue Details

IDProjectCategoryView StatusLast Update
0000854GT-MP ServerAPIpublic2018-01-16 21:30
ReporterlegendAssigned To 
PrioritynormalSeveritymajorReproducibilitysometimes
Status newResolutionopen 
Product Version0.1.6 
Target VersionFixed in Version 
Summary0000854: Wrong return values of API.GetPlayerWeaponAmmo
DescriptionAPI.GetPlayerWeaponAmmo returns sometimes completely wrong values.
Unfortunately I could not catch in which cases or for which weapons.

DarkIrata has the same problem.
TagsNo tags attached.

Activities

Fabian

2018-01-06 18:43

reporter   ~0001267

In gta the non equipped ammo is the same for each weapon at the same slot.

Silverdark

2018-01-16 21:30

reporter   ~0001311

I think I can reproduce it.

Video: http://plays.tv/video/5a5e6c940a6fa681d4/getplayerweaponammo

Code:
Server side:
[Command("test1")]
public void Test1(Client player)
{
    API.givePlayerWeapon(player, WeaponHash.CombatPDW, 100, false, false);
    API.sendChatMessageToPlayer(player, "CombatPDW with 100 ammo");
}

[Command("test2")]
public void Test2(Client player)
{
    API.givePlayerWeapon(player, WeaponHash.SMG, 200, false, false);
    API.sendChatMessageToPlayer(player, "SMG with 200 ammo");
}

[Command("ammo")]
public void GetAmmo(Client player)
{
    API.sendChatMessageToPlayer(player, $"Weapon {player.currentWeapon.ToString()}: {API.getPlayerWeaponAmmo(player, player.currentWeapon)}");
    API.triggerClientEvent(player, "PrintCurrentAmmo");
}

Client:
API.onServerEventTrigger.connect((eventName) =>
{
    if (eventName !== "PrintCurrentAmmo")
    {
        return;
    }

    const localPlayer = API.getLocalPlayer();
    const currentWeapon = API.getPlayerCurrentWeapon();
    const lastWeaponAmmo = API.returnNative("GET_AMMO_IN_PED_WEAPON", 0, localPlayer, currentWeapon);
    API.sendChatMessage(`Client: Weapon ${currentWeapon} with ${lastWeaponAmmo} ammo`);
})

Issue History

Date Modified Username Field Change
2018-01-06 14:27 legend New Issue
2018-01-06 18:43 Fabian Note Added: 0001267
2018-01-16 21:30 Silverdark Note Added: 0001311