Get Player Current Weapon

Hi,

I am trying to find a way to check what weapon the player is currently holding and if they are holding a certain weapon it returns a true value for an if statement.

I have tried to use
if GetCurrentPedWeapon(ped, weapon) == 1 then
but no matter what weapon you are holding it returns 1.

Any help would be appreciated :smiley:

Matt

1 Like

maybe you could use this native : GET_SELECTED_PED_WEAPON(Ped ped)

it return you the hash of the weapon.

2 Likes

Yep that worked perfectly - did

if GetSelectedPedWeapon(ped) == GetHashKey("weapon_specialcarbine") then

This returns true if the selected weapon is the Special Carbine Rifle

Thanks for your help!

1 Like

glad to help :+1:

(don’t forget to click on solve if it’s solve ^^)

Im trying to code a simple script for weapon components and i get this error https://prnt.sc/tkkmbw
i dont know why?

hi, can you help me with vangolico robbery? i tried to use get player current weapon to start robbery, but when i shoot, robbery won’t start.
here is my code

incircle = true
						if GetSelectedPedWeapon(ped) == GetHashKey("weapon_specialcarbine") then
						if IsPedShooting(GetPlayerPed(-1)) then
							if Config.NeedBag then
							    if borsa == 40 or borsa == 41 or borsa == 44 or borsa == 45 then
							        ESX.TriggerServerCallback('esx_vangelico_robbery:conteggio', function(CopsConnected)
								        if CopsConnected >= Config.RequiredCopsRob then
							                TriggerServerEvent('esx_vangelico_robbery:rob', k)
									        PlaySoundFromCoord(soundid, "VEHICLES_HORNS_AMBULANCE_WARNING", pos2.x, pos2.y, pos2.z)
								        else
									        TriggerEvent('esx:showNotification', _U('min_two_police') .. Config.RequiredCopsRob .. _U('min_two_police2'))
								        end
							        end)		
						        else
							        TriggerEvent('esx:showNotification', _U('need_bag'))
								end
							else
								ESX.TriggerServerCallback('esx_vangelico_robbery:conteggio', function(CopsConnected)
									if CopsConnected >= Config.RequiredCopsRob then
										TriggerServerEvent('esx_vangelico_robbery:rob', k)
										PlaySoundFromCoord(soundid, "VEHICLES_HORNS_AMBULANCE_WARNING", pos2.x, pos2.y, pos2.z)
									else
										TriggerEvent('esx:showNotification', _U('min_two_police') .. Config.RequiredCopsRob .. _U('min_two_police2'))
									end
								end)	
							end	
						end
						end

@kingnesiarp not the place to ask, start a new topic, that’s clearly stated… Like everywhere :man_facepalming:

1 Like