Need help to make my healing script


#1

Hello I’m trying to add a healing function to my paramedic script, but I can’t find my error
(I have start lua there is 5 days, sorry if it’s newbie’s errors :confused:)
Can someone help me to resolve it please ? Thank you. :innocent:
I search with this function to heal the people I have target, by example /heal 1 -> I want to heal the player with the ID 1.

Code:

TriggerEvent('es:addCommand', 'heal', function(source, args, user) 
	TriggerEvent("es:getPlayerFromId", source, function(player)
		local isParamedic = s_checkIsParamedic(player.identifier)
		if(not args[2]) then
			TriggerClientEvent('chatMessage', source, 'SYSTEM', {255, 0, 0}, "Usage : /heal [ID]")	
		else
			if(GetPlayerName(tonumber(args[2])) ~= nil)then
				local player = tonumber(args[2])
				if(isParamedic ~= "nil") then
					TriggerEvent("es:getPlayerFromId", player, function(target)
						SetEntityHealth(target, 200)
						TriggerClientEvent('chatMessage', source, 'SYSTEM', {255, 0, 0}, "Your blessings have been healed !")
				    end)
				else
					TriggerClientEvent('chatMessage', source, 'SYSTEM', {255, 0, 0}, "You don't have the permission to do this !")
				end
			end
		end
	end)
end)

#2

Nobody can help me? I really can not run this script, I don’t understand how the SetEntityHealth work :confused:


#3

You’re calling a native function on the server, that doesn’t work. Try moving it to a client event.