JeViCo Posted April 1, 2018 Share Posted April 1, 2018 Good day, community! I have a question: How can i detect a moment when the player is near the car and opens the door? I tried to use onClientVehicleStartEnter. When then distance between player and vehicle like 1 meter and more sound plays before player starts opening the door. getPedOccupiedVehicle + OnClientRender gives me the same as onClientVehicleEnter Link to comment
Moderators Patrick Posted April 1, 2018 Moderators Share Posted April 1, 2018 (edited) It's only play sound when enter to the vehicle from OUTSIDE. More tasks: https://wiki.multitheftauto.com/wiki/List_of_player_tasks Maybe you need: TASK_SIMPLE_CAR_OPEN_DOOR_FROM_OUTSIDE, TASK_SIMPLE_CAR_OPEN_LOCKED_DOOR_FROM_OUTSIDE, TASK_SIMPLE_CAR_CLOSE_DOOR_FROM_INSIDE, TASK_SIMPLE_CAR_CLOSE_DOOR_FROM_OUTSIDE -- CLIENT function checkEnter() local a,b,c,d = getPedTask(getLocalPlayer(), "primary", 3) if tostring(b) == "TASK_SIMPLE_CAR_OPEN_DOOR_FROM_OUTSIDE" then playDoorSound() removeEventHandler("onClientRender", getRootElement(), checkEnter) end end function playDoorSound() outputChatBox("playSound()") end addEventHandler("onClientVehicleStartEnter", getRootElement(), function(player) if player ~= localPlayer then return end addEventHandler("onClientRender", getRootElement(), checkEnter) end) Edited April 1, 2018 by gpetersz 1 Link to comment
Slim Posted April 1, 2018 Share Posted April 1, 2018 Maybe could utilize this, can detect when a player presses their preferred "enter_exit" key.https://wiki.multitheftauto.com/wiki/Control_names Link to comment
JeViCo Posted April 2, 2018 Author Share Posted April 2, 2018 On 01.04.2018 at 15:16, gpetersz said: It's only play sound when enter to the vehicle from OUTSIDE. More tasks: https://wiki.multitheftauto.com/wiki/List_of_player_tasks Maybe you need: TASK_SIMPLE_CAR_OPEN_DOOR_FROM_OUTSIDE, TASK_SIMPLE_CAR_OPEN_LOCKED_DOOR_FROM_OUTSIDE, TASK_SIMPLE_CAR_CLOSE_DOOR_FROM_INSIDE, TASK_SIMPLE_CAR_CLOSE_DOOR_FROM_OUTSIDE -- CLIENT function checkEnter() local a,b,c,d = getPedTask(getLocalPlayer(), "primary", 3) if tostring(b) == "TASK_SIMPLE_CAR_OPEN_DOOR_FROM_OUTSIDE" then playDoorSound() removeEventHandler("onClientRender", getRootElement(), checkEnter) end end function playDoorSound() outputChatBox("playSound()") end addEventHandler("onClientVehicleStartEnter", getRootElement(), function(player) if player ~= localPlayer then return end addEventHandler("onClientRender", getRootElement(), checkEnter) end) Thank you so much, it works! I didn't know about getPedTask. I'll learn it. Thanks again Link to comment
Moderators Patrick Posted April 2, 2018 Moderators Share Posted April 2, 2018 You are welcome! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now