Sign in to follow this  
xXGhostXx

[HELP] Heal system

Recommended Posts

Hi everyone .

What is problem ?

I want doctor use /heal and send request to player, player use /aheal and accept heal and set element health to 100 but if not request say "You have no pending request."

Please fix it !

function darmanKardan (thePlayer, command, player)
	local taraf = getPlayerFromName(player)
	if player then
		setElementData(taraf,"healrequest", pending)
		outputChatBox("#00ff00The doctor is willing to heal you. Do you accept?", taraf, 255, 255, 255, true)
	else
		outputChatBox("#ff0000Syntax: /heal <Name>", thePlayer, 255, 255, 255, true)
	end
end
addCommandHandler("heal", darmanKardan)

function acceptHeal (thePlayer, command)
	local requestStatus = getElementData(thePlayer, "healrequest")
	if (requestStatus = "pending") then
		setElementData(player,"healrequest", unpending)
		setElementHealth(player, 100)
		outputChatBox("#00ff00You have been healed by the doctor.", thePlayer, 255, 255, 255, true)
	else
		outputChatBox("#ff0000[Error]: #ffffffYou have no pending request.", thePlayer, 255, 255, 255, true)
	end
end
addCommandHandler("aheal", acceptHeal)

 

Share this post


Link to post
1 minute ago, HDmaster0702 said:

You've haven't put quote marks around the pending at the 4. line. Putting them should fix it.

Can you give me code ?

Share this post


Link to post
function darmanKardan (thePlayer, command, player)
	local taraf = getPlayerFromName(player)
	if player then
		setElementData(taraf,"healrequest", "pending")
		outputChatBox("#00ff00The doctor is willing to heal you. Do you accept?", taraf, 255, 255, 255, true)
	else
		outputChatBox("#ff0000Syntax: /heal <Name>", thePlayer, 255, 255, 255, true)
	end
end
addCommandHandler("heal", darmanKardan)

function acceptHeal (thePlayer, command)
	local requestStatus = getElementData(thePlayer, "healrequest")
	if (requestStatus = "pending") then
		setElementData(player,"healrequest", "unpending")
		setElementHealth(player, 100)
		outputChatBox("#00ff00You have been healed by the doctor.", thePlayer, 255, 255, 255, true)
	else
		outputChatBox("#ff0000[Error]: #ffffffYou have no pending request.", thePlayer, 255, 255, 255, true)
	end
end
addCommandHandler("aheal", acceptHeal)

 

Yes, here you go.

 

Share this post


Link to post
function darmanKardan (thePlayer, command, player)
	local taraf = getPlayerFromName(player)
	if player then
		setElementData(taraf,"healrequest", pending)
		outputChatBox("#00ff00The doctor is willing to heal you. Do you accept?", taraf, 255, 255, 255, true)
	else
		outputChatBox("#ff0000Syntax: /heal <Name>", thePlayer, 255, 255, 255, true)
	end
end
addCommandHandler("heal", darmanKardan)

function acceptHeal (thePlayer, command)
	local requestStatus = getElementData(thePlayer, "healrequest")
	if (requestStatus == "pending") then
		setElementData(player,"healrequest", unpending)
		setElementHealth(player, 100)
		outputChatBox("#00ff00You have been healed by the doctor.", thePlayer, 255, 255, 255, true)
	else
		outputChatBox("#ff0000[Error]: #ffffffYou have no pending request.", thePlayer, 255, 255, 255, true)
	end
end
addCommandHandler("aheal", acceptHeal)

The equality operator == is missing in line 14. This code should work

Share this post


Link to post
2 minutes ago, NeverUnbeatable said:

function darmanKardan (thePlayer, command, player)
	local taraf = getPlayerFromName(player)
	if player then
		setElementData(taraf,"healrequest", pending)
		outputChatBox("#00ff00The doctor is willing to heal you. Do you accept?", taraf, 255, 255, 255, true)
	else
		outputChatBox("#ff0000Syntax: /heal <Name>", thePlayer, 255, 255, 255, true)
	end
end
addCommandHandler("heal", darmanKardan)

function acceptHeal (thePlayer, command)
	local requestStatus = getElementData(thePlayer, "healrequest")
	if (requestStatus == "pending") then
		setElementData(player,"healrequest", unpending)
		setElementHealth(player, 100)
		outputChatBox("#00ff00You have been healed by the doctor.", thePlayer, 255, 255, 255, true)
	else
		outputChatBox("#ff0000[Error]: #ffffffYou have no pending request.", thePlayer, 255, 255, 255, true)
	end
end
addCommandHandler("aheal", acceptHeal)

The equality operator == is missing in line 14. This code should work

Fixed, but doctor is send request for me but i cant accept request

Share this post


Link to post
function darmanKardan (thePlayer, command, player)
	if player then
    	local taraf = getPlayerFromName(player)
		setElementData(taraf,"healrequest", "pending")
		outputChatBox("#00ff00The doctor is willing to heal you. Do you accept?", taraf, 255, 255, 255, true)
	else
		outputChatBox("#ff0000Syntax: /heal <Name>", thePlayer, 255, 255, 255, true)
	end
end
addCommandHandler("heal", darmanKardan)

function acceptHeal (thePlayer, command)
	local requestStatus = getElementData(thePlayer, "healrequest")
	if (requestStatus == "pending") then
		setElementData(player,"healrequest", "unpending")
		setElementHealth(player, 100)
		outputChatBox("#00ff00You have been healed by the doctor.", thePlayer, 255, 255, 255, true)
	else
		outputChatBox("#ff0000[Error]: #ffffffYou have no pending request.", thePlayer, 255, 255, 255, true)
	end
end
addCommandHandler("aheal", acceptHeal)

Try it.

Share this post


Link to post
16 hours ago, Pirulax said:

Stop using element data for everything, please.

do you have better method instead of element data?

Share this post


Link to post
2 hours ago, Tony Brand said:

do you have better method instead of element data?

variables, tables.

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.