1LoL1 Posted January 29, 2016 Share Posted January 29, 2016 (edited) Hello, is possible 3x getElementData in 1x getElementData? i mean this: local r = getElementData(source, "r") local g = getElementData(source, "g") local b = getElementData(source, "b") local all = getElementData(source, "all", r, g, b) When i go this i have this Error: Bad argument @ 'getElementData' [Expected bool at argument 3, got number '0']. Edited February 4, 2016 by Guest Link to comment
tosfera Posted January 29, 2016 Share Posted January 29, 2016 Yes, you just have to save the table in there like so; setElementData ( source, "all", { r, g, b } ); later on you can use; local all = getElementData ( source, "all" ); local r, g, b = unpack ( all ); Link to comment
1LoL1 Posted January 29, 2016 Author Share Posted January 29, 2016 Yes, you just have to save the table in there like so; setElementData ( source, "all", { r, g, b } ); later on you can use; local all = getElementData ( source, "all" ); local r, g, b = unpack ( all ); When i want use getElementData i have this warning: Bad argument @ 'getElementData' [Expected bool at argument 3, got number '0'] local all = getElementData(source, "all") local r, g, b = unpack(all) local wtf = r, g, b local ttt = getElementData(source, "all", wtf) Link to comment
1LoL1 Posted January 29, 2016 Author Share Posted January 29, 2016 ok i have now this: setElementData(player, "all", ""..r..", "..g..", "..b.."") -- Work and this too: local all = getElementData(source, "all") -- Work and here too: local all = getElementData(player, "all") local r, g, b = unpack(tostring(all)) setVehicleHeadLightColor(source, r, g, b) Link to comment
tosfera Posted January 30, 2016 Share Posted January 30, 2016 Oh that's right, unpack is used for a string, not a table. My bad ^^ Link to comment
1LoL1 Posted January 30, 2016 Author Share Posted January 30, 2016 Oh that's right, unpack is used for a string, not a table. My bad ^^ So how i can fix? Link to comment
1LoL1 Posted January 30, 2016 Author Share Posted January 30, 2016 Oh that's right, unpack is used for a string, not a table. My bad ^^ So how i can fix? Please anyone? Link to comment
ALw7sH Posted January 30, 2016 Share Posted January 30, 2016 Oh that's right, unpack is used for a string, not a table. My bad ^^ It's for tables not string Link to comment
1LoL1 Posted January 30, 2016 Author Share Posted January 30, 2016 Please anyone tell me if this is possible Link to comment
ViRuZGamiing Posted January 30, 2016 Share Posted January 30, 2016 local all = getElementData(source, "all") local r, g, b = unpack(all) local wtf = r, g, b local ttt = getElementData(source, "all", wtf) That error you got: Bad argument @ 'getElementData' [Expected bool at argument 3, got number '0'] That was because of your last line 'getElementData', getElementData only needs the element and the data. (source and "all") Where you do have to use 3 parameters are with SET (setElementData(source, "all", colors) For example; addEventHandler("onMarkerHit", markerName, function() local r, g, b = getVehicleColor(vehicle, true) setElementData(vehicle, "color", {r, g, b}) end) -- and later on addEventHandler("onMarkerHit", marker2Name, function() local x, y, z = unpack(getElementData(vehicle, "color") setVehicleColor(vehicle, x, y, z) end) If i'm right at least, btw it's just a random example. Link to comment
ALw7sH Posted January 31, 2016 Share Posted January 31, 2016 Use toJSON fromJSON He don't need to set/get-Elementdata does store tables unlike set/get-accountData ViRuZGamiing example is what he should do, btw there's a missing ")" on line 8 Link to comment
KariiiM Posted January 31, 2016 Share Posted January 31, 2016 He don't need to Nice to know that Link to comment
1LoL1 Posted January 31, 2016 Author Share Posted January 31, 2016 local all = getElementData(source, "all") local r, g, b = unpack(all) local wtf = r, g, b local ttt = getElementData(source, "all", wtf) That error you got: Bad argument @ 'getElementData' [Expected bool at argument 3, got number '0'] That was because of your last line 'getElementData', getElementData only needs the element and the data. (source and "all") Where you do have to use 3 parameters are with SET (setElementData(source, "all", colors) For example; addEventHandler("onMarkerHit", markerName, function() local r, g, b = getVehicleColor(vehicle, true) setElementData(vehicle, "color", {r, g, b}) end) -- and later on addEventHandler("onMarkerHit", marker2Name, function() local x, y, z = unpack(getElementData(vehicle, "color") setVehicleColor(vehicle, x, y, z) end) If i'm right at least, btw it's just a random example. Not work Bad argument #1 to 'unpack' (table expected, got string) i think i need this local r, g, b = {r, g, b} Link to comment
ViRuZGamiing Posted January 31, 2016 Share Posted January 31, 2016 did you Add the missing ')' on line 8? that was my bad Link to comment
1LoL1 Posted January 31, 2016 Author Share Posted January 31, 2016 did you Add the missing ')' on line 8? that was my bad Yes it is added. Link to comment
ALw7sH Posted January 31, 2016 Share Posted January 31, 2016 did you Add the missing ')' on line 8? that was my bad Yes it is added. Where's your full code? we cant help you without your code Link to comment
1LoL1 Posted January 31, 2016 Author Share Posted January 31, 2016 did you Add the missing ')' on line 8? that was my bad Yes it is added. Where's your full code? we cant help you without your code Don't needed full code.. i want only example how i can 3x getElementData in 1x getElementData. Link to comment
ALw7sH Posted January 31, 2016 Share Posted January 31, 2016 They did gave you not one example but two and you're still giving us some weird errors? Link to comment
1LoL1 Posted January 31, 2016 Author Share Posted January 31, 2016 They did gave you not one example but twoand you're still giving us some weird errors? Errors is in this examples.. Link to comment
ViRuZGamiing Posted January 31, 2016 Share Posted January 31, 2016 Show us your code that's the way we can help. I think the problem will be somewhere around your r,g,b declaration/setElementData. Link to comment
1LoL1 Posted January 31, 2016 Author Share Posted January 31, 2016 Show us your code that's the way we can help. I think the problem will be somewhere around your r,g,b declaration/setElementData. Don't needed full code can be this: setElementData(sorce, "all", r,g,b) addEventHandler("onVehicleEnter", getRootElement(), function (player) local r, g, b = getElementData(player, "all") local r, g, b = unpack(r, g, b) setVehicleHeadLightColor(source, r, g, b) end end) Link to comment
ViRuZGamiing Posted January 31, 2016 Share Posted January 31, 2016 setElementData(sorce, "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) If this doesn't work, let me see the setElementData function because I don't know what the source is right now. Link to comment
ALw7sH Posted January 31, 2016 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}) Link to comment
ViRuZGamiing Posted January 31, 2016 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) 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