Jump to content

How can I control the speed of an executed script


IIYAMA

Recommended Posts

  • Moderators

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...