Moderators IIYAMA Posted November 12, 2012 Moderators Share 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 Link to comment
Moderators IIYAMA Posted November 12, 2012 Author Moderators Share 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 Link to comment
Moderators IIYAMA Posted November 12, 2012 Author Moderators Share 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 ); Link to comment
myonlake Posted November 12, 2012 Share Posted November 12, 2012 You can also use a timer to do this. setTimer 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