Jump to content

Warp few feet higher, z+X


blacee

Recommended Posts

Hello,

I wrote a function which should warp a player who reaches a checkpoint a few feet higher.

 function warphigh (source) 
    local x, y, z, r = 0, 0, 0, 0 
    x, y, z = getElementPosition (source) 
    r = getPlayerRotation (source) 
    z = (z + 20) 
    setElementPosition (source, x, y, z) 
    setPlayerRotation (source, r) 
end 
  
addEvent('onPlayerReachCheckpoint') 
addEventHandler('onPlayerReachCheckpoint', getRootElement(), warphigh(source)) 

I run it with,

warphigh(source) 

but nothing happens at all, neither error messages nor crashes.

Thanks in advance.

Link to comment
  • Moderators
  
addEvent('onPlayerReachCheckpoint') 
addEventHandler('onPlayerReachCheckpoint', getRootElement(), 
function  (checkpoint,time)-- if needed checkpoint,time 
   local  x, y, z = getElementPosition (source) 
    setElementPosition (source, x, y, z+20) 
    setPlayerRotation (source, getPlayerRotation (source)) 
end) 
  
 --"warphigh(source)" why? 
  

I have never worked with it but here in Russian:

https://wiki.multitheftauto.com/wiki/RU/Resource:Race

"onPlayerReachCheckpoint" -- correct

user = source -- but won't be wrote down in ()

int checkpoint, int time_ -- between the (), they are the parameters

Link to comment

Thanks for the help, but sadly it does not work.

  
function warphigh(checkpoint, time) 
   local  x, y, z = getElementPosition (source) 
    setElementPosition (source, x, y, z+20) 
    setPlayerRotation (source, getPlayerRotation (source)) 
end 
  
addEvent('onPlayerReachCheckpoint') 
addEventHandler('onPlayerReachCheckpoint', getRootElement(), warphigh()) 

Link to comment

Edited 2 :D

  
addEvent('onPlayerReachCheckpoint', true) 
addEventHandler('onPlayerReachCheckpoint' , root, 
function(cp, time) 
    if cp == 1 or cp == 3 or cp == 5 or cp == 7 or cp == 9 or cp == 11 or cp == 13 or cp == 15 or cp == 17 or cp == 19 then 
    local x, y, z = getElementPosition( source) 
   local x1, x2, x3 = getElementRotation(source) 
    setElementPosition(source, x, y, z+20) 
    setElementRotation(source, x1, x2, x3(source)) 
  end 
end 
) 

Edited by Guest
Link to comment
  • Moderators

Since when is onPlayerReachCheckpoint client side O_o

setElementRotation(localPlayer, x1, x2, x3(localPlayer)) heh????? :?

Thanks for the help, but sadly it does not work.

  
function warphigh(checkpoint, time) 
   local  x, y, z = getElementPosition (source) 
    setElementPosition (source, x, y, z+20) 
    setPlayerRotation (source, getPlayerRotation (source)) 
end 
  
addEvent('onPlayerReachCheckpoint') 
addEventHandler('onPlayerReachCheckpoint', getRootElement(), warphigh()) 

  
function warphigh(checkpoint, time) 
   local  x, y, z = getElementPosition (source) 
    setElementPosition (source, x, y, z+20) 
    setPlayerRotation (source, getPlayerRotation (source)) 
end 
  
addEvent('onPlayerReachCheckpoint') 
addEventHandler('onPlayerReachCheckpoint', getRootElement(), warphigh)-- NO >() 

maybe getRootElement() must be root, but I am not sure...

  
function warphigh(checkpoint, time) 
   local  x, y, z = getElementPosition (source) 
    setElementPosition (source, x, y, z+20) 
    setPlayerRotation (source, getPlayerRotation (source)) 
end 
  
addEvent('onPlayerReachCheckpoint') 
addEventHandler('onPlayerReachCheckpoint', root, warphigh)-- NO >() 

Link to comment
Since when is onPlayerReachCheckpoint client side O_o

setElementRotation(localPlayer, x1, x2, x3(localPlayer)) heh????? :?

Thanks for the help, but sadly it does not work.

  
function warphigh(checkpoint, time) 
   local  x, y, z = getElementPosition (source) 
    setElementPosition (source, x, y, z+20) 
    setPlayerRotation (source, getPlayerRotation (source)) 
end 
  
addEvent('onPlayerReachCheckpoint') 
addEventHandler('onPlayerReachCheckpoint', getRootElement(), warphigh()) 

  
function warphigh(checkpoint, time) 
   local  x, y, z = getElementPosition (source) 
    setElementPosition (source, x, y, z+20) 
    setPlayerRotation (source, getPlayerRotation (source)) 
end 
  
addEvent('onPlayerReachCheckpoint') 
addEventHandler('onPlayerReachCheckpoint', getRootElement(), warphigh)-- NO >() 

maybe getRootElement() must be root, but I am not sure...

  
function warphigh(checkpoint, time) 
   local  x, y, z = getElementPosition (source) 
    setElementPosition (source, x, y, z+20) 
    setPlayerRotation (source, getPlayerRotation (source)) 
end 
  
addEvent('onPlayerReachCheckpoint') 
addEventHandler('onPlayerReachCheckpoint', root, warphigh)-- NO >() 

You don't necessarely need to use 'root' instead of 'getRootElement' function, they're both the same.

Link to comment

 function warphigh(checkpoint, time) 
   local  x, y, z = getElementPosition (source) 
    setElementPosition (source, x, y, z+20) 
    setPlayerRotation (source, getPlayerRotation (source)) 
end 
  
addEvent('onPlayerReachCheckpoint') 
addEventHandler('onPlayerReachCheckpoint', getRootElement(), warphigh) 

Still not working. I run it inside the map with:

  <meta> <script src="warphigh.lua" type="server"/> </meta> 

Edited by Guest
Link to comment

Ok, so I rewrote my whole script because of the problem.

When someone enters a checkpoint, a new vehicle will be created 20 units higher. After that, the ped gets warped into the new created vehicle and the old one gets destroyed.

There is just a small problem with the script. I'm running it in racemode, so the whole mode gets restarted because of the Race script integrity check. I know that I could just disable the integrity check, but I feel like I shouldn't do that.

Is there any way to solve that problem?

Link to comment
function warphigh ( checkpoint, time ) 
    local vehicle = getPedOccupiedVehicle ( source ) 
    local x, y, z = getElementPosition ( vehicle ) 
    local rx, ry, rz = getElementRotation ( vehicle ) 
    setElementPosition ( vehicle, x, y, z + 20 ) 
    setElementRotation ( vehicle, rx, ry, rz ) 
end 
addEvent ( 'onPlayerReachCheckpoint' ) 
addEventHandler ( 'onPlayerReachCheckpoint', getRootElement(), warphigh ) 

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