2kristof2 Posted January 4, 2015 Posted January 4, 2015 (edited) Hi, Here is my script: NumToCount = 0.05 CountSpeed = 100 local b = 0.001 marker = createMarker(5497.0727539063, -2612.5356445313, 7.6, "corona",6, 0, 0, 0, 0) function flying (player) if source == marker then if isPedInVehicle(player) then vehicle=getPedOccupiedVehicle(player) x,y,z = getElementVelocity(vehicle) addEventHandler ( "onClientRender", getRootElement(), MyB) setTimer (function() removeEventHandler ( "onClientRender", getRootElement(), MyB) end, 1100 , 1 ) end end end addEventHandler("onClientMarkerHit", getRootElement(), flying) function MyB ( ) setTimer (function() b = b + 0.0015 end, CountSpeed , NumToCount ) setElementVelocity(vehicle, x,y,b) end My question is how to change local b to the primary value (0.001), because when I hit the marker and hit it again after X seconds I'll get different velocity.. Thanks for help regards, 2kristof2 Edited January 6, 2015 by Guest
Castillo Posted January 4, 2015 Posted January 4, 2015 I don't understand what do you mean, you want to reset "b" to 0.001 each time you hit the marker? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
manawydan Posted January 4, 2015 Posted January 4, 2015 continuos velocity? like fly? "Querer não é poder, mas tentar é avançar"!
2kristof2 Posted January 4, 2015 Author Posted January 4, 2015 to make it clear i recorded a short video: https://www.youtube.com/watch?v=x_rishxU4Q4&feature=youtu.be (first jump is ok, but when i hit the marker again I jump too high.
Castillo Posted January 4, 2015 Posted January 4, 2015 Add: b = 0.001 After: x,y,z = getElementVelocity(vehicle) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
2kristof2 Posted January 5, 2015 Author Posted January 5, 2015 better but still bad: https://www.youtube.com/watch?v=XAV-jpNw7BU&feature=youtu.be
Sasu Posted January 5, 2015 Posted January 5, 2015 CountSpeed = 100 local b = 0.001 local tick marker = createMarker(5497.0727539063, -2612.5356445313, 7.6, "corona",6, 0, 0, 0, 0) function flying (player) if source == marker then if isPedInVehicle(player) then vehicle=getPedOccupiedVehicle(player) b = 0.001 tick = getTickCount() x,y,z = getElementVelocity(vehicle) addEventHandler ( "onClientRender", getRootElement(), MyB) setTimer (function() removeEventHandler ( "onClientRender", getRootElement(), MyB) end, 1100 , 1 ) end end end addEventHandler("onClientMarkerHit", getRootElement(), flying) function MyB ( ) if (getTickCount() - tick) >= CountSpeed then b = b + 0.0015 tick = getTickCount() end setElementVelocity(vehicle, x,y,b) end State: Inactive
2kristof2 Posted January 5, 2015 Author Posted January 5, 2015 doesn't work (no errors in debugscript)
Dealman Posted January 5, 2015 Posted January 5, 2015 Not entirely sure what the problem is, but could it be due to the fact that the timer repeats infinitely? NumToCount is set to 0.05 and I'm pretty sure the timer only accepts an integer, so it'll interpret it as 0 which means infinite looping. If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
Sasu Posted January 5, 2015 Posted January 5, 2015 Be careful because it creates a timer every render, that's a crazy idea if we think about the eficient. State: Inactive
2kristof2 Posted January 6, 2015 Author Posted January 6, 2015 Yeah i know but the function lasts only 1,4 sec so there is no lags and everything works correctly. Anyway if you have better idea you can write it here . (because your script doesn't work for me )
Dealman Posted January 6, 2015 Posted January 6, 2015 Can't you just remove the onClientRender event handler and call the function itself once like this; x,y,z = getElementVelocity(vehicle) MyB() If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
Sasu Posted January 6, 2015 Posted January 6, 2015 Sorry, I would test it but I'm not going to be in my home until saturday. State: Inactive
2kristof2 Posted January 6, 2015 Author Posted January 6, 2015 @Dealman I tried it but somehow it doesn't work @Sasu no problem (you can always test it later)
Sasu Posted January 9, 2015 Posted January 9, 2015 I'm back, try this: local CountSpeed = 100 local b = 0.001 local tick local marker = createMarker(5497.0727539063, -2612.5356445313, 7.6, "corona",6, 0, 0, 0, 0) function flying (player) if source == marker then if isPedInVehicle(player) then vehicle=getPedOccupiedVehicle(player) b = 0.001 tick = getTickCount() x,y,z = getElementVelocity(vehicle) addEventHandler ( "onClientRender", getRootElement(), MyB) setTimer (function() removeEventHandler ( "onClientRender", getRootElement(), MyB) end, 1100 , 1 ) end end end addEventHandler("onClientMarkerHit", getRootElement(), flying) function MyB ( ) if (getTickCount() - tick) >= CountSpeed then b = b + 0.024 tick = getTickCount() end setElementVelocity(vehicle, x,y,b) end State: Inactive
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