Joaovit13 Posted February 9, 2021 Share Posted February 9, 2021 marker_aleatoriosS = { 1872.08, -1308.8, 18.147, 1893.097, -1314.732, 23.151, 1892.831, -1316.274, 28.152, 1872.101, -1317.594, 33.147, 1876.034, -1321.604, 38.147, 1876.088, -1309.743, 43.147, 1873.865, -1322.412, 48.069, --Para não pegar repetido 1872.08, -1308.8, 18.147, 1893.097, -1314.732, 23.151, 1892.831, -1316.274, 28.152, 1872.101, -1317.594, 33.147, 1876.034, -1321.604, 38.147, 1876.088, -1309.743, 43.147, 1873.865, -1322.412, 48.069, } Object_ferro = {} marker_EntregarS = {} --ID do objeto barra de ferro 2960 function pegarFerroS(player,cmd) local x, y, z = getElementPosition(marker_ferro) local Random_Pos = math.random(#marker_aleatoriosS) if not isPedInVehicle(player) then if isElementWithinMarker(player, marker_ferro) then if getElementData(player, "Ferro") == false then if getElementData(player, "Pedreiro") == true then setPedAnimation(player, "CARRY", "liftup", 1.0, false) setTimer(function() if isElement(Object_ferro[player]) then destroyElement(Object_ferro[player]) end if isElement(marker_EntregarS[player]) then destroyElement(marker_EntregarS) end setElementData(player, "Recompensa", 0) setPedAnimation(player, nil) setElementData(player, "Ferro", true) toggleControl(player, "jump", false) toggleControl(player, "fire", false) toggleControl(player, "aim_weapon", false) setPedAnimation( player, "CARRY", "crry_prtial", 4.1, true, true, true ) marker_EntregarS[player] = createMarker ( marker_aleatoriosS[Random_Pos][1], marker_aleatoriosS[Random_Pos][2], marker_aleatoriosS[Random_Pos][3] -2.2, "cylinder", 2.5, 16, 111, 231, 50) setElementVisibleTo(marker_EntregarS, root, false) setElementVisibleTo(marker_EntregarS, player, true) addEventHandler("onMarkerHit", marker_EntregarS[player], fim_Emprego) Object_ferro[player] = createObject(2960, x, y, z) exports.bone_attach:attachElementToBone(Object_ferro[player], player, 4, 0, 0.4, - 0.6, -90, 0, 0 ) end, 1000,1) end end end end end addCommandHandler("ferro", pegarFerroS) Essa função está retornando erro no createMarker attemp to index upvalue 'Random_Pos' <a number value> não encontrei aonde está meu erro. Link to comment
Other Languages Moderators androksi Posted February 9, 2021 Other Languages Moderators Share Posted February 9, 2021 A maneira na qual você organizou a sua tabela, está errada. Todos os elementos devem estar, também, dentro de chaves. 1 Link to comment
LucasST Posted February 10, 2021 Share Posted February 10, 2021 marker_aleatoriosS = { {1872.08, -1308.8, 18.147}, {1893.097, -1314.732, 23.151}, {1892.831, -1316.274, 28.152}, {1872.101, -1317.594, 33.147}, {1876.034, -1321.604, 38.147}, {1876.088, -1309.743, 43.147}, {1873.865, -1322.412, 48.069}, --Para não pegar repetido {1872.08, -1308.8, 18.147}, {1893.097, -1314.732, 23.151}, {1892.831, -1316.274, 28.152}, {1872.101, -1317.594, 33.147}, {1876.034, -1321.604, 38.147}, {1876.088, -1309.743, 43.147}, {1873.865, -1322.412, 48.069}, } Object_ferro = {} marker_EntregarS = {} --ID do objeto barra de ferro 2960 function pegarFerroS(player,cmd) local x, y, z = getElementPosition(marker_ferro) local Random_Pos = math.random(#marker_aleatoriosS) if not isPedInVehicle(player) then if isElementWithinMarker(player, marker_ferro) then if getElementData(player, "Ferro") == false then if getElementData(player, "Pedreiro") == true then setPedAnimation(player, "CARRY", "liftup", 1.0, false) setTimer(function() if isElement(Object_ferro[player]) then destroyElement(Object_ferro[player]) end if isElement(marker_EntregarS[player]) then destroyElement(marker_EntregarS) end setElementData(player, "Recompensa", 0) setPedAnimation(player, nil) setElementData(player, "Ferro", true) toggleControl(player, "jump", false) toggleControl(player, "fire", false) toggleControl(player, "aim_weapon", false) setPedAnimation( player, "CARRY", "crry_prtial", 4.1, true, true, true ) marker_EntregarS[player] = createMarker ( marker_aleatoriosS[Random_Pos][1], marker_aleatoriosS[Random_Pos][2], marker_aleatoriosS[Random_Pos][3] -2.2, "cylinder", 2.5, 16, 111, 231, 50) setElementVisibleTo(marker_EntregarS, root, false) setElementVisibleTo(marker_EntregarS, player, true) addEventHandler("onMarkerHit", marker_EntregarS[player], fim_Emprego) Object_ferro[player] = createObject(2960, x, y, z) exports.bone_attach:attachElementToBone(Object_ferro[player], player, 4, 0, 0.4, - 0.6, -90, 0, 0 ) end, 1000,1) end end end end end addCommandHandler("ferro", pegarFerroS) Sua maneira de tabela estava incorreta, estava pegando a index de uma tabela como essa. {1872.08, -1308.8, 18.147,1893.097, -1314.732, 23.151} 1 Link to comment
Joaovit13 Posted February 10, 2021 Author Share Posted February 10, 2021 Puts, muito obrigado pessoal! 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