Jump to content

Change a CommandHandler to Timer!


Chaz-CR

Recommended Posts

Hi well, i've been trying to change a command handler whit a timer but i couldn't. I'd like you guys help me cuz i dont know how to do this line works thanks!

Here is the code!

function saveAllVehiclesAlternative () 
        local file = fileCreate( "vehicles.xml" ) 
        local vs = 0 
        local prec = getTickCount() 
          fileWrite( file, "\n" ) 
            for k, i in ipairs ( getElementsByType( "vehicle" ) ) do 
                if allVehicles[i] then 
                    local x, y, z = getElementPosition( i ) 
                    local ar, ag, ab, br, bg, bb, cr, cg, cb, dr, dg, db = getVehicleColor( i, true ) 
                    fileWrite( file, "    \""..allVehicles[i].."\" model=\""..getElementModel( i ).."\" pos=\""..toJSON({x, y, z}).."\" color=\""..toJSON({ar, ag, ab, br, bg, bb, cr, cg, cb, dr, dg, db}).."\" paintjob=\""..getVehiclePaintjob(i).."\" upgrades=\""..toJSON( getVehicleUpgrades(i) ).."\" interior=\""..getElementInterior(i).."\" dimension=\""..getElementDimension(i).."\" /> \n" ) 
                    vs = vs + 1 
                end 
            end 
          fileWrite( file, " \n" ) 
        fileClose( file ) 
        outputDebugString( vs.." vehiculos guardados en "..getTickCount()-prec.." ms", 3 ) 
    end 
addCommandHandler( "preguard", saveAllVehiclesAlternative ) 

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