Jump to content

Color


Arsilex

Recommended Posts

Posted
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

rsilex.png.0e6ad382b3fdc3cbe6390e3e847572c9.png
Posted
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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Lo que pasa es que yo le puse que guardase un JSON en lugar de un numero.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Es un string que luego podes transformar en tabla con: fromJSON.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

  • Recently Browsing   0 members

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