Jump to content

X - Y - Z


#Paper

Recommended Posts

  • Discord Moderators
Posted

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

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

Posted
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

  • Discord Moderators
Posted (edited)

I had a function once to do this job precisely with matrices, I'll see if I can find tomorrow

Edited by Guest
  • Discord Moderators
Posted
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

Posted
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

  • Discord Moderators
Posted

Excuse me, but take 1 fucking minute to read the code and tell me what function do you think you must connect?

  • Discord Moderators
Posted
Excuse me, but take 1 :o minute to read the code and tell me what function do you think you must connect?

mybe the isVehicle...???

go on and test it!

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

  • Discord Moderators
Posted
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

Posted
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

  • Discord Moderators
Posted

did I remember to highlight clientside and your vehicle having to be upside down and command called once?

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