Jump to content

X - Y - Z


#Paper

Recommended Posts

  • Discord Moderators

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

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