Jump to content

Warp few feet higher, z+X


blacee

Recommended Posts

Posted

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.

Posted

You want when someone hits the checkpoint to get a few feet higher or what ?

" Keep Thinking Different . " - Steve Jops

--------------------

Don't send me PMs asking for help, I Won't reply !

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

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

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()) 

Posted (edited)

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

- New , Kill System

- New, GameMode Intro

- Leve / Exp System

- New nametag showing style

- New , Hud For Players

- Skin Selection from SA-MP

- Money System / Buy Weapons

- Drop Weapons

- New, Flood System

- New , Group Assign

- Gun license For Weapons

- Random Rule System For Money

  • Moderators
Posted

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 >() 

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

  • Moderators
Posted

yes, client. But I hate f*ck client.

I script server.

ahh removed your post....

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted (edited)

Lol what hell with my eyes sorry for posting iam saw you code it's Correct i think you get all the Player needs :D

Edited by Guest

- New , Kill System

- New, GameMode Intro

- Leve / Exp System

- New nametag showing style

- New , Hud For Players

- Skin Selection from SA-MP

- Money System / Buy Weapons

- Drop Weapons

- New, Flood System

- New , Group Assign

- Gun license For Weapons

- Random Rule System For Money

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

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

  • Moderators
Posted

@Anderl, do you think this event will work?

I never used the Event "onPlayerReachCheckpoint".

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

i will say he better use marker and on MarkerHit or ClientMarkerHit whatever.

- New , Kill System

- New, GameMode Intro

- Leve / Exp System

- New nametag showing style

- New , Hud For Players

- Skin Selection from SA-MP

- Money System / Buy Weapons

- Drop Weapons

- New, Flood System

- New , Group Assign

- Gun license For Weapons

- Random Rule System For Money

Posted
@Anderl, do you think this event will work?

I never used the Event "onPlayerReachCheckpoint".

I never used it either. But if that's a race event, you need to add it with addEvent.

EDIT: Nevermind, I saw you're using addEvent already.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted (edited)

 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
Posted

Why is your file with XML extension?

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

  • Moderators
Posted

To know if the script has been executed the only thing you have to do is:

outputChatBox("Works" )

Outside the function. So easy as hell....

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

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?

Posted

You could set the current vehicle model and set his position instead of creating a new one.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
You could set the current vehicle model and set his position instead of creating a new one.

Which is not working for some reason.

Would disabling the integrity check cause any problems at all?

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

  • Moderators
Posted

lol the 'vehicle' -_-"

I am stupid....

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
Finally. Thanks for helping me guys.

My code worked?

P.S: I corrected a typo at getElementPosition.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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