Jump to content

getDistanceBetweenPoints2D


LucasBaker

Recommended Posts

Posted
function darVida (M, T) 
if T == 1 then 
local PlayersP = getElementByType("player")) 
for _,Pl in ipairs(PlayersP) do 
local x,y,z = getElementPosition(Pl) 
local x2,y2,z2 = getElementPosition(source) 
local Distance = getDistanceBetweenPoints2D ( x,y, x2,y2 ) 
if (Distance <= 10) then 
setElementHealth(100, Pl) 
outputChatBox ( "Você recebeu vida", Pl ) 
end 
end 
end 
end 
addCommandHandler ( "darvida", darVida ) 

the script would be to give life to those who have a distance of 10 but nothing happens, what error?

Posted
function darVida(M, _, T) 
    if T == "1" then 
        local x1, y1 = getElementPosition(M) 
        for _,Pl in ipairs(getElementsByType("player")) do 
            local x2, y2 = getElementPosition(Pl) 
            local Distance = getDistanceBetweenPoints2D(x1, y1, x2, y2) 
            if (Distance <= 10) then 
                setElementHealth(100, Pl) 
                outputChatBox("Você recebeu vida", Pl) 
            end 
        end 
    end 
end 
addCommandHandler("darvida", darVida) 

Posted
function darVida(M, _, T) 
    if T == "1" then 
        local x1, y1 = getElementPosition(M) 
        for _,Pl in ipairs(getElementsByType("player")) do 
            local x2, y2 = getElementPosition(Pl) 
            local Distance = getDistanceBetweenPoints2D(x1, y1, x2, y2) 
            if (Distance <= 10) then 
                setElementHealth(100, Pl) 
                outputChatBox("Você recebeu vida", Pl) 
            end 
        end 
    end 
end 
addCommandHandler("darvida", darVida) 

did not work

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...