Jump to content

setVehicleColor #ERROR#


JuniorMelo

Recommended Posts

Posted

Hello, I have a problem in this script

has an error :|

mta-screen_2013-11-15_18-34-45.png

function ResourceStart() 
executeSQLCreateTable("VColors", "serial STRING,Col1 INT,Col2 INT,Col3 INT") 
end 
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), ResourceStart) 
  
addEvent ( "GetColor2", true ) 
addEventHandler ( "GetColor2", root, 
function ( r, g, b, PVeh ) 
            triggerClientEvent ( root, "GetColor", root, r, g, b ) 
            local serial = getPlayerSerial(source) 
            setVehicleColor ( PVeh, r, g, b) 
            outputChatBox("Settings Updated!",source,0,255,0) 
executeSQLUpdate ( "VColors", "Col1 = '"..r.."'","serial = '" .. serial .. "'") 
executeSQLUpdate ( "VColors", "Col2 = '"..g.."'","serial = '" .. serial .. "'") 
executeSQLUpdate ( "VColors", "Col3 = '"..b.."'","serial = '" .. serial .. "'") 
end ) 
  
 function vehColor2() 
local players = getElementsByType ( "player" ) 
for k,v in ipairs(players) do 
local PVeh = getPedOccupiedVehicle(v) 
local serial = getPlayerSerial(v) 
local Col1 = executeSQLSelect ( "VColors", "Col1","serial = '" .. serial .. "'") 
local Col2 = executeSQLSelect ( "VColors", "Col2","serial = '" .. serial .. "'") 
local Col3 = executeSQLSelect ( "VColors", "Col3","serial = '" .. serial .. "'") 
setVehicleColor(PVeh,tonumber(Col1[1]["Col1"]),tonumber(Col2[1]["Col2"]),tonumber(Col3[1]["Col3"]) ) 
 end 
 end 
  
function timer() 
 setTimer(vehColor2,3000,1) 
 end 
 function timer2() 
 setTimer(vehColor2,tonumber(respawntime)+1000,1) 
 end 
 addEventHandler("onMapStarting",getRootElement(),timer) 

line 373:

setVehicleColor(PVeh,tonumber(Col1[1]["Col1"]),tonumber(Col2[1]["Col2"]),tonumber(Col3[1]["Col3"]) ) 

........... \__ ▄▂_

.........[█|||███████]▄▄▄▄▄▄▄▄▄▃▂

..__▂▄▅█████████▅▄▃▂

I███████████████████]

...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

░░░███████ ]▄▄▄▄▄▄▄▄

▂▄▅████████▅▄▃▂

I███████████████████]

◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

Posted

One of these "Col*" is returning nil.

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

You should create an output to see what Col1[1] returns. Cause you're getting a table back and you're using a unknown index field ( it doesn't exist in your table ). I think the ["Col1"] is the biggest problem right now

logo-small.png?v=3 tiny-sapdfr.png

 

If you want to contact me directly concerning Advanced-Gaming, please contact me at [email protected]

Posted

:?:?:?:?

changed

the error may be in client file ??

addEventHandler ( "onClientGUIClick", root, 
function ( VehColor,r, g, b,PVeh) 
if ( guiGetText ( r2 ) ~= "" ) and ( guiGetText ( g2 ) ~= "" ) and ( guiGetText ( b2 ) ~= "" ) then 
    if ( source == ExecuteColor ) then 
local PVeh = getPedOccupiedVehicle(getLocalPlayer()) 
triggerServerEvent ( "GetColor2", localPlayer, guiGetText ( r2 ), guiGetText ( g2 ), guiGetText ( b2 ), PVeh ) 
    elseif ( source == colorPicker ) then 
        openPicker ( 59553532, "#000000", "Cor do Veiculo" ) 
        end 
    end 
end ) 

SERVER

  function ResourceStart() 
executeSQLCreateTable("VColors", "serial STRING,Col1 INT,Col2 INT,Col3 INT") 
end 
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), ResourceStart) 
  
addEvent ( "GetColor2", true ) 
addEventHandler ( "GetColor2", root, 
function ( r, g, b, PVeh ) 
            triggerClientEvent ( root, "GetColor", root, r, g, b ) 
            local serial = getPlayerSerial(source) 
            setVehicleColor ( PVeh, r, g, b) 
            outputChatBox("Settings Updated!",source,0,255,0) 
executeSQLUpdate ( "VColors", "Col1 = '"..r.."'","serial = '" .. serial .. "'") 
executeSQLUpdate ( "VColors", "Col2 = '"..g.."'","serial = '" .. serial .. "'") 
executeSQLUpdate ( "VColors", "Col3 = '"..b.."'","serial = '" .. serial .. "'") 
end ) 
  
 function vehColor2() 
local players = getElementsByType ( "player" ) 
for k,v in ipairs(players) do 
local PVeh = getPedOccupiedVehicle(v) 
local serial = getPlayerSerial(v) 
local Col1 = executeSQLSelect ( "VColors", "Col1","serial = '" .. serial .. "'") 
local Col2 = executeSQLSelect ( "VColors", "Col2","serial = '" .. serial .. "'") 
local Col3 = executeSQLSelect ( "VColors", "Col3","serial = '" .. serial .. "'") 
setVehicleColor(PVeh,tonumber(Col1[1]["Col1"]),tonumber(Col2[1]["Col2"]),tonumber(Col3[1]["Col3"]) ) 
 end 
 end 
  
function timer() 
 setTimer(vehColor2,3000,1) 
 end 
 function timer2() 
 setTimer(vehColor2,tonumber(respawntime)+1000,1) 
 end 
 addEventHandler("onMapStarting",getRootElement(),timer) 

........... \__ ▄▂_

.........[█|||███████]▄▄▄▄▄▄▄▄▄▃▂

..__▂▄▅█████████▅▄▃▂

I███████████████████]

...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

░░░███████ ]▄▄▄▄▄▄▄▄

▂▄▅████████▅▄▃▂

I███████████████████]

◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

Posted
Give us the output what col1, col2 and col3 is. ( outputDebugString ), if it's a table value then add [1] to it.

well?

local Col1[1] = executeSQLSelect ( "VColors", "Col1","serial = '" .. serial .. "'") 
local Col2[1] = executeSQLSelect ( "VColors", "Col2","serial = '" .. serial .. "'") 
local Col3[1] = executeSQLSelect ( "VColors", "Col3","serial = '" .. serial .. "'") 

........... \__ ▄▂_

.........[█|||███████]▄▄▄▄▄▄▄▄▄▃▂

..__▂▄▅█████████▅▄▃▂

I███████████████████]

...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

░░░███████ ]▄▄▄▄▄▄▄▄

▂▄▅████████▅▄▃▂

I███████████████████]

◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

Posted

You don't get it, after those 3 lines place this;

outputDebugString ( tostring ( Col1[1] ) .." -- ".. tostring ( Col2[1] ) .." -- " .. tostring ( Col3[1] ) ); 

tell us what you see in /debugscript 3

logo-small.png?v=3 tiny-sapdfr.png

 

If you want to contact me directly concerning Advanced-Gaming, please contact me at [email protected]

Posted
You don't get it, after those 3 lines place this;
outputDebugString ( tostring ( Col1[1] ) .." -- ".. tostring ( Col2[1] ) .." -- " .. tostring ( Col3[1] ) ); 

tell us what you see in /debugscript 3

mta-screen_2013-11-15_23-23-12.png

........... \__ ▄▂_

.........[█|||███████]▄▄▄▄▄▄▄▄▄▃▂

..__▂▄▅█████████▅▄▃▂

I███████████████████]

...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

░░░███████ ]▄▄▄▄▄▄▄▄

▂▄▅████████▅▄▃▂

I███████████████████]

◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

Posted
This function is deprecated. This means that its use is discouraged and that it might not exist in future versions.

Please use executeSQLQuery instead. See the examples at executeSQLQuery for equivalent SELECT usage

You should have used executeSQLQuery

F4MZM4.gif

Posted
This function is deprecated. This means that its use is discouraged and that it might not exist in future versions.

Please use executeSQLQuery instead. See the examples at executeSQLQuery for equivalent SELECT usage

You should have used executeSQLQuery

Could you give me an example this function?

........... \__ ▄▂_

.........[█|||███████]▄▄▄▄▄▄▄▄▄▃▂

..__▂▄▅█████████▅▄▃▂

I███████████████████]

...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

░░░███████ ]▄▄▄▄▄▄▄▄

▂▄▅████████▅▄▃▂

I███████████████████]

◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

Posted
executeSQLQuery("SELECT score,health FROM players WHERE name=?", playerName ) 
executeSQLQuery("SELECT `score`,`health` FROM `players` WHERE `name`=?", playerName ) 

https://wiki.multitheftauto.com/wiki/ExecuteSQLQuery

this function that you sent me, * health * Saves the health of player ? :?:?:shock::shock:

........... \__ ▄▂_

.........[█|||███████]▄▄▄▄▄▄▄▄▄▃▂

..__▂▄▅█████████▅▄▃▂

I███████████████████]

...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

░░░███████ ]▄▄▄▄▄▄▄▄

▂▄▅████████▅▄▃▂

I███████████████████]

◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

Posted

No this retrieves the health and the score from a database, if you want to save/update something then use INSERT syntax to store something or use UPDATE syntax to update a stored data.

Examples of INSERT and UPDATE syntaxes:

executeSQLQuery("INSERT INTO players(name,color,sound) VALUES(?,?,?)", playerName, colorName, soundName ) 
executeSQLQuery("INSERT INTO `players`(`name`,`color`,`sound`) VALUES(?,?,?)", playerName, colorName, soundName ) 

executeSQLQuery("UPDATE players SET color='green',sound='somehead' WHERE name=?", playerName ) 
executeSQLQuery("UPDATE players SET color=?,sound=? WHERE name=?", colorName, soundName, playerName ) 
executeSQLQuery("UPDATE `players` SET `color`=?,`sound`=? WHERE `name`=?", colorName, soundName, playerName 

F4MZM4.gif

Posted (edited)

deleted

Edited by Guest

........... \__ ▄▂_

.........[█|||███████]▄▄▄▄▄▄▄▄▄▃▂

..__▂▄▅█████████▅▄▃▂

I███████████████████]

...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

░░░███████ ]▄▄▄▄▄▄▄▄

▂▄▅████████▅▄▃▂

I███████████████████]

◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

Posted

New function, no working

function buyCarColor(thePlayer,red,green,blue) 
    local account = getPlayerAccount(thePlayer) 
    if not (isGuestAccount(account)) then 
            setAccountData(account,"firstRed",red) 
            setAccountData(account,"firstGreen",green) 
            setAccountData(account,"firstBlue",blue) 
            outputChatBox("#00ff00[sHOP] #ffffff---!",thePlayer,255,255,255,true) 
            local PVeh = getPedOccupiedVehicle(thePlayer) 
            setVehicleColor(PVeh,red,green,blue) 
        end 
    end 
  
function callClientFunction(client, funcname, ...) 
    local arg = { ... } 
    if (arg[1]) then 
        for key, value in next, arg do 
            if (type(value) == "number") then arg[key] = tostring(value) end 
        end 
    end 
    -- If the clientside event handler is not in the same resource, replace 'resourceRoot' with the appropriate element 
    triggerClientEvent(client, "onServerCallsClientFunction", resourceRoot, funcname, unpack(arg or {})) 
end 
  
  
function callServerFunction(funcname, ...) 
    local arg = { ... } 
    if (arg[1]) then 
        for key, value in next, arg do arg[key] = tonumber(value) or value end 
    end 
    loadstring("return "..funcname)()(unpack(arg)) 
end 
addEvent("onClientCallsServerFunction", true) 
addEventHandler("onClientCallsServerFunction", resourceRoot , callServerFunction) 
  
function updatePlayerLogin(thePlayer) 
    local account = getPlayerAccount(thePlayer) 
        red = getAccountData(account,"firstRed") 
        green = getAccountData(account,"firstGreen") 
        blue = getAccountData(account,"firstBlue") 
        local PVeh = getPedOccupiedVehicle(thePlayer) 
        setVehicleColor(PVeh,red,green,blue) 
end 
  
addEventHandler("onPlayerLogin", getRootElement(),updatePlayerLogin) 
  

Debugscript 3

mta-screen_2013-11-16_14-42-07.png

........... \__ ▄▂_

.........[█|||███████]▄▄▄▄▄▄▄▄▄▃▂

..__▂▄▅█████████▅▄▃▂

I███████████████████]

...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

░░░███████ ]▄▄▄▄▄▄▄▄

▂▄▅████████▅▄▃▂

I███████████████████]

◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

Posted
function buyCarColor(thePlayer,red,green,blue) 
    local account = getPlayerAccount(thePlayer) 
    if not (isGuestAccount(account)) then 
            setAccountData(account,"firstRed",red) 
            setAccountData(account,"firstGreen",green) 
            setAccountData(account,"firstBlue",blue) 
            outputChatBox("#00ff00[sHOP] #ffffff---!",thePlayer,255,255,255,true) 
            local PVeh = getPedOccupiedVehicle(thePlayer) 
            setVehicleColor(PVeh,red,green,blue) 
        end 
    end 
  
function callClientFunction(client, funcname, ...) 
    local arg = { ... } 
    if (arg[1]) then 
        for key, value in next, arg do 
            if (type(value) == "number") then arg[key] = tostring(value) end 
        end 
    end 
    -- If the clientside event handler is not in the same resource, replace 'resourceRoot' with the appropriate element 
    triggerClientEvent(client, "onServerCallsClientFunction", resourceRoot, funcname, unpack(arg or {})) 
end 
  
  
function callServerFunction(funcname, ...) 
    local arg = { ... } 
    if (arg[1]) then 
        for key, value in next, arg do arg[key] = tonumber(value) or value end 
    end 
    loadstring("return "..funcname)()(unpack(arg)) 
end 
addEvent("onClientCallsServerFunction", true) 
addEventHandler("onClientCallsServerFunction", resourceRoot , callServerFunction) 
  
function updatePlayerLogin( ) 
    local account = getPlayerAccount( source ) 
        red = getAccountData(account,"firstRed") 
        green = getAccountData(account,"firstGreen") 
        blue = getAccountData(account,"firstBlue") 
        local PVeh = getPedOccupiedVehicle(source) 
        setVehicleColor(PVeh,red,green,blue) 
end 
  
addEventHandler("onPlayerLogin", getRootElement(),updatePlayerLogin) 

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 (edited)
function buyCarColor(thePlayer,red,green,blue) 
    local account = getPlayerAccount(thePlayer) 
    if not (isGuestAccount(account)) then 
            setAccountData(account,"firstRed",red) 
            setAccountData(account,"firstGreen",green) 
            setAccountData(account,"firstBlue",blue) 
            outputChatBox("#00ff00[sHOP] #ffffff---!",thePlayer,255,255,255,true) 
            local PVeh = getPedOccupiedVehicle(thePlayer) 
            setVehicleColor(PVeh,red,green,blue) 
        end 
    end 
  
function callClientFunction(client, funcname, ...) 
    local arg = { ... } 
    if (arg[1]) then 
        for key, value in next, arg do 
            if (type(value) == "number") then arg[key] = tostring(value) end 
        end 
    end 
    -- If the clientside event handler is not in the same resource, replace 'resourceRoot' with the appropriate element 
    triggerClientEvent(client, "onServerCallsClientFunction", resourceRoot, funcname, unpack(arg or {})) 
end 
  
  
function callServerFunction(funcname, ...) 
    local arg = { ... } 
    if (arg[1]) then 
        for key, value in next, arg do arg[key] = tonumber(value) or value end 
    end 
    loadstring("return "..funcname)()(unpack(arg)) 
end 
addEvent("onClientCallsServerFunction", true) 
addEventHandler("onClientCallsServerFunction", resourceRoot , callServerFunction) 
  
function updatePlayerLogin( ) 
    local account = getPlayerAccount( source ) 
        red = getAccountData(account,"firstRed") 
        green = getAccountData(account,"firstGreen") 
        blue = getAccountData(account,"firstBlue") 
        local PVeh = getPedOccupiedVehicle(source) 
        setVehicleColor(PVeh,red,green,blue) 
end 
  
addEventHandler("onPlayerLogin", getRootElement(),updatePlayerLogin) 

OHHHHHHHhhhhhhhhhhhhhhhhhhhhhhh

Castillo thank you, thank you even needed that!!!

Edited by Guest

........... \__ ▄▂_

.........[█|||███████]▄▄▄▄▄▄▄▄▄▃▂

..__▂▄▅█████████▅▄▃▂

I███████████████████]

...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

░░░███████ ]▄▄▄▄▄▄▄▄

▂▄▅████████▅▄▃▂

I███████████████████]

◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

Posted

is possible to use the event

addEventHandler("onMapStarting", getRootElement(),updatePlayerLogin) 

:?::?:

........... \__ ▄▂_

.........[█|||███████]▄▄▄▄▄▄▄▄▄▃▂

..__▂▄▅█████████▅▄▃▂

I███████████████████]

...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

░░░███████ ]▄▄▄▄▄▄▄▄

▂▄▅████████▅▄▃▂

I███████████████████]

◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

Posted

Not alone, because it doesn't have a player element.

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

ok, I'll find another way :|

........... \__ ▄▂_

.........[█|||███████]▄▄▄▄▄▄▄▄▄▃▂

..__▂▄▅█████████▅▄▃▂

I███████████████████]

...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

░░░███████ ]▄▄▄▄▄▄▄▄

▂▄▅████████▅▄▃▂

I███████████████████]

◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

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