LucasBaker Posted October 31, 2014 Share 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? Link to comment
FatalTerror Posted October 31, 2014 Share 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 ? Link to comment
TAPL Posted October 31, 2014 Share 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) Link to comment
LucasBaker Posted October 31, 2014 Author Share 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 Link to comment
TAPL Posted October 31, 2014 Share Posted October 31, 2014 lol This: setElementHealth(100, Pl) should be: setElementHealth(Pl, 100) 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