blacee Posted February 22, 2013 Posted February 22, 2013 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.
PaiN^ Posted February 22, 2013 Posted February 22, 2013 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 !
blacee Posted February 22, 2013 Author Posted February 22, 2013 Hello,I wrote a function which should warp a player who reaches a checkpoint a few feet higher. That's what I said. Yes.
Moderators IIYAMA Posted February 22, 2013 Moderators Posted February 22, 2013 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" -- correctuser = 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 Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
blacee Posted February 23, 2013 Author Posted February 23, 2013 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())
Max+ Posted February 23, 2013 Posted February 23, 2013 (edited) Edited 2 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 February 23, 2013 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 IIYAMA Posted February 23, 2013 Moderators Posted February 23, 2013 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 Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Moderators IIYAMA Posted February 23, 2013 Moderators Posted February 23, 2013 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 Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Max+ Posted February 23, 2013 Posted February 23, 2013 (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 Edited February 23, 2013 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
Anderl Posted February 23, 2013 Posted February 23, 2013 Since when is onPlayerReachCheckpoint client side O_osetElementRotation(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 IIYAMA Posted February 23, 2013 Moderators Posted February 23, 2013 @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 Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Max+ Posted February 23, 2013 Posted February 23, 2013 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
Anderl Posted February 23, 2013 Posted February 23, 2013 @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
blacee Posted February 23, 2013 Author Posted February 23, 2013 (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 February 23, 2013 by Guest
Anderl Posted February 23, 2013 Posted February 23, 2013 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 IIYAMA Posted February 23, 2013 Moderators Posted February 23, 2013 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 Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
blacee Posted February 23, 2013 Author Posted February 23, 2013 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?
Castillo Posted February 23, 2013 Posted February 23, 2013 You could set the current vehicle model and set his position instead of creating a new one. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
blacee Posted February 23, 2013 Author Posted February 23, 2013 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?
Castillo Posted February 23, 2013 Posted February 23, 2013 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. Education is the most powerful weapon which you can use to change the world.
Moderators IIYAMA Posted February 23, 2013 Moderators Posted February 23, 2013 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 Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Castillo Posted February 23, 2013 Posted February 23, 2013 Finally. Thanks for helping me guys. My code worked? P.S: I corrected a typo at getElementPosition. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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