Tommy. Posted November 13, 2016 Share Posted November 13, 2016 (edited) I want to stop the gravity after 5 seconds Gravity changes to 0.0001 but does not return to 0.0008 --client side panel = false function test() dxDrawRectangle(414, 297, 109, 29, tocolor(0, 0, 0, 150), false) dxDrawText("TEST GRAVITY", 414, 297, 523, 326, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false) end function onClientClick (button,state) if parte1hab and button == "left" and state == "down" then if isCursorOnElement(414, 297, 109, 29) then triggerServerEvent ("Gravity-5s", getLocalPlayer()) end end end addEventHandler("onClientClick",root,onClientClick) function open() if panel == false then addEventHandler ("onClientRender", root, test) panel = true showCursor (true) else removeEventHandler ("onClientRender", root, test) panel = false showCursor (false) end end bindKey("F5", "down", open) --server side function Gravity () setPedGravity(source, 0.0001) setTimer(function() setPedGravity(source, 0.0008) end, 5000, 1) end addEvent("Gravity-5s",true) addEventHandler("Gravity-5s",getRootElement(),Gravity) Edited November 13, 2016 by Tommy. Link to comment
LoPollo Posted November 13, 2016 Share Posted November 13, 2016 (edited) Source does not exists inside the timer (line 4 server) You must pass the source as a parameter to the timer Spoiler function Gravity () setPedGravity(source, 0.0001) setTimer(function(player)--this parameter is the parameter passed below setPedGravity(player, 0.0008) end, 5000, 1, source)--this parameter will be handled from the function end addEvent("Gravity-5s",true) addEventHandler("Gravity-5s",getRootElement(),Gravity) Edited November 13, 2016 by LoPollo Link to comment
Tommy. Posted November 13, 2016 Author Share Posted November 13, 2016 1 minute ago, LoPollo said: Source does not exists inside the timer (line 4 server) You must pass the source as a parameter to the timer that's right? function Gravity () setPedGravity(source, 0.0001) setTimer(function(source) setPedGravity(source, 0.0008) end, 5000, 1) end addEvent("Gravity-5s",true) addEventHandler("Gravity-5s",getRootElement(),Gravity) Link to comment
LoPollo Posted November 13, 2016 Share Posted November 13, 2016 nope, i edited the above reply adding the code to be more clear 1 Link to comment
Tommy. Posted November 13, 2016 Author Share Posted November 13, 2016 2 minutes ago, LoPollo said: nope, i edited the above reply adding the code to be more clear did not work Link to comment
LoPollo Posted November 13, 2016 Share Posted November 13, 2016 mmm then i need to test, i will let you know as soon as i have time 1 Link to comment
Gravestone Posted November 13, 2016 Share Posted November 13, 2016 Try function Gravity () setPedGravity(source, 0.0001) player = source setTimer(function() setPedGravity(player, 0.0008) end, 5000, 1) end addEvent("Gravity-5s",true) addEventHandler("Gravity-5s",getRootElement(),Gravity) Link to comment
Tommy. Posted November 13, 2016 Author Share Posted November 13, 2016 3 minutes ago, Gravestone said: Try function Gravity () setPedGravity(source, 0.0001) player = source setTimer(function() setPedGravity(player, 0.0008) end, 5000, 1) end addEvent("Gravity-5s",true) addEventHandler("Gravity-5s",getRootElement(),Gravity) No error in debugscript but does not work Link to comment
LoPollo Posted November 13, 2016 Share Posted November 13, 2016 (edited) the code i provided is working for me, but the default gravity is 0.008 ( not 0.0008 ) btw i do have an element at argument 1, are you sure u copied the code? (maybe you edited and forgot something, dunno) Edited November 13, 2016 by LoPollo 1 Link to comment
Tommy. Posted November 13, 2016 Author Share Posted November 13, 2016 1 minute ago, LoPollo said: the code i provided is working for me, but the default gravity is 0.008 (not 0.0008 btw i do have an element at argument 1, are you sure u copied the code? (maybe you edited and forgot something, dunno) Thanks, I was putting 0.0008 <3 1 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