Jump to content

[Help] Problem reseting vehicle hand


JoaoZanetti

Recommended Posts

I have a script, when i type "carrosexp" all cars in my server respawn, but respawn with previous handling. I need to reset this hand but idk how to do it. I tried setModelHandling but without success.

Part of my script:

for _, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do -- For every vehicle do the following... 
            if isEmpty( vehicle ) then 
                resetVehicleIdleTime ( vehicle ) -- Reset the vehicle's idle time 
                respawnVehicle ( vehicle ) 
            end 
        end  
        outputDebugString("Cars Respawned") 
        outputChatBox("#ADFF2F[PDB Allert]#FFFFFF All vehicles have been re-spawned" , root, 0, 255, 0, true) 
    end,respawn*1000,1) 

Thanks everyone :D

Link to comment
  • 3 weeks later...
for _, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do -- For every vehicle do the following... 
            if isEmpty( vehicle ) then
                -- Getting standart handlings
                local tempVehicle = createVehicle(getElementModel(vehicle), 0, 0, -3)
                local tempHandling = getVehicleHandling(tempVehicle)
                for _, property in ipairs(tempHanding) do
                  setVehicleHandling(vehicle, property, tempHandling[property])
                end
                destroyElement(tempVehicle)

                resetVehicleIdleTime ( vehicle ) -- Reset the vehicle's idle time 
                respawnVehicle ( vehicle ) 
            end 
        end  
        outputDebugString("Cars Respawned") 
        outputChatBox("#ADFF2F[PDB Allert]#FFFFFF All vehicles have been re-spawned" , root, 0, 255, 0, true) 
    end,respawn*1000,1) 

 

Edited by draobrehtom
Link to comment
18 minutes ago, draobrehtom said:

for _, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do -- For every vehicle do the following... 
            if isEmpty( vehicle ) then
                -- Getting standart handlings
                local tempVehicle = createVehicle(getElementModel(vehicle), 0, 0, -3)
                local tempHandling = getVehicleHandling(tempVehicle)
                for _, property in ipairs(tempHanding) do
                  setVehicleHandling(vehicle, property, tempHandling[property])
                end
                destroyElement(tempVehicle)

                resetVehicleIdleTime ( vehicle ) -- Reset the vehicle's idle time 
                respawnVehicle ( vehicle ) 
            end 
        end  
        outputDebugString("Cars Respawned") 
        outputChatBox("#ADFF2F[PDB Allert]#FFFFFF All vehicles have been re-spawned" , root, 0, 255, 0, true) 
    end,respawn*1000,1) 

 

Now vehicles is not spawning.

Link to comment
18 minutes ago, JoaoZanetti said:

Now vehicles is not spawning.

Use /debugscript 3 to find errors and test your code. I gave you right algorithm, maybe problem in indexing tempHandling table - I not test it.

for prop,value in pairs(tempHanding) do
  setVehicleHandling(vehicle, prop, value)
end

 

Edited by draobrehtom
Link to comment
2 minutes ago, JoaoZanetti said:

I got this error: http://prntscr.com/ch8cyw

for _, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do -- For every vehicle do the following... 
            if isEmpty( vehicle ) then
                -- Getting standart handlings
                local tempVehicle = createVehicle(getElementModel(vehicle), 0, 0, -3)
                local tempHandling = getVehicleHandling(tempVehicle)
                for prop,value in pairs(tempHandling) do
                  setVehicleHandling(vehicle, prop, value)
                end
                destroyElement(tempVehicle)
                resetVehicleIdleTime ( vehicle ) -- Reset the vehicle's idle time 
                respawnVehicle ( vehicle ) 
            end 
        end  
        outputDebugString("Cars Respawned") 
        outputChatBox("#ADFF2F[PDB Allert]#FFFFFF All vehicles have been re-spawned" , root, 0, 255, 0, true) 
    end,respawn*1000,1) 

 

Edited by draobrehtom
Link to comment
46 minutes ago, draobrehtom said:

for _, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do -- For every vehicle do the following... 
            if isEmpty( vehicle ) then
                -- Getting standart handlings
                local tempVehicle = createVehicle(getElementModel(vehicle), 0, 0, -3)
                local tempHandling = getVehicleHandling(tempVehicle)
                for prop,value in pairs(tempHandling) do
                  setVehicleHandling(vehicle, prop, value)
                end
                destroyElement(tempVehicle)
                resetVehicleIdleTime ( vehicle ) -- Reset the vehicle's idle time 
                respawnVehicle ( vehicle ) 
            end 
        end  
        outputDebugString("Cars Respawned") 
        outputChatBox("#ADFF2F[PDB Allert]#FFFFFF All vehicles have been re-spawned" , root, 0, 255, 0, true) 
    end,respawn*1000,1) 

 

It worked perfect. Thanks!

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