Scripting Moderators ds1-e Posted February 5, 2019 Scripting Moderators Share Posted February 5, 2019 Hi. I created a function for enable/disable things like: walk, sprint, jump. However this function runs every 300ms on client side. Any idea how can i improve it, to remove timer at all? (I tried to do it without timer - but without it, it doesn't work as it should) function checkPlayerMovementStyle() local value = skinsData["Movement"][getElementModel(getLocalPlayer())] if value then setPedControlState(getLocalPlayer(), "walk", value[1]) toggleControl("sprint", value[2]) toggleControl("jump", value[3]) end end setTimer(checkPlayerMovementStyle, 300, 0) Link to comment
Z4Zy Posted February 5, 2019 Share Posted February 5, 2019 Seems this code is toggling player's sprint and jump every 300 miliseconds. But when you toggle the control one time... it will last longer until you enable it. Is't it ? Link to comment
Scripting Moderators ds1-e Posted February 5, 2019 Author Scripting Moderators Share Posted February 5, 2019 (edited) 8 minutes ago, DeadthStrock said: Seems this code is toggling player's sprint and jump every 300 miliseconds. But when you toggle the control one time... it will last longer until you enable it. Is't it ? Without timer this thing: setPedControlState(getLocalPlayer(), "walk", value[1]) isn't working, if i want to player move slowly all the time, after sometime it looks like this thing disable. (player can walk like you are exhausted, i want to player move all the time on ALT) Edited February 5, 2019 by majqq Link to comment
Z4Zy Posted February 5, 2019 Share Posted February 5, 2019 (edited) can you test below peace of code separately from your resource ? and tell what you think about it related to your code ? after command as /walk function checkPlayerMovementStyle() setTimer( function () value = {} value[1] = true value[2] = false setTimer(setPedControlState,50,2,getLocalPlayer(), "walk", value[1]) toggleControl("walk", value[2]) toggleControl("sprint", value[2]) toggleControl("jump", value[2]) end,500,1) end addCommandHandler("walk",checkPlayerMovementStyle) Edited February 5, 2019 by DeadthStrock 1 Link to comment
Scripting Moderators ds1-e Posted February 7, 2019 Author Scripting Moderators Share Posted February 7, 2019 On 05/02/2019 at 16:15, DeadthStrock said: can you test below peace of code separately from your resource ? and tell what you think about it related to your code ? after command as /walk function checkPlayerMovementStyle() setTimer( function () value = {} value[1] = true value[2] = false setTimer(setPedControlState,50,2,getLocalPlayer(), "walk", value[1]) toggleControl("walk", value[2]) toggleControl("sprint", value[2]) toggleControl("jump", value[2]) end,500,1) end addCommandHandler("walk",checkPlayerMovementStyle) I'll try it out soon, after it i'll answer you. Thanks. 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