Scripting Moderators ds1-e Posted March 17, 2019 Scripting Moderators Share Posted March 17, 2019 (edited) Hey once again. I have encountered a issue with colshapes. https://wiki.multitheftauto.com/wiki/OnClientColShapeHit https://wiki.multitheftauto.com/wiki/OnClientColShapeLeave So what's the problem with them? - OnClientColShapeHit doesn't trigger after leaving from other colshape. Let's say i have player with colshape, inside of car which have colshape too. Firstly i hit car colsphere, then i hit player colsphere, after that i leave from player colsphere, but sadly, onClientColShapeHit doesn't trigger for car colsphere, even if i am still inside of colshape. So i am asking you guys, how can i do something like "dynamic" colshapes. Or atleast fix issue above. Edited March 17, 2019 by majqq Link to comment
Enargy, Posted March 18, 2019 Share Posted March 18, 2019 When OnClientColShapeLeave is triggered you could check if the player is in any other colshape. 1 Link to comment
Zorgman Posted March 18, 2019 Share Posted March 18, 2019 It's normal, the event is triggered only when you hit the colshape bounds. In your use case, you are already in the car's col, so no new hit event is detected. You can save the interaction colshapes that are 'active' for the player by using tables. 1 Link to comment
Scripting Moderators ds1-e Posted March 19, 2019 Author Scripting Moderators Share Posted March 19, 2019 16 hours ago, Zorgman said: It's normal, the event is triggered only when you hit the colshape bounds. In your use case, you are already in the car's col, so no new hit event is detected. You can save the interaction colshapes that are 'active' for the player by using tables. If colshape/player hit each other, save it to client-side table, and then let's say use a function to switch them, if there's more than 1, and if player is in range of it? Plus delete data from this table onClientElementDestroy? That's what you mean? Link to comment
Scripting Moderators ds1-e Posted April 4, 2019 Author Scripting Moderators Share Posted April 4, 2019 bump. I just tried 2 different events related with colshapes, and probably i shoud use OnClientElementColShapeHit/OnClientElementColShapeLeave. Because onClientColShapeLeave doesn't trigger after jumping out of car. function onClientElementColShapeHit(theShape, sameDimension) colShape = "onClientElementColShapeHit" end addEventHandler("onClientElementColShapeHit", getRootElement(), onClientElementColShapeHit) -- function onClientElementColShapeLeave(theShape, sameDimension) colShape = "onClientElementColShapeLeave" end addEventHandler("onClientElementColShapeLeave", getRootElement(), onClientElementColShapeLeave) Added little state in onClientRender to be sure which event triggers. But, still i need some help. I would like to know which way will be best for get colshape into table (only if it doesn't exist in table). Any advices? Link to comment
Zorgman Posted April 5, 2019 Share Posted April 5, 2019 Assuming that you can interact with only one player and one vehicle at a time - just create two client-side variables to handle it (e.g. currentVehicleInteractCol and currentPlayerInteractCol) and update them on hit and on leave events. 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