Jump to content

[Solved]A "for" instead of "setTimer"


ManeXi

Recommended Posts

Well I have made custom settings to disable/enable GTA:SA glitches via admin panel, it works but I use a timer to keep being able to enable/disable them on real time. Idk if it's my paranoia, but I find it pretty annoying, so my question is How can I use a "for" loop with it.

This is the code:

function executeGlitches() 
    local super_sprint = get("super_sprint") 
    local fastmove = get("fastmove") 
    local crouchbug = get("crouchbug") 
    local fastfire = get("fastfire") 
    local quickstand = get("quickstand") 
    local hitanim = get("hitanim") 
    setGlitchEnabled ( "fastsprint", super_sprint ) 
    setGlitchEnabled ( "fastmove", fastmove ) 
    setGlitchEnabled ( "crouchbug", crouchbug ) 
    setGlitchEnabled ( "fastfire", fastfire ) 
    setGlitchEnabled ( "quickstand", quickstand ) 
    setGlitchEnabled ( "hitanim", hitanim ) 
end 
setTimer(executeGlitches,500, 0) 

Edited by Guest
Link to comment
  • Moderators

You can't replace a timer with a for loop!

But you can make the code dynamic with a "for" loop.

local glitchesTable = { 
    {"super_sprint", "fastsprint"}, 
    {"fastmove", "fastmove"}, 
    -- etc.! 
} 

for i=1, #glitchesTable  do 
    local glitchData = glitchesTable[i] 
    local glitchValue = tostring(get(glitchData[1])) 
    local glitchName = glitchData[2] 
    if glitchValue ~= "" then 
        setGlitchEnabled ( glitchName , glitchValue:lower() == "true" ) 
    end 
end 

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...