Moderators IIYAMA Posted November 12, 2012 Moderators Posted November 12, 2012 I like to know how to make a script execute with a limit at speed rate. (Best way) See script> Script sample: function weaponfire(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) outputChatBox("etc.") end addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), weaponfire ) If I use a shotgun the outputchatbox does have low speed rate. A spraycan does have a speed rate at client render. See weapon flag 0x000400 - fires every frame within loop (ie paint spray) . How can I make a limit at execute a script? (like a timer etc (lagg)) Thx 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 November 12, 2012 Author Moderators Posted November 12, 2012 like this one? function weaponfire(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) tick = getTickCount() if tick - lastshot > 50/getGameSpeed() then outputChatBox("lol") lastshot = tick return end outputChatBox("works") end addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), weaponfire ) or can it be smaller? Thx for the help 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 November 12, 2012 Author Moderators Posted November 12, 2012 btw what would be better if I do or don't use weapons like 41 or 42? this way: if weapon == 41 or weapon == 42 then tick = getTickCount() if tick - lastShot> 20/getGameSpeed() then lastShot = tick return; end onClientPlayerWeaponFireFunc_CallBack(source, weapon, hitX, hitY, hitZ, hitElement ); else -- now he does not have to calcullate tickcount, but he do have another 2 lines. onClientPlayerWeaponFireFunc_CallBack(source, weapon, hitX, hitY, hitZ, hitElement ); end or if weapon == 41 or weapon == 42 then tick = getTickCount() if tick - lastShot> 20/getGameSpeed() then lastShot = tick return; end end onClientPlayerWeaponFireFunc_CallBack(source, weapon, hitX, hitY, hitZ, hitElement ); 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
myonlake Posted November 12, 2012 Posted November 12, 2012 You can also use a timer to do this. setTimer If I helped you, please click the like button on the right Thanks!
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