Arsilex Posted August 27, 2012 Share Posted August 27, 2012 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
Castillo Posted August 27, 2012 Share Posted August 27, 2012 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
Arsilex Posted August 27, 2012 Author Share Posted August 27, 2012 MySQL Query failed. me sale eso pero solo si lo ago con coches guardados en el mysql con coches temporales no me sale nada Link to comment
Castillo Posted August 27, 2012 Share Posted August 27, 2012 Lo que pasa es que yo le puse que guardase un JSON en lugar de un numero. Link to comment
Castillo Posted August 27, 2012 Share Posted August 27, 2012 Es un string que luego podes transformar en tabla con: fromJSON. Link to comment
Arsilex Posted August 27, 2012 Author Share Posted August 27, 2012 Pues la verda es que me quede igual que estava con lo de JSON.. Link to comment
Recommended Posts