Jump to content

Coches


Arsilex

Recommended Posts

Bueno necesito ayuda con esto

function openall (player, commandName, modelo) 
local models = getElementsByType("vehicle") 
    for index, autos in pairs(models) do 
        if ( getElementModel(autos) == tonumber(modelo)) then 
            local vehicleID = vehicles[ vehicle ] and vehicles[ vehicle ].vehicleID 
            if vehicleID and ( vehicleID < 0 or exports.sql:query_free( "UPDATE vehicles SET locked = 1 - locked WHERE vehicleID = " .. vehicleID ) ) then 
                setVehicleLocked( vehicle, not isVehicleLocked( vehicle ) ) 
                return true 
            end 
            return false 
        else 
        outputChatBox( "No se encontro el coche", player, 255,0,0, true) 
        end 
    end 
end 
addCommandHandler("abrircoches", openall) 

lo que quiero es que en vezde poner el modelo que solo ponga abrircoches y se abran los coches de los siguentes ID

431--Bus

574--Sweeper

420--Taxi

438--Cabbie

Es posible :S

Link to comment
local models = 
    { 
        [ 431 ] = true, 
        [ 574 ] = true, 
        [ 420 ] = true, 
        [ 438 ] = true 
    } 
  
function openall ( player ) 
    for index, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do 
        if ( models [ getElementModel ( vehicle ) ] ) then 
            local vehicleID = vehicles [ vehicle ] and vehicles [ vehicle ].vehicleID 
            if ( vehicleID and ( vehicleID < 0 or exports.sql:query_free( "UPDATE vehicles SET locked = 1 - locked WHERE vehicleID = " .. vehicleID ) ) ) then 
                setVehicleLocked ( vehicle, not isVehicleLocked ( vehicle ) ) 
            end 
        end 
    end 
end 
addCommandHandler ( "abrircoches", openall ) 

Link to comment
  • Recently Browsing   0 members

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