blacee Posted February 22, 2013 Share 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. Link to comment
PaiN^ Posted February 22, 2013 Share Posted February 22, 2013 You want when someone hits the checkpoint to get a few feet higher or what ? Link to comment
blacee Posted February 22, 2013 Author Share 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. Link to comment
Moderators IIYAMA Posted February 22, 2013 Moderators Share 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 Link to comment
blacee Posted February 23, 2013 Author Share 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()) Link to comment
Max+ Posted February 23, 2013 Share 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 Link to comment
Moderators IIYAMA Posted February 23, 2013 Moderators Share 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 >() Link to comment
Moderators IIYAMA Posted February 23, 2013 Moderators Share Posted February 23, 2013 yes, client. But I hate f*ck client. I script server. ahh removed your post.... Link to comment
Max+ Posted February 23, 2013 Share 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 Link to comment
Anderl Posted February 23, 2013 Share 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. Link to comment
Moderators IIYAMA Posted February 23, 2013 Moderators Share Posted February 23, 2013 @Anderl, do you think this event will work? I never used the Event "onPlayerReachCheckpoint". Link to comment
Max+ Posted February 23, 2013 Share Posted February 23, 2013 i will say he better use marker and on MarkerHit or ClientMarkerHit whatever. Link to comment
Anderl Posted February 23, 2013 Share 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. Link to comment
blacee Posted February 23, 2013 Author Share 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 Link to comment
Anderl Posted February 23, 2013 Share Posted February 23, 2013 Why is your file with XML extension? Link to comment
blacee Posted February 23, 2013 Author Share Posted February 23, 2013 Just a type, sorry. Link to comment
blacee Posted February 23, 2013 Author Share Posted February 23, 2013 Just a typo, sorry. Link to comment
Moderators IIYAMA Posted February 23, 2013 Moderators Share 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.... Link to comment
blacee Posted February 23, 2013 Author Share 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? Link to comment
Castillo Posted February 23, 2013 Share Posted February 23, 2013 You could set the current vehicle model and set his position instead of creating a new one. Link to comment
blacee Posted February 23, 2013 Author Share 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? Link to comment
Castillo Posted February 23, 2013 Share 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 ) Link to comment
blacee Posted February 23, 2013 Author Share Posted February 23, 2013 Finally. Thanks for helping me guys. Link to comment
Moderators IIYAMA Posted February 23, 2013 Moderators Share Posted February 23, 2013 lol the 'vehicle' -_-" I am stupid.... Link to comment
Castillo Posted February 23, 2013 Share Posted February 23, 2013 Finally. Thanks for helping me guys. My code worked? P.S: I corrected a typo at getElementPosition. Link to comment
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