Jump to content

[HELP] Medic Healing Range


ViRuZGamiing

Recommended Posts

Hello Community,

My Script:

function medic(player, cmd, who) 
local who = getPlayerFromName(who) 
if getPlayerTeam(player) == getTeamFromName("Medic") then 
setElementHealth(who, 100) 
end 
end 
addCommandHandler("heal", medic) 

What I want:

The Script works fine but I want to set a Range that only players around me can be healed

with this added:

else 
outputChatBox("This player isn't close to you", 0, 0, 225) 

Thanks for helping already

Link to comment
Guest Guest4401
local range = 50 
addCommandHandler('heal', 
    function(p,c,who) 
        local who = getPlayerFromName(who) 
        if who then 
            local mx,my,mz = getElementPosition(p) 
            local ux,uy,uz = getElementPosition(who) 
            if getDistanceBetweenPoints3D(mx,my,mz,ux,uy,uz) <= range then 
                if getPlayerTeam(p) == getTeamFromName("Medic") then 
                    setElementHealth(who, 100) 
                end 
            else 
                outputChatBox("This player is far away",p) 
            end 
        else 
            outputChatBox('Player not found.',p,255,0,0) 
        end 
    end 
) 

Link to comment

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...