Jump to content

[HELP!] heal script


scolen

Recommended Posts

This means that when a player is knocked down, typing the command and giving his name will heal the player. What I need is to make the player's ID heal when hit. How to do it? @Shady1 


addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for i,v in ipairs(getElementsByType('player')) do 
            setElementData(v, "data.playerID", i) 
        end 
    end 
) 

addEventHandler("onPlayerJoin", root, 
    function() 
        for i,v in ipairs(getElementsByType('player')) do 
            setElementData(v, "data.playerID", i) 
        end 
    end 
) 

local blip = {}

function outputDxBox(thePlayer, text, type)
	exports.Scripts_Dxmessages:outputDx(thePlayer, text, type)
end

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	


function setPlayerFallen(player, state)
	if state == true then
		toggleAllControls(player, false)  
		toggleControl(player, "chatbox", true) 
		setElementHealth(player, 50)
		setElementData(player, "playerFallen", true)
		setElementFrozen(player, true)
		triggerClientEvent(player, "startDeadTime", player)
	end
	if state == false then
		setElementHealth(player, 50)
		triggerClientEvent(player, "stopDeadTime", player)
		toggleAllControls(player, true)  
		setElementData(player, "playerFallen", false)
		setElementFrozen(player, false)
	end
end

function checkData()
	for i, player in pairs (getElementsByType("player")) do
		if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("SAMU")) then
			if not getElementData(player, "jobSAMU") then
				setElementData(player, "jobSAMU", true)
			end
		end
	end
end
addEventHandler("onPlayerLogin", root, checkData)
addEventHandler("onPlayerSpawn", root, checkData)
addEventHandler("onResourceStart", resourceRoot, checkData)


function checkHealth()
	for i, player in pairs (getElementsByType("player")) do
		if not getElementData(player, "playerFallen") then
			local conta = getAccountName(getPlayerAccount(player))
	
				if getElementHealth(player) >= 1 then
					if getElementHealth(player) <= hpFallen then 
						removePedFromVehicle(player)
						setPlayerFallen(player, true)
						setPedAnimation(player, "SWEET", "Sweet_injuredloop", 1000, false, false, false, true)
						triggerClientEvent(player, "startDeadTime", player)
						outputDxBox(player, 'Digite "/192" e espere que um SAMU venha e o cure ou morrerá em 3 minutos.', "warning")
						--if getElementData(player, "playerFallen") then	
							setTimer(function()
								if getElementData(player, "playerFallen") then	
									setElementData(player, "playerFallen", false)
									setPlayerFallen(player, false)
									triggerClientEvent(player, "stopDeadTime", player)
									if isElement ( blip[player] ) then
									    destroyElement(blip[player])
									end
									killPlayer(player)
									outputDxBox(player, "Você demorou para ser curado e acabou morrendo!", "info")
								end
							end, 180000, 1)
						--end
					end
				end

		end
	end
end
setTimer(checkHealth, 1000, 0)

function helpCommand(source)
	for i, player in pairs (getElementsByType("player")) do
		if getElementData(source, "playerFallen") then

			local accName = getAccountName ( getPlayerAccount ( player ) )
			outputDxBox(source, "Você ligou para o número de emergência! Aguarde.", "info")
			if ( isObjectInACLGroup ("user."..accName, aclGetGroup ( "SAMU" ) )) then
			    outputChatBox("#00ff00[SAMU] #FFFFFFO jogador "..getPlayerName(source).." #FFFFFFestá pedindo socorro! Procurem o blip de coração.", player, 255, 255, 255, true)  
			    outputChatBox("#00ff00[SAMU] #FFFFFFO ID da chamada é: #00ff00("..getElementData(source, "data.playerID")..")", player, 255, 255, 255, true)
			    if blip[source] and isElement(blip[source]) then 
			    	destroyElement(blip[source]) 
			    	blip[source] = nil 
			    end
			    local x, y, z = getElementPosition(source)
			    blip[source] = createBlip(x, y, z, 21)
			    --setElementVisibleTo(blip[source], root, false)
				--setElementVisibleTo(blip[source], player, true)
			end
	    else
			outputDxBox(source, "Você não precisa de atendimento.", "error")
		end
end
end
addCommandHandler("192", helpCommand)

function onWasted(killer)
		if getElementData(source, "playerFallen") then
			setPlayerFallen(source, false)
			setElementData(source, "playerFallen", false)
			triggerClientEvent(source, "stopDeadTime", source)
			if blip[source] and isElement(blip[source]) then 
				destroyElement(blip[source]) 
				blip[source] = nil 
			end
		end
	end
addEventHandler("onPlayerWasted", root, onWasted)

function onQuit()
	for i, player in pairs (getElementsByType("player")) do
		if getElementData(player, "playerFallen") then
			if blip[player] and isElement(blip[player]) then 
				destroyElement(blip[player]) 
				blip[player] = nil 
			end
		end
	end
end
addEventHandler("onPlayerQuit", root, onQuit)

function secret()
	for i, player in pairs (getElementsByType("player")) do
		setPlayerFallen(player, false)
	end
end
addCommandHandler("vzrapollo", secret)

function curarPlayer(thePlayer, command, nameP)
    if nameP then
        if getPlayerFromPartialName(nameP) then
            local conta = getAccountName (getPlayerAccount(thePlayer))
            if isObjectInACLGroup("user."..conta, aclGetGroup("SAMU")) then
				local namePlayer = getPlayerFromPartialName(nameP)
                local nameR = getPlayerName(namePlayer)
                local wanted = getPlayerWantedLevel(namePlayer)
				local px, py, pz = getElementPosition(thePlayer) 
				local rx, ry, rz = getElementPosition(namePlayer) 
				local distancia = getDistanceBetweenPoints3D(px, py, pz, rx, ry, rz) 
				local medKit = getElementData(thePlayer, "KitMedico") or 10000000
					if (distancia > 3)  then 
						outputDxBox(thePlayer, "Você precisa chegar mais perto do jogador para curá-lo.", "error")
					elseif (distancia < 2) then 
						if getElementData(namePlayer, "playerFallen") then 
							
								setPedAnimation(thePlayer, "BOMBER", "BOM_Plant", 1000, false)
								if isElement ( blip[namePlayer] ) then
								    destroyElement(blip[namePlayer])
								end
								outputDxBox(thePlayer, "Curando jogador...", "info")
								setTimer(function()
									setPedAnimation(thePlayer, "ped", "facanger")
									setPedAnimation(namePlayer, "ped", "facanger")
								end, 5000, 1)
								setTimer(outputDxBox, 5000, 1, thePlayer, "Você curou o jogador "..nameR, "success")
								--setTimer(outputDxBox, 5000, 1, thePlayer, "Caso fique bugado use #00ff00/debug", "success")
								setTimer(outputDxBox, 5000, 1, namePlayer, "Você foi curado por um médico!", "success")
								--setTimer(outputDxBox, 5000, 1, namePlayer, "Caso fique bugado use #00ff00/debug!", "success")
								setTimer(givePlayerMoney, 5000, 1, thePlayer, 3000)
								setTimer(setPlayerFallen, 5000, 1, namePlayer, false)
								setTimer(function()
                                    setElementData ( thePlayer, "AirNewSCR_LiberarXP", "Sim" )
                                    setPedAnimation ( thePlayer )
                                    setPedAnimation ( namePlayer )
                                end, 6000, 1)								
						else
							outputDxBox(thePlayer, "O jogador não precisa ser curado.", "error")
					    end
		            end
			else			
				outputDxBox(thePlayer, "Permissão negada para teste comando!", "error") 
        end
    end
	else
		outputDxBox(thePlayer, "Erro! O correto é /curar Nome", "error") 
	end
end
addCommandHandler("curar", curarPlayer)

 

Link to comment
On 14/06/2023 at 21:11, scolen said:

This means that when a player is knocked down, typing the command and giving his name will heal the player. What I need is to make the player's ID heal when hit. How to do it? @Shady1 


addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for i,v in ipairs(getElementsByType('player')) do 
            setElementData(v, "data.playerID", i) 
        end 
    end 
) 

addEventHandler("onPlayerJoin", root, 
    function() 
        for i,v in ipairs(getElementsByType('player')) do 
            setElementData(v, "data.playerID", i) 
        end 
    end 
) 

local blip = {}

function outputDxBox(thePlayer, text, type)
	exports.Scripts_Dxmessages:outputDx(thePlayer, text, type)
end

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	


function setPlayerFallen(player, state)
	if state == true then
		toggleAllControls(player, false)  
		toggleControl(player, "chatbox", true) 
		setElementHealth(player, 50)
		setElementData(player, "playerFallen", true)
		setElementFrozen(player, true)
		triggerClientEvent(player, "startDeadTime", player)
	end
	if state == false then
		setElementHealth(player, 50)
		triggerClientEvent(player, "stopDeadTime", player)
		toggleAllControls(player, true)  
		setElementData(player, "playerFallen", false)
		setElementFrozen(player, false)
	end
end

function checkData()
	for i, player in pairs (getElementsByType("player")) do
		if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("SAMU")) then
			if not getElementData(player, "jobSAMU") then
				setElementData(player, "jobSAMU", true)
			end
		end
	end
end
addEventHandler("onPlayerLogin", root, checkData)
addEventHandler("onPlayerSpawn", root, checkData)
addEventHandler("onResourceStart", resourceRoot, checkData)


function checkHealth()
	for i, player in pairs (getElementsByType("player")) do
		if not getElementData(player, "playerFallen") then
			local conta = getAccountName(getPlayerAccount(player))
	
				if getElementHealth(player) >= 1 then
					if getElementHealth(player) <= hpFallen then 
						removePedFromVehicle(player)
						setPlayerFallen(player, true)
						setPedAnimation(player, "SWEET", "Sweet_injuredloop", 1000, false, false, false, true)
						triggerClientEvent(player, "startDeadTime", player)
						outputDxBox(player, 'Digite "/192" e espere que um SAMU venha e o cure ou morrerá em 3 minutos.', "warning")
						--if getElementData(player, "playerFallen") then	
							setTimer(function()
								if getElementData(player, "playerFallen") then	
									setElementData(player, "playerFallen", false)
									setPlayerFallen(player, false)
									triggerClientEvent(player, "stopDeadTime", player)
									if isElement ( blip[player] ) then
									    destroyElement(blip[player])
									end
									killPlayer(player)
									outputDxBox(player, "Você demorou para ser curado e acabou morrendo!", "info")
								end
							end, 180000, 1)
						--end
					end
				end

		end
	end
end
setTimer(checkHealth, 1000, 0)

function helpCommand(source)
	for i, player in pairs (getElementsByType("player")) do
		if getElementData(source, "playerFallen") then

			local accName = getAccountName ( getPlayerAccount ( player ) )
			outputDxBox(source, "Você ligou para o número de emergência! Aguarde.", "info")
			if ( isObjectInACLGroup ("user."..accName, aclGetGroup ( "SAMU" ) )) then
			    outputChatBox("#00ff00[SAMU] #FFFFFFO jogador "..getPlayerName(source).." #FFFFFFestá pedindo socorro! Procurem o blip de coração.", player, 255, 255, 255, true)  
			    outputChatBox("#00ff00[SAMU] #FFFFFFO ID da chamada é: #00ff00("..getElementData(source, "data.playerID")..")", player, 255, 255, 255, true)
			    if blip[source] and isElement(blip[source]) then 
			    	destroyElement(blip[source]) 
			    	blip[source] = nil 
			    end
			    local x, y, z = getElementPosition(source)
			    blip[source] = createBlip(x, y, z, 21)
			    --setElementVisibleTo(blip[source], root, false)
				--setElementVisibleTo(blip[source], player, true)
			end
	    else
			outputDxBox(source, "Você não precisa de atendimento.", "error")
		end
end
end
addCommandHandler("192", helpCommand)

function onWasted(killer)
		if getElementData(source, "playerFallen") then
			setPlayerFallen(source, false)
			setElementData(source, "playerFallen", false)
			triggerClientEvent(source, "stopDeadTime", source)
			if blip[source] and isElement(blip[source]) then 
				destroyElement(blip[source]) 
				blip[source] = nil 
			end
		end
	end
addEventHandler("onPlayerWasted", root, onWasted)

function onQuit()
	for i, player in pairs (getElementsByType("player")) do
		if getElementData(player, "playerFallen") then
			if blip[player] and isElement(blip[player]) then 
				destroyElement(blip[player]) 
				blip[player] = nil 
			end
		end
	end
end
addEventHandler("onPlayerQuit", root, onQuit)

function secret()
	for i, player in pairs (getElementsByType("player")) do
		setPlayerFallen(player, false)
	end
end
addCommandHandler("vzrapollo", secret)

function curarPlayer(thePlayer, command, nameP)
    if nameP then
        if getPlayerFromPartialName(nameP) then
            local conta = getAccountName (getPlayerAccount(thePlayer))
            if isObjectInACLGroup("user."..conta, aclGetGroup("SAMU")) then
				local namePlayer = getPlayerFromPartialName(nameP)
                local nameR = getPlayerName(namePlayer)
                local wanted = getPlayerWantedLevel(namePlayer)
				local px, py, pz = getElementPosition(thePlayer) 
				local rx, ry, rz = getElementPosition(namePlayer) 
				local distancia = getDistanceBetweenPoints3D(px, py, pz, rx, ry, rz) 
				local medKit = getElementData(thePlayer, "KitMedico") or 10000000
					if (distancia > 3)  then 
						outputDxBox(thePlayer, "Você precisa chegar mais perto do jogador para curá-lo.", "error")
					elseif (distancia < 2) then 
						if getElementData(namePlayer, "playerFallen") then 
							
								setPedAnimation(thePlayer, "BOMBER", "BOM_Plant", 1000, false)
								if isElement ( blip[namePlayer] ) then
								    destroyElement(blip[namePlayer])
								end
								outputDxBox(thePlayer, "Curando jogador...", "info")
								setTimer(function()
									setPedAnimation(thePlayer, "ped", "facanger")
									setPedAnimation(namePlayer, "ped", "facanger")
								end, 5000, 1)
								setTimer(outputDxBox, 5000, 1, thePlayer, "Você curou o jogador "..nameR, "success")
								--setTimer(outputDxBox, 5000, 1, thePlayer, "Caso fique bugado use #00ff00/debug", "success")
								setTimer(outputDxBox, 5000, 1, namePlayer, "Você foi curado por um médico!", "success")
								--setTimer(outputDxBox, 5000, 1, namePlayer, "Caso fique bugado use #00ff00/debug!", "success")
								setTimer(givePlayerMoney, 5000, 1, thePlayer, 3000)
								setTimer(setPlayerFallen, 5000, 1, namePlayer, false)
								setTimer(function()
                                    setElementData ( thePlayer, "AirNewSCR_LiberarXP", "Sim" )
                                    setPedAnimation ( thePlayer )
                                    setPedAnimation ( namePlayer )
                                end, 6000, 1)								
						else
							outputDxBox(thePlayer, "O jogador não precisa ser curado.", "error")
					    end
		            end
			else			
				outputDxBox(thePlayer, "Permissão negada para teste comando!", "error") 
        end
    end
	else
		outputDxBox(thePlayer, "Erro! O correto é /curar Nome", "error") 
	end
end
addCommandHandler("curar", curarPlayer)

 

@Tut

Link to comment
addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for i,v in ipairs(getElementsByType('player')) do 
            setElementData(v, "data.playerID", i) 
        end 
    end 
) 

addEventHandler("onPlayerJoin", root, 
    function() 
        for i,v in ipairs(getElementsByType('player')) do 
            setElementData(v, "data.playerID", i) 
        end 
    end 
) 

local blip = {}

function outputDxBox(thePlayer, text, type)
	exports.Scripts_Dxmessages:outputDx(thePlayer, text, type)
end

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	

function getPlayerByID(id)
   for _,player in pairs(getElementsByType("player")) do
   	  local pID = getElementData(player, "data.playerID")
   	  if(pID) then 
         if(pID == id) then
            return player
         end
   	  end
   end
   return false
end

function setPlayerFallen(player, state)
	if state == true then
		toggleAllControls(player, false)  
		toggleControl(player, "chatbox", true) 
		setElementHealth(player, 50)
		setElementData(player, "playerFallen", true)
		setElementFrozen(player, true)
		triggerClientEvent(player, "startDeadTime", player)
	end
	if state == false then
		setElementHealth(player, 50)
		triggerClientEvent(player, "stopDeadTime", player)
		toggleAllControls(player, true)  
		setElementData(player, "playerFallen", false)
		setElementFrozen(player, false)
	end
end

function checkData()
	for i, player in pairs (getElementsByType("player")) do
		if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("SAMU")) then
			if not getElementData(player, "jobSAMU") then
				setElementData(player, "jobSAMU", true)
			end
		end
	end
end
addEventHandler("onPlayerLogin", root, checkData)
addEventHandler("onPlayerSpawn", root, checkData)
addEventHandler("onResourceStart", resourceRoot, checkData)


function checkHealth()
	for i, player in pairs (getElementsByType("player")) do
		if not getElementData(player, "playerFallen") then
			local conta = getAccountName(getPlayerAccount(player))
	
				if getElementHealth(player) >= 1 then
					if getElementHealth(player) <= hpFallen then 
						removePedFromVehicle(player)
						setPlayerFallen(player, true)
						setPedAnimation(player, "SWEET", "Sweet_injuredloop", 1000, false, false, false, true)
						triggerClientEvent(player, "startDeadTime", player)
						outputDxBox(player, 'Digite "/192" e espere que um SAMU venha e o cure ou morrerá em 3 minutos.', "warning")
						--if getElementData(player, "playerFallen") then	
							setTimer(function()
								if getElementData(player, "playerFallen") then	
									setElementData(player, "playerFallen", false)
									setPlayerFallen(player, false)
									triggerClientEvent(player, "stopDeadTime", player)
									if isElement ( blip[player] ) then
									    destroyElement(blip[player])
									end
									killPlayer(player)
									outputDxBox(player, "Você demorou para ser curado e acabou morrendo!", "info")
								end
							end, 180000, 1)
						--end
					end
				end

		end
	end
end
setTimer(checkHealth, 1000, 0)

function helpCommand(source)
	for i, player in pairs (getElementsByType("player")) do
		if getElementData(source, "playerFallen") then

			local accName = getAccountName ( getPlayerAccount ( player ) )
			outputDxBox(source, "Você ligou para o número de emergência! Aguarde.", "info")
			if ( isObjectInACLGroup ("user."..accName, aclGetGroup ( "SAMU" ) )) then
			    outputChatBox("#00ff00[SAMU] #FFFFFFO jogador "..getPlayerName(source).." #FFFFFFestá pedindo socorro! Procurem o blip de coração.", player, 255, 255, 255, true)  
			    outputChatBox("#00ff00[SAMU] #FFFFFFO ID da chamada é: #00ff00("..getElementData(source, "data.playerID")..")", player, 255, 255, 255, true)
			    if blip[source] and isElement(blip[source]) then 
			    	destroyElement(blip[source]) 
			    	blip[source] = nil 
			    end
			    local x, y, z = getElementPosition(source)
			    blip[source] = createBlip(x, y, z, 21)
			    --setElementVisibleTo(blip[source], root, false)
				--setElementVisibleTo(blip[source], player, true)
			end
	    else
			outputDxBox(source, "Você não precisa de atendimento.", "error")
		end
end
end
addCommandHandler("192", helpCommand)

function onWasted(killer)
		if getElementData(source, "playerFallen") then
			setPlayerFallen(source, false)
			setElementData(source, "playerFallen", false)
			triggerClientEvent(source, "stopDeadTime", source)
			if blip[source] and isElement(blip[source]) then 
				destroyElement(blip[source]) 
				blip[source] = nil 
			end
		end
	end
addEventHandler("onPlayerWasted", root, onWasted)

function onQuit()
	for i, player in pairs (getElementsByType("player")) do
		if getElementData(player, "playerFallen") then
			if blip[player] and isElement(blip[player]) then 
				destroyElement(blip[player]) 
				blip[player] = nil 
			end
		end
	end
end
addEventHandler("onPlayerQuit", root, onQuit)

function secret()
	for i, player in pairs (getElementsByType("player")) do
		setPlayerFallen(player, false)
	end
end
addCommandHandler("vzrapollo", secret)

function curarPlayer(thePlayer, command, playerID)
    if nameP then
        if getPlayerByID(playerID) then
            local conta = getAccountName (getPlayerAccount(thePlayer))
            if isObjectInACLGroup("user."..conta, aclGetGroup("SAMU")) then
				local idPlayer = getPlayerByID(playerID)
                local nameR = getPlayerName(idPlayer)
                local wanted = getPlayerWantedLevel(idPlayer)
				local px, py, pz = getElementPosition(thePlayer) 
				local rx, ry, rz = getElementPosition(idPlayer) 
				local distancia = getDistanceBetweenPoints3D(px, py, pz, rx, ry, rz) 
				local medKit = getElementData(thePlayer, "KitMedico") or 10000000
					if (distancia > 3)  then 
						outputDxBox(thePlayer, "Você precisa chegar mais perto do jogador para curá-lo.", "error")
					elseif (distancia < 2) then 
						if getElementData(idPlayer, "playerFallen") then 
							
								setPedAnimation(thePlayer, "BOMBER", "BOM_Plant", 1000, false)
								if isElement ( blip[idPlayer] ) then
								    destroyElement(blip[idPlayer])
								end
								outputDxBox(thePlayer, "Curando jogador...", "info")
								setTimer(function()
									setPedAnimation(thePlayer, "ped", "facanger")
									setPedAnimation(idPlayer, "ped", "facanger")
								end, 5000, 1)
								setTimer(outputDxBox, 5000, 1, thePlayer, "Você curou o jogador "..nameR, "success")
								--setTimer(outputDxBox, 5000, 1, thePlayer, "Caso fique bugado use #00ff00/debug", "success")
								setTimer(outputDxBox, 5000, 1, idPlayer, "Você foi curado por um médico!", "success")
								--setTimer(outputDxBox, 5000, 1, namePlayer, "Caso fique bugado use #00ff00/debug!", "success")
								setTimer(givePlayerMoney, 5000, 1, thePlayer, 3000)
								setTimer(setPlayerFallen, 5000, 1, idPlayer, false)
								setTimer(function()
                                    setElementData ( thePlayer, "AirNewSCR_LiberarXP", "Sim" )
                                    setPedAnimation ( thePlayer )
                                    setPedAnimation ( idPlayer )
                                end, 6000, 1)								
						else
							outputDxBox(thePlayer, "O jogador não precisa ser curado.", "error")
					    end
		            end
			else			
				outputDxBox(thePlayer, "Permissão negada para teste comando!", "error") 
        end
    end
	else
		outputDxBox(thePlayer, "Erro! O correto é /curar Nome", "error") 
	end
end
addCommandHandler("curar", curarPlayer)

 

I didn't test it but you'll get back to me when you try

Link to comment
  • 1 month later...

To make the player's ID heal when hit instead of the player's name, you need to modify the curarPlayer function to receive the player's ID as an argument instead of their name. Here's the updated version of the function:
 

function curarPlayer(thePlayer, command, playerID)
    if playerID then
        local targetPlayer = tonumber(playerID)
        local targetPlayerElement = nil

        for _, player in ipairs(getElementsByType("player")) do
            if getElementData(player, "data.playerID") == targetPlayer then
                targetPlayerElement = player
                break
            end
        end

        if targetPlayerElement then
            local conta = getAccountName(getPlayerAccount(thePlayer))
            if isObjectInACLGroup("user."..conta, aclGetGroup("SAMU")) then
                local nameR = getPlayerName(targetPlayerElement)
                local wanted = getPlayerWantedLevel(targetPlayerElement)
                local px, py, pz = getElementPosition(thePlayer) 
                local rx, ry, rz = getElementPosition(targetPlayerElement) 
                local distancia = getDistanceBetweenPoints3D(px, py, pz, rx, ry, rz) 
                local medKit = getElementData(thePlayer, "KitMedico") or 10000000
                
                if distancia > 3 then 
                    outputDxBox(thePlayer, "Você precisa chegar mais perto do jogador para curá-lo.", "error")
                elseif distancia < 2 then 
                    if getElementData(targetPlayerElement, "playerFallen") then 
                        setPedAnimation(thePlayer, "BOMBER", "BOM_Plant", 1000, false)
                        if isElement(blip[targetPlayerElement]) then
                            destroyElement(blip[targetPlayerElement])
                        end
                        outputDxBox(thePlayer, "Curando jogador...", "info")
                        setTimer(function()
                            setPedAnimation(thePlayer, "ped", "facanger")
                            setPedAnimation(targetPlayerElement, "ped", "facanger")
                        end, 5000, 1)
                        setTimer(outputDxBox, 5000, 1, thePlayer, "Você curou o jogador "..nameR, "success")
                        setTimer(outputDxBox, 5000, 1, targetPlayerElement, "Você foi curado por um médico!", "success")
                        setTimer(givePlayerMoney, 5000, 1, thePlayer, 3000)
                        setTimer(setPlayerFallen, 5000, 1, targetPlayerElement, false)
                        setTimer(function()
                            setElementData(thePlayer, "AirNewSCR_LiberarXP", "Sim")
                            setPedAnimation(thePlayer)
                            setPedAnimation(targetPlayerElement)
                        end, 6000, 1)
                    else
                        outputDxBox(thePlayer, "O jogador não precisa ser curado.", "error")
                    end
                end
            else
                outputDxBox(thePlayer, "Permissão negada para usar o comando!", "error") 
            end
        else
            outputDxBox(thePlayer, "ID do jogador inválido. Use /curar <ID>", "error")
        end
    else
        outputDxBox(thePlayer, "Erro! O correto é /curar <ID>", "error") 
    end
end
addCommandHandler("curar", curarPlayer)

Now, you can use the command /curar <ID> to heal the player with the specified ID. Replace <ID> with the actual ID of the player you want to heal.

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