GiveWeaponToPed not working ServerSide C#

Im trying to use this

GiveWeaponToPed(player.Character.NetworkId, (uint)GetHashKey("WEAPON_PISTOL"), 1000, false, false);

In an event like this

private void TeleportEvent([FromSource] Player player, string obj)
        {

            PlayerList players = new PlayerList();
            GiveWeaponToPed(player.Character.NetworkId, (uint)GetHashKey("WEAPON_PISTOL"), 1000, false, false);

Thats not giving the pistol to the player. I know that the event is triggering because if i add a console.writeline after GiveWeaponToPed it shows up. Where is the problem?

Don’t pass the network ID, just use the entity handle.

What do you mean by entity handle? Im completly new to fivem, sorry if its obvious

Use player.Character.Handle

Also I suggest you use Players instead of new PlayerList()

I usage

API.GiveWeaponToPed(player.Character.Handle, (uint)WeaponHash.RevolverCattleman, 1, false, true);
API.SetCurrentPedWeapon(player.Character.Handle, (uint)WeaponHash.RevolverCattleman, true);

But not working, why?

are you trying to call this client sided or server sided? I have no idea what’s not working. I need more information please.

It`s server side. I call server API, but this code not reaction

[Command("giveweapon")]
private void GiveWeaponCommand([FromSource] Player player)
{
    GiveWeaponToPed(int.Parse(player.Handle), (uint)GetHashKey("WEAPON_ASSAULTRIFLE"), 9999, true, false);
    SetCurrentPedWeapon(int.Parse(player.Handle), (uint)GetHashKey("WEAPON_ASSAULTRIFLE"), false);
}

Here you go I hope this helps :smiley:

(edit: Please note this is just proof of concept modify as you see fit.)