LucasBaker Posted October 31, 2014 Posted October 31, 2014 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?
FatalTerror Posted October 31, 2014 Posted October 31, 2014 Hi, There is an extra ")" line 3, the function is wrong. It's getElementsByType, and make sure that "if T == 1 then" is true. And why don't you use getDistanceBetweenPoints3D ? That would be more logic don't you think ?
TAPL Posted October 31, 2014 Posted October 31, 2014 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)
LucasBaker Posted October 31, 2014 Author Posted October 31, 2014 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
TAPL Posted October 31, 2014 Posted October 31, 2014 lol This: setElementHealth(100, Pl) should be: setElementHealth(Pl, 100)
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