Guest Posted September 10, 2012 Share Posted September 10, 2012 (edited) Hello ! I have problem with my system packages (again). Error: Attempt to concatenate global 'id2' (a boolean value). Edited November 8, 2014 by Guest Link to comment
Kenix Posted September 10, 2012 Share Posted September 10, 2012 (edited) Variable id2 is boolean, not number, because setElementData function return boolean. Read arguments on wiki before post something! Use getElementData function if you want get data. Also If you want boolean value convert to string use tostring function. Edited September 10, 2012 by Guest Link to comment
TAPL Posted September 10, 2012 Share Posted September 10, 2012 and please next time use lua button not Code. EDIT: is your code client-side or server-side? if it client side outputChatBox in client-side does not need player argument. btw: player argument here does not look defined. outputChatBox("Załadowałeś trociny!", player) if it server-side outputChatBox in server-side need player argument. outputChatBox("Id: " .. id .. "Id 2: " .. id2, 0, 255, 0) Link to comment
Guest Posted September 10, 2012 Share Posted September 10, 2012 If i use "getElementData": (this is client script) function towarTrociny() dest = markers[math.random(1, #markers)] if towar == 0 then towar = 1 outputChatBox("Załadowałeś trociny!", player) destblip = createBlip( dest[1], dest[2], dest[3], 41, 2, 255, 255, 0, 0, 100) setElementData(source, "id2", dest[4]) id2 = getElementData(source, "id2") outputChatBox("Id: " .. id .. "Id 2: " .. id2, 0, 255, 0) else outputChatBox("Aby załadować ten towar musisz mieć minimum 0 punktów!", 0, 255, 0) end end Error: Attempt to concatenate global 'id2' (a nil value). Sorry... Link to comment
TAPL Posted September 10, 2012 Share Posted September 10, 2012 I can't see where is id define. Since it client-side, Mostly you should use localPlayer Instead of source. Otherwise, post full code, includes the event you're using and the Table (markers). Link to comment
Guest Posted September 10, 2012 Share Posted September 10, 2012 -- Współrzędne: x, y, z local markers = { { -1725, -121, 2 }, {-1854, 1402, 6.1}, {-2282, 2278, 4,5}, {-367, 1547, 75,1}, {345, 2534, 16,2}, {1641, 2412, 10}, {-2887, 503, 4}, {-1515, 721, 6}, {-683, 965, 12}, {948, 2279, 11}, {1488, 2146, 10}, {1910, 2157, 10}, {2242, 1977, 9}, {-658, 2318, 138}, {-2054, -2565, 30}, {-1416, -1468, 101}, {-605, -483, 25}, {-55, -326, 5}, {1077, -307, 75}, {-2644, 1334, 7}, {2481, 2796, 10}, {-857, -1944, 15}, {-87, -1574, 2}, {-2264, -1688, 480}, { -2029.1010742188, 172.45364379883, 27.35425567627 } } source = getLocalPlayer() local towar = 0 -- Tworzenie markerów i blipów oraz inicjowanie ich for k, v in ipairs (markers) do destmarker = createMarker(v[1], v[2], v[3], "cylinder", 3, 255, 255, 0, 255) setElementData(destmarker, "id", v[4]) id = getElementData(destmarker, "id") createBlip(v[1],v[2],v[3], 51) end -- Funkcja rozładunek function rozladunek(source) for b, tow in ipairs (pack) do if towar == b and id == id2 then triggerServerEvent("punkty", localPlayer, points) towar = 0 rmoney = math.random(tow[4],tow[5]) triggerServerEvent("kasa", localPlayer, rmoney) outputChatBox("Rozładowałeś: " .. tow[2], player) destroyElement(destblip) else outputChatBox("To nie jest ten rozładunek!", 0, 255, 0) end end end -- Funkcje załadunków function towarTrociny() dest = markers[math.random(1, #markers)] if towar == 0 then towar = 1 outputChatBox("Załadowałeś trociny!", player) destblip = createBlip( dest[1], dest[2], dest[3], 41, 2, 255, 255, 0, 0, 100) setElementData(source, "id2", dest[4]) id2 = getElementData(source, "id2") outputChatBox("Id: " .. id .. "Id 2: " .. id2, player, 0, 255, 0) else outputChatBox("Aby załadować ten towar musisz mieć minimum 0 punktów!", 0, 255, 0) end end Link to comment
TAPL Posted September 10, 2012 Share Posted September 10, 2012 The rows in the table has only 3 values, that means dest[4] and v[4] is nil. line 39, make no sense, it will overwrite. and there are others errors. Link to comment
Guest Posted September 10, 2012 Share Posted September 10, 2012 But "setElementData(destmarker, "id", v[4])" make v[4]. If you can please ready code. Link to comment
Castillo Posted September 10, 2012 Share Posted September 10, 2012 When is "towarTrociny" function executed? Link to comment
myonlake Posted September 11, 2012 Share Posted September 11, 2012 Why are you using globals in the first place. Link to comment
Guest Posted September 11, 2012 Share Posted September 11, 2012 I don't know. I can't good programing in lua. Please help. Link to comment
Kenix Posted September 11, 2012 Share Posted September 11, 2012 I don't know. I can't good programing in lua. Please help. viewtopic.php?f=148&t=40809 Link to comment
Guest Posted September 12, 2012 Share Posted September 12, 2012 Websites do not help me, especially because there is no one solution to any errors. Link to comment
Guest Posted September 15, 2012 Share Posted September 15, 2012 Client: for k, v in ipairs (markers) do destmarker = createMarker(v[1], v[2], v[3], "cylinder", 3, 255, 255, 0, 255) createBlip(v[1],v[2],v[3], 51) setElementData(destmarker, "id", v[4]) end function towarTrociny() dest = markers[math.random(1, #markers)] if towar == 0 then towar = 1 outputChatBox("Załadowałeś trociny!", player) destblip = createBlip( dest[1], dest[2], dest[3], 41, 2, 255, 255, 0, 0, 100) setElementData(source, "id2", dest[4]) else outputChatBox("Aby załadować ten towar musisz mieć minimum 0 punktów!", player, 0, 255, 0) end end Server: function rozladunek(source) local x1, y1, z1 = getMarkerTarget(source) local x2, y2, z2 = getMarkerTarget(blipmarker) for b, tow in ipairs (pack) do if towar == b and x1 == x2 and y1 == y2 then setElementData(getLocalPlayer(),"points",tonumber(points + 1)) towar = 0 rmoney = math.random(tow[4],tow[5]) givePlayerMoney( source, tonumber(rmoney)) outputChatBox("Rozładowałeś: " .. tow[2], player) destroyElement(destblip) else outputChatBox("To nie jest ten rozładunek!", player, 0, 255, 0) end end end addEventHandler("rozl", getRootElement(), rozladunek) Why can i unload the goods in all the markers? Error: Bad argument @ 'getMarkerTarget' 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