slau Posted June 2, 2021 Posted June 2, 2021 gostaria de saber como que pego os player proximo a mim num certo raio, não sei se existe alguma função que faz isso automaticamente, tipo getNereastElement() algo do tipo.
Discord Moderators Tut Posted June 2, 2021 Discord Moderators Posted June 2, 2021 Your thread has been moved into the Portuguese scripting section!
Other Languages Moderators androksi Posted June 2, 2021 Other Languages Moderators Posted June 2, 2021 (edited) Olá. Você pode usar a função getElementsWithinRange. É retornado uma tabela com todos os elementos. Exemplo: -- Server-side addCommandHandler("pradius", function(player, cmd, radius) radius = tonumber(radius) or 5 -- Caso "radius" seja inválido, teremos o valor 5 como padrão local x, y, z = getElementPosition(player) local playersInRadius = getElementsWithinRange(x, y, z, radius, "player") -- Iremos pegar tudo o que é "player", ou seja, jogador if #playersInRadius == 0 then -- Caso não haja jogadores no raio especificado, então mostraremos a mensagem de erro: return outputChatBox("Não há jogadores num raio de " .. radius .. " metros.", player, 255, 45, 45) end for index, element in pairs(playersInRadius) do outputChatBox(getPlayerName(element) .. " está num raio de " .. radius .. " metros perto de você!", player, 45, 255, 45) end end) -- Comando: /pradius <raio> -- Exemplo: /pradius 200 Edited June 2, 2021 by andr0xy
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