#Paper Posted December 2, 2010 Share Posted December 2, 2010 How i can detect when a player do a vehicle flip? Link to comment
Discord Moderators Zango Posted December 2, 2010 Discord Moderators Share Posted December 2, 2010 you mean whenever the ped vehicle is upside down? There is no event for this, unless you're running freeroam you can for example create your own event and trigger when player uses /flip Link to comment
#Paper Posted December 2, 2010 Author Share Posted December 2, 2010 you mean whenever the ped vehicle is upside down?There is no event for this, unless you're running freeroam you can for example create your own event and trigger when player uses /flip no, you don't understand, i want to know when a player flip his/her vehicle, but whitout command and shop... Link to comment
Castillo Posted December 2, 2010 Share Posted December 2, 2010 what i get of what he asking for is, when a vehicle jumps and the vehicle flips he wants to detect that i guess. Link to comment
#Paper Posted December 2, 2010 Author Share Posted December 2, 2010 what i get of what he asking for is, when a vehicle jumps and the vehicle flips he wants to detect that i guess. ye i want this but i don't know how to detect it ;S Link to comment
Discord Moderators Zango Posted December 2, 2010 Discord Moderators Share Posted December 2, 2010 (edited) I had a function once to do this job precisely with matrices, I'll see if I can find tomorrow Edited December 3, 2010 by Guest Link to comment
Discord Moderators Zango Posted December 3, 2010 Discord Moderators Share Posted December 3, 2010 local WORLD_DOWN = {0, 0, -1} local UPSIDE_DOWN_THRESHOLD = math.cos(math.rad(20)) function isVehicleUpsideDown (vehicle) local matrix = getElementMatrix (vehicle) local vehicleUp = {matrix_rotate (matrix, 0, 0, 1)} local dotP = math.dotP (vehicleUp, WORLD_DOWN) return (dotP >= UPSIDE_DOWN_THRESHOLD) end function matrix_rotate (matrix, x, y, z) local tx = x * matrix[1][1] + y * matrix[2][1] + z * matrix[3][1] local ty = x * matrix[1][2] + y * matrix[2][2] + z * matrix[3][2] local tz = x * matrix[1][3] + y * matrix[2][3] + z * matrix[3][3] return tx, ty, tz end function math.dotP(v1, v2) return v1[1]*v2[1] + v1[2]*v2[2] + v1[3]*v2[3] end use a timer or something similar to check Link to comment
#Paper Posted December 6, 2010 Author Share Posted December 6, 2010 local WORLD_DOWN = {0, 0, -1} local UPSIDE_DOWN_THRESHOLD = math.cos(math.rad(20)) function isVehicleUpsideDown (vehicle) local matrix = getElementMatrix (vehicle) local vehicleUp = {matrix_rotate (matrix, 0, 0, 1)} local dotP = math.dotP (vehicleUp, WORLD_DOWN) return (dotP >= UPSIDE_DOWN_THRESHOLD) end function matrix_rotate (matrix, x, y, z) local tx = x * matrix[1][1] + y * matrix[2][1] + z * matrix[3][1] local ty = x * matrix[1][2] + y * matrix[2][2] + z * matrix[3][2] local tz = x * matrix[1][3] + y * matrix[2][3] + z * matrix[3][3] return tx, ty, tz end function math.dotP(v1, v2) return v1[1]*v2[1] + v1[2]*v2[2] + v1[3]*v2[3] end in what function i must connect the timer? use a timer or something similar to check Link to comment
Discord Moderators Zango Posted December 7, 2010 Discord Moderators Share Posted December 7, 2010 Excuse me, but take 1 fucking minute to read the code and tell me what function do you think you must connect? Link to comment
#Paper Posted December 7, 2010 Author Share Posted December 7, 2010 Excuse me, but take 1 minute to read the code and tell me what function do you think you must connect? mybe the isVehicle...??? Link to comment
Discord Moderators Zango Posted December 7, 2010 Discord Moderators Share Posted December 7, 2010 Excuse me, but take 1 minute to read the code and tell me what function do you think you must connect? mybe the isVehicle...??? go on and test it! Link to comment
wasd Posted December 7, 2010 Share Posted December 7, 2010 You could do this a bit simpler with this function https://wiki.multitheftauto.com/wiki/GetElementRotation Link to comment
#Paper Posted December 7, 2010 Author Share Posted December 7, 2010 You could do this a bit simpler with this function https://wiki.multitheftauto.com/wiki/GetElementRotation i saw but the example can't help me... Link to comment
wasd Posted December 7, 2010 Share Posted December 7, 2010 You could do this a bit simpler with this function https://wiki.multitheftauto.com/wiki/GetElementRotation i saw but the example can't help me... If your going to script things sooner or later your going to have to learn the fundamental concepts of programming. Learn the concepts and then you will be able to teach yourself, until then I guess you will just have to get people to write code for you, as it seems you are trying to get people to do here. You asked a question so I gave you an answer, if you don't know how to implement that answer, then tough luck. Link to comment
Discord Moderators Zango Posted December 7, 2010 Discord Moderators Share Posted December 7, 2010 You could do this a bit simpler with this function https://wiki.multitheftauto.com/wiki/GetElementRotation it won't work properly, or not atleast with the same result as the function I posted above I made a script for you in the pain of publishing that function without purpose local WORLD_DOWN = {0, 0, -1} local UPSIDE_DOWN_THRESHOLD = math.cos(math.rad(20)) function isVehicleUpsideDown (vehicle) local matrix = getElementMatrix (vehicle) local vehicleUp = {matrix_rotate (matrix, 0, 0, 1)} local dotP = math.dotP (vehicleUp, WORLD_DOWN) return (dotP >= UPSIDE_DOWN_THRESHOLD) end function matrix_rotate (matrix, x, y, z) local tx = x * matrix[1][1] + y * matrix[2][1] + z * matrix[3][1] local ty = x * matrix[1][2] + y * matrix[2][2] + z * matrix[3][2] local tz = x * matrix[1][3] + y * matrix[2][3] + z * matrix[3][3] return tx, ty, tz end function math.dotP(v1, v2) return v1[1]*v2[1] + v1[2]*v2[2] + v1[3]*v2[3] end function onVehicleFlip () local vehicle = getPedOccupiedVehicle (getLocalPlayer()) if vehicle then checkTimer = setTimer ( function (vehicle) if isElement (vehicle) then if isVehicleUpsideDown (vehicle) then outputChatBox ('Your vehicle is upside down!') killTimer (checkTimer) end else killTimer (checkTimer) end end, 100, 0, vehicle ) end end addCommandHandler ('vehicleflip', onVehicleFlip) copy and paste this into a clientside script, start it and type /vehicleflip you can see the result and play around for yourself isVehicleUpsideDown is the function which returns whether or not the vehicle is flipped as you called it Link to comment
#Paper Posted December 7, 2010 Author Share Posted December 7, 2010 You could do this a bit simpler with this function https://wiki.multitheftauto.com/wiki/GetElementRotation it won't work properly, or not atleast with the same result as the function I posted above I made a script for you in the pain of publishing that function without purpose local WORLD_DOWN = {0, 0, -1} local UPSIDE_DOWN_THRESHOLD = math.cos(math.rad(20)) function isVehicleUpsideDown (vehicle) local matrix = getElementMatrix (vehicle) local vehicleUp = {matrix_rotate (matrix, 0, 0, 1)} local dotP = math.dotP (vehicleUp, WORLD_DOWN) return (dotP >= UPSIDE_DOWN_THRESHOLD) end function matrix_rotate (matrix, x, y, z) local tx = x * matrix[1][1] + y * matrix[2][1] + z * matrix[3][1] local ty = x * matrix[1][2] + y * matrix[2][2] + z * matrix[3][2] local tz = x * matrix[1][3] + y * matrix[2][3] + z * matrix[3][3] return tx, ty, tz end function math.dotP(v1, v2) return v1[1]*v2[1] + v1[2]*v2[2] + v1[3]*v2[3] end function onVehicleFlip () local vehicle = getPedOccupiedVehicle (getLocalPlayer()) if vehicle then checkTimer = setTimer ( function (vehicle) if isElement (vehicle) then if isVehicleUpsideDown (vehicle) then outputChatBox ('Your vehicle is upside down!') killTimer (checkTimer) end else killTimer (checkTimer) end end, 100, 0, vehicle ) end end addCommandHandler ('vehicleflip', onVehicleFlip) copy and paste this into a clientside script, start it and type /vehicleflip you can see the result and play around for yourself isVehicleUpsideDown is the function which returns whether or not the vehicle is flipped as you called it lol the command don't work Link to comment
Discord Moderators Zango Posted December 7, 2010 Discord Moderators Share Posted December 7, 2010 did I remember to highlight clientside and your vehicle having to be upside down and command called once? 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