Jump to content

Color


Arsilex

Recommended Posts

addCommandHandler( { "setvehiclecolor", "setcolor" }, 
    function( player, commandName, other, color1, color2 ) 
        local color1 = tonumber( color1 ) 
        local color2 = tonumber( color2 ) or color1 
        if other and color1 and color2 and color1 >= 0 and color1 <= 255 and color2 >= 0 and color2 <= 255 then 
            local other, name = exports.players:getFromName( player, other ) 
            if other then 
                local vehicle = getPedOccupiedVehicle( other ) 
                if vehicle then 
                    local data = vehicles[ vehicle ] 
                    if data then 
                        if data.vehicleID < 0 or exports.sql:query_free( "UPDATE vehicles SET color1 = " .. color1 .. ", color2 = " .. color2 .. " WHERE vehicleID = " .. data.vehicleID ) then 
                            setVehicleColor( vehicle, color1, color2, color1, color2 ) 
                            outputChatBox( "Changed the color of " .. name .. "'s " .. getVehicleName( vehicle ) .. ".", player, 0, 255, 153 ) 
                        else 
                            outputChatBox( "MySQL Query failed.", player, 255, 0, 0 ) 
                        end 
                    else 
                        outputChatBox( "Vehicle Error.", player, 255, 0, 0 ) 
                    end 
                else 
                    outputChatBox( name .. " isn't driving a vehicle.", player, 255, 0, 0 ) 
                end 
            end 
        else 
            outputChatBox( "Syntax: /" .. commandName .. " [player] [color 1] [color 2]", player, 255, 255, 255 ) 
        end 
    end, 
    true 
) 

como hacer para que el script reconozca colores R,B,G

Link to comment
addCommandHandler( { "setvehiclecolor", "setcolor" }, 
    function( player, commandName, other, r, g, b, r2, g2, b2 ) 
        local r = tonumber ( r ) or 0 
        local g = tonumber ( g ) or r 
        local b = tonumber ( b ) or g 
        local r2 = tonumber ( r2 ) 
        local g2 = tonumber ( g2 ) 
        local b2 = tonumber ( b2 ) 
        if ( other and r and g and b >= 0 and r <= 255 and g >= 0 and g <= 255 and b >= 0 and b <= 255 ) then 
            local other, name = exports.players:getFromName ( player, other ) 
            if ( other ) then 
                local vehicle = getPedOccupiedVehicle ( other ) 
                if ( vehicle ) then 
                    local data = vehicles [ vehicle ] 
                    if ( data ) then 
                        if ( data.vehicleID < 0 or exports.sql:query_free ( "UPDATE vehicles SET color1 = " .. toJSON ( { r, g, b } ) .. ", color2 = " .. toJSON ( { r2, g2, b2 } ) .. " WHERE vehicleID = " .. data.vehicleID  ) ) then 
                            setVehicleColor ( vehicle, r, g, b, r2, g2, b2 ) 
                            outputChatBox ( "Changed the color of " .. name .. "'s " .. getVehicleName ( vehicle ) .. ".", player, 0, 255, 153 ) 
                        else 
                            outputChatBox ( "MySQL Query failed.", player, 255, 0, 0 ) 
                        end 
                    else 
                        outputChatBox ( "Vehicle Error.", player, 255, 0, 0 ) 
                    end 
                else 
                    outputChatBox ( name .. " isn't driving a vehicle.", player, 255, 0, 0 ) 
                end 
            end 
        else 
            outputChatBox ( "Syntax: /" .. commandName .. " [player] [r] [g] [b]", player, 255, 255, 255 ) 
        end 
    end, 
    true 
) 

Proba eso.

Link to comment
  • Recently Browsing   0 members

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