Jump to content

heal request and accept


Recommended Posts

hi guys 

how to make a system for request Heal to other players ?

like : acl group medic use /heal <playername> and player use /aheal and the health set to 100 !

outputChatBox for player is The doctor is going to give you HEAL. do you accept? use / aheal

outputChaBox for medic is Your Request Send.

Link to comment
function getPlayerFromPartialName(name)
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil
    if name then
        for _, player in ipairs(getElementsByType("player")) do
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower()
            if name_:find(name, 1, true) then
                return player
            end
        end
    end
end

addCommandHandler( 'heal', function( source,_,player ) 
    local find = getPlayerFromPartialName( player ) 
    if find then	    
    	    setElementData(player,"healrequest", pending)
      		outputChatBox("The doctor is willing to heal you. Do you accept?", player)
    else
      outputChatBox("Player not found!", source, 255, 0, 0)
	end
end)

function acceptHeal()
  local requestStatus = getElementData(source, "healrequest")
  if (requestStatus = "pending") then
  	setElementData(player,"healrequest", unpending)
    setElementHealth(player, 100)
    outputChatBox("You have been healed by the doctor.", source)
  else
    outputChatBox("You have no pending request.")
  end
end
addCommandHandler("aheal", acceptHeal)
  

@MRThinker

Edited by Galactix
Link to comment
Just now, IIYAMA said:

@Galactix

Please do requested code in a private message. Else people might think it is normal to request code in this section.

I really appreciate your affords for the community!

Sorry, I will make sure to do so in the future!

  • Like 1
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...