1LoL1 Posted January 29, 2016 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
tosfera Posted January 29, 2016 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 );
1LoL1 Posted January 29, 2016 Author 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)
1LoL1 Posted January 29, 2016 Author 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)
tosfera Posted January 30, 2016 Posted January 30, 2016 Oh that's right, unpack is used for a string, not a table. My bad ^^
1LoL1 Posted January 30, 2016 Author Posted January 30, 2016 Oh that's right, unpack is used for a string, not a table. My bad ^^ So how i can fix?
1LoL1 Posted January 30, 2016 Author 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?
ALw7sH Posted January 30, 2016 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
1LoL1 Posted January 30, 2016 Author Posted January 30, 2016 Please anyone tell me if this is possible
ViRuZGamiing Posted January 30, 2016 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.
ALw7sH Posted January 31, 2016 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
1LoL1 Posted January 31, 2016 Author 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}
ViRuZGamiing Posted January 31, 2016 Posted January 31, 2016 did you Add the missing ')' on line 8? that was my bad
1LoL1 Posted January 31, 2016 Author Posted January 31, 2016 did you Add the missing ')' on line 8? that was my bad Yes it is added.
ALw7sH Posted January 31, 2016 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
1LoL1 Posted January 31, 2016 Author 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.
ALw7sH Posted January 31, 2016 Posted January 31, 2016 They did gave you not one example but two and you're still giving us some weird errors?
1LoL1 Posted January 31, 2016 Author 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..
ViRuZGamiing Posted January 31, 2016 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.
1LoL1 Posted January 31, 2016 Author 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)
ViRuZGamiing Posted January 31, 2016 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.
ALw7sH Posted January 31, 2016 Posted January 31, 2016 Who's "source" or "sorce" and setElementData(sorce, "all", r,g,b) should be setElementData(sorce, "all", {r,g,b})
ViRuZGamiing Posted January 31, 2016 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)
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