wesssley Posted March 3, 2023 Posted March 3, 2023 (edited) Estou tendo que copiar e colar várias vezes o mesmo código para mudar somente a posição, como faço para criar apenas uma tabela onde ficaria todos os markers sem ter que copiar e colar o código direto? Tenho o seguinte código pegarT = createMarker(-2409.32764, -600.28540, 132.64844 -1, "cylinder", 1.1,255,255,255,50) -- Marker Policial createPickup(-2409.32764, -600.28540, 132.64844 , 3, 1247, 1) ------------------------------------------ function salariopm(player) -- Policial if isElementWithinMarker(player, pegarT) then if isObjectInACLGroup ( "user." ..getAccountName(getPlayerAccount(player)), aclGetGroup ( Grupo1 )) then if getElementData(player, "TrabalhoPolicial") then setElementData(player, "TrabalhoPolicial", false) outputChatBox("Você #ff0000saiu #009affde serviço!", player, 0, 154, 255, true) setElementModel(player, 0) else setElementData(player, "TrabalhoPolicial", true) outputChatBox("Você #006effentrou #009affem serviço, bom trabalho!", player, 0, 154, 255, true) setElementModel(player, 283) end else outputChatBox("Você não tem permissão para isso.", source, 255,0,0, true) end end end addCommandHandler("trabalhar", salariopm) -------------------------------------------- MENSAGEM MARKER POLICIAL addEventHandler("onMarkerHit", pegarT, function(player) if getElementType(player) == "player" then outputChatBox(" ", player, 255,255,255, true) outputChatBox("Para começar a trabalhar, digite #ffff00/trabalhar ", player, 255,255,255, true) outputChatBox(" ", player, 255,255,255, true) end end) Edited March 3, 2023 by wesssley
Doongogar Posted March 4, 2023 Posted March 4, 2023 MarkCoords = { {x, y, z}, {x, y, z}, {x, y, z}, } Markers = {} Markers = createMarker(MarkCoords[i][1], MarkCoords[i][2], MarkCoords[i][3], "cylinder", 1.1, 255, 255, 255, 100) cara não tenho certeza, mas acho que e mais ou menos assim 1
Other Languages Moderators Lord Henry Posted March 6, 2023 Other Languages Moderators Posted March 6, 2023 local markCoords = { {x, y, z}, -- Troque o x, y, z pela posição x, y, z do marker {x, y, z}, -- Faça o mesmo no segundo marker. {x, y, z}, -- E assim por diante. } local markers = {} -- Tabela vazia, onde os markers ficarão ao serem criados. for i, item in ipairs (markCoords) do -- Para cada item da tabela markCoords, faça: local x, y, z = unpack(item) -- x, y, z recebem a posição do item da tabela markCoords. markers[i] = createMarker(x, y, z, "cylinder", 1.1, 255, 255, 255, 50) -- Cria o marker nessa posição e coloca ele na tabela markers. end addEventHandler("onMarkerHit", resourceRoot, function(hitElement) -- Faz com que essa função só ative para markers criados neste resource. if getElementType(hitElement) == "player" then outputChatBox(" ", hitElement) -- Textos vazios não precisam de parâmetros de cor. outputChatBox("Para começar a trabalhar, digite #ffff00/trabalhar ", hitElement, 255, 255, 255, true) outputChatBox(" ", hitElement) end end) function salariopm(thePlayer) -- Policial. for i, marker in ipairs (markers) do -- Para cada marker da tabela markers, faça: if isElementWithinMarker(thePlayer, marker) then -- Se o jogador está dentro desse marker, então: if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup(Grupo1)) then -- Grupo1 dará erro se você não declarar essa variável antes em algum lugar. if getElementData(thePlayer, "TrabalhoPolicial") then setElementData(thePlayer, "TrabalhoPolicial", false) outputChatBox("Você #ff0000saiu #009affde serviço!", thePlayer, 0, 154, 255, true) setElementModel(thePlayer, 0) else setElementData(thePlayer, "TrabalhoPolicial", true) outputChatBox("Você #006effentrou #009affem serviço, bom trabalho!", thePlayer, 0, 154, 255, true) setElementModel(thePlayer, 283) end else outputChatBox("Você não tem permissão para isso.", thePlayer, 255, 0, 0, true) end break -- Sai do loop pois já encontrou o marker em que o jogador está. end end end addCommandHandler("trabalhar", salariopm) 1
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