1LoL1 Posted January 31, 2016 Author Share Posted January 31, 2016 Who's "source" or "sorce"and setElementData(sorce, "all", r,g,b) should be setElementData(sorce, "all", {r,g,b}) Yeah I looked over the table in setElementData setElementData(source, "all", {r,g,b}) -- this has to be source instead of sorce probably addEventHandler("onVehicleEnter", getRootElement(), function (player) local colors = getElementData(player, "all") -- by calling it r, g, b you use 3 variables but the table only needs 1 local r, g, b = unpack(colors) -- here you go from 1 table to 3 variables setVehicleHeadLightColor(source, r, g, b) end) When i use your code i have this error: bad argument #1 to 'unpack' (table expected, got nil) addCommandHandler("colors", function (source) local colors = getElementData(source, "all") local r, g, b = unpack(color) outputChatBox("Colors: "..r..", "..g..", "..b.."", source, 255, 255, 255, true) end) Link to comment
ViRuZGamiing Posted January 31, 2016 Share Posted January 31, 2016 You keep changing your code just show the ENTIRE code. It's not like we're about to steal it because we can write it as well. function (source) has to be function () (if this is client sided) Else you make source = commandName let me see the setElementData function because I don't know what the source is right now. Link to comment
1LoL1 Posted January 31, 2016 Author Share Posted January 31, 2016 You keep changing your code just show the ENTIRE code. It's not like we're about to steal it because we can write it as well.function (source) has to be function () (if this is client sided) Else you make source = commandName let me see the setElementData function because I don't know what the source is right now. What? this is server-side. And this is next code i want only know how color i have. Link to comment
ViRuZGamiing Posted January 31, 2016 Share Posted January 31, 2016 Well I'll help you if I see the entire deal, I have no idea right know what you are trying to do. The example is correct. Link to comment
1LoL1 Posted January 31, 2016 Author Share Posted January 31, 2016 Well I'll help you if I see the entire deal, I have no idea right know what you are trying to do. The example is correct. Now i'am trying to save. This save work normally: local r = getElementData(source, "r") local g = getElementData(source, "g") local b = getElementData(source, "b") dbExec(db, "INSERT INTO RGB (Name, Account, RGB) VALUES (?, ?, ?)", name, account, ""..r..", "..g..", "..b.."" When i want load RGB values not work idk how to: setElementData(source, "RGB", poll[1]["RGB"]) Link to comment
ViRuZGamiing Posted January 31, 2016 Share Posted January 31, 2016 Still not seeing the FULL thing. What is source? what is poll (probably dbPoll)? what is it's 1st value? ... Link to comment
1LoL1 Posted January 31, 2016 Author Share Posted January 31, 2016 Still not seeing the FULL thing. What is source? what is poll (probably dbPoll)? what is it's 1st value? ... source = Player poll = dbPoll 1st value = This is what i said on start topic. Link to comment
Bonus Posted February 2, 2016 Share Posted February 2, 2016 Show us how you are using poll. Although you could open your database and look if it saved. Link to comment
ViRuZGamiing Posted February 3, 2016 Share Posted February 3, 2016 Show us how you are using poll.Although you could open your database and look if it saved. he's not planning on showing the code this is all we get to fix it. I've tried speaking to him but hé only wants to do it in skype. Link to comment
1LoL1 Posted February 3, 2016 Author Share Posted February 3, 2016 Show us how you are using poll.Although you could open your database and look if it saved. he's not planning on showing the code this is all we get to fix it. I've tried speaking to him but hé only wants to do it in skype. Yes because you want full code. And i can't share full code because there i have save system. Link to comment
Bonus Posted February 3, 2016 Share Posted February 3, 2016 Then try it and look into database if it got saved. Link to comment
1LoL1 Posted February 3, 2016 Author Share Posted February 3, 2016 Then try it and look into database if it got saved. Save working normally i need only load of database. Link to comment
KariiiM Posted February 3, 2016 Share Posted February 3, 2016 Yes because you want full code. And i can't share full code because there i have save system. So how it's going? Link to comment
Bonus Posted February 3, 2016 Share Posted February 3, 2016 We cant see how you are loading. How can you expect us to know where the problem is? Link to comment
1LoL1 Posted February 3, 2016 Author Share Posted February 3, 2016 We cant see how you are loading.How can you expect us to know where the problem is? Here: local r = getElementData(source, "r") local g = getElementData(source, "g") local b = getElementData(source, "b") dbExec(db, "INSERT INTO RGB (Name, Account, RGB) VALUES (?, ?, ?)", name, account, ""..r..", "..g..", "..b.."") in database is "255, 255, 255" But idk how i can load 3x getElementData to 1x getElementData function loadd (source) local account = getAccountName(source) local result = dbQuery ( database ,"SELECT * FROM RGB WHERE Account = ?", account) local poll, rows = dbPoll(result, -1) if rows == 1 then setElementData(source, "RGB", poll[1]["HERE IDK HOW"]) end end addEventHandler("onPlayerLogin", getRootElement(), loadd) because i want use it to Vehicle Lights and there i need r, g, b. Link to comment
ViRuZGamiing Posted February 3, 2016 Share Posted February 3, 2016 function loadd (source) local account = getAccountName(source) local query = dbQuery ( database ,"SELECT * FROM RGB WHERE Account = ?", account) local result = dbPoll(query, -1) if result then for _, row in ipairs (result) do -- here you can use row or get the column: row["column"] or use a 2nd loop for the column end end end addEventHandler("onPlayerLogin", getRootElement(), loadd) If I'm right tho Link to comment
1LoL1 Posted February 3, 2016 Author Share Posted February 3, 2016 function loadd (source) local account = getAccountName(source) local query = dbQuery ( database ,"SELECT * FROM RGB WHERE Account = ?", account) local result = dbPoll(query, -1) if result then for _, row in ipairs (result) do -- here you can use row or get the column: row["column"] or use a 2nd loop for the column end end end addEventHandler("onPlayerLogin", getRootElement(), loadd) If I'm right tho I don't understand this -- here you can use row or get the column: row["column"] or use a 2nd loop for the column Link to comment
ViRuZGamiing Posted February 3, 2016 Share Posted February 3, 2016 You were trying to do something with your rows but didn't access them right. What exactly are you trying to do? what is your script's idea? I also don't know how your table is build up. Link to comment
1LoL1 Posted February 3, 2016 Author Share Posted February 3, 2016 You were trying to do something with your rows but didn't access them right. What exactly are you trying to do? what is your script's idea? I also don't know how your table is build up. ??? i don't know what do you mean with row["column"] mean row["1"] ? Link to comment
Bonus Posted February 3, 2016 Share Posted February 3, 2016 function loadd (_, acc) local account = getAccountName(acc) local result = dbQuery ( database ,"SELECT RGB FROM RGB WHERE Account = ?", account) local poll = dbPoll(result, -1) if poll and poll[1] then setElementData(source, "RGB", poll[1]["RGB"]) end end addEventHandler("onPlayerLogin", getRootElement(), loadd) Try that ... onPlayerLogin gives you 3 arguments: The first is the previous acc, the second is the current acc and the third is a boolean for auto-login. You used the first argument, the previous acc. But I think you want to get the RGB for the current acc, not previous. Then you used source for the source (player) and for the previous acc. That can't work Link to comment
1LoL1 Posted February 4, 2016 Author Share Posted February 4, 2016 function loadd (_, acc) local account = getAccountName(acc) local result = dbQuery ( database ,"SELECT RGB FROM RGB WHERE Account = ?", account) local poll = dbPoll(result, -1) if poll and poll[1] then setElementData(source, "RGB", poll[1]["RGB"]) end end addEventHandler("onPlayerLogin", getRootElement(), loadd) Try that ... onPlayerLogin gives you 3 arguments: The first is the previous acc, the second is the current acc and the third is a boolean for auto-login. You used the first argument, the previous acc. But I think you want to get the RGB for the current acc, not previous. Then you used source for the source (player) and for the previous acc. That can't work Now in database is "255, 255, 255" but when i go setElementData(source, "RGB" its 3 in 1. So now how i can get to Car Lights??? Example: local w = {255,255,255} r = w[1] g = w[2] b = w[3] and lights will normally r, g, b Link to comment
Bonus Posted February 4, 2016 Share Posted February 4, 2016 Use gettok: https://wiki.multitheftauto.com/wiki/Gettok Link to comment
1LoL1 Posted February 4, 2016 Author Share Posted February 4, 2016 Use gettok:https://wiki.multitheftauto.com/wiki/Gettok Pff i really don't know this function so i don't know how i can use in this my code. Link to comment
Bonus Posted February 4, 2016 Share Posted February 4, 2016 And I sent you a link where its described very well. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now