Jump to content

event when player stops aiming


John Smith

Recommended Posts

Posted

Maybe this function will help:

getPedTask 

But I don't know if it has some 'aiming' task, you should play around with it and see what it returns to find out.

If there isn't such task, then the closest thing you can do is probably checking when aiming control state changes:

bindKey 

But it's not that accurate for detecting when player stops aiming.

Posted

Try this event, not tested...

addEventHandler("onPlayerTarget", getRootElement(), function (target) 
if(not target) then 
--DO WHAT YOU WANT TO DO WHEN PLAYER STOPS TARGET HERE! 
end 
end) 
  

Change getRootElement() for your player if you want

Posted

Except "onPlayerTarget" doesn't detect when the player starts/stops aiming, but rather when the player starts/stop aiming at particular element.

Posted
Except "onPlayerTarget" doesn't detect when the player starts/stops aiming, but rather when the player starts/stop aiming at particular element.

Just think a little bit... when a player stops aiming at all, it will stop aiming of the object too...

Posted

Now there's a great possibility to create an event with getPedTask()

Just hook it onClientRender (most accurate)

local currTask = false 
addEventHandler('onClientRender',getRootElement(),function() 
local thisTask = getPedTask(localPlayer,'secondary',0) 
if currTask == 'TASK_SIMPLE_USE_GUN' and currTask ~= thisTask then 
    triggerEvent('onClientPlayerStopAiming',localPlayer) 
end 
currTask = thisTask 
end) 
  
addEvent('onClientPlayerStopAiming',false) 
addEventHandler('onClientPlayerStopAiming',getRootElement(),function() 
    outputChatBox(' You have stopped aiming.',255,100,100) 
end) 
  

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...