Jump to content

event when player stops aiming


John Smith

Recommended Posts

Posted

is there such event?

i need to know how to know when player has stopped aiming

thanks

If you find my post useful or if it helped you, please like my post :)
Ingame name: ZoeN

560x95_FFFFFF_FF9900_000000_000000.png

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

350x20_FFFFFF_FFFFFF_000000_000000.png

http://i.imgur.com/CSE28MJ.png

Don't hesitate to contact me for anything! If I can help, I will for sure!

Education is the most powerful weapon which you can use to change the world. - Castillo

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...

350x20_FFFFFF_FFFFFF_000000_000000.png

http://i.imgur.com/CSE28MJ.png

Don't hesitate to contact me for anything! If I can help, I will for sure!

Education is the most powerful weapon which you can use to change the world. - Castillo

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) 
  

Powered by Kimsufi©

n-560x95_FFFFFF_FFFFFF_000000_000000.png

ZHP on FacebookZHP on YoutubeSupport us

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...