• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Health Item [I will REP++]

Synthetic_

deathzot.net
Joined
Dec 30, 2008
Messages
2,535
Reaction score
575
Well, I'm trying to make a script that when you use a rock, if you have 50k it will add 500 health

LUA:
local cost = 50000
    function onUse(cid, item, fromPosition, itemEx, toPosition)
    doPlayerRemoveMoney(cid, cost) == TRUE then
    doCreatureAddHealth(cid, 500)
    doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
    doCreatureSay(cid, "Health+.", TALKTYPE_ORANGE_1)
    elseif getPlayerMoney(cid) < cost then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have enough skulls.")
        end
        return TRUE
    end


Error:

Code:
[26/09/2009 19:27:43] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/health.lua)
[26/09/2009 19:27:43] data/actions/scripts/other/health.lua:3: unexpected symbol near '=='

Whats wrong with it? I will REP++
 
Last edited:
Will this work?

Code:
[26/09/2009 19:27:43] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/health.lua)
[26/09/2009 19:27:43] data/actions/scripts/other/health.lua:3: unexpected symbol near '=='

If you want a screen shot tell me
 
LUA:
    function onUse(cid, item, fromPosition, itemEx, toPosition)
    doPlayerRemoveMoney(cid, 50000) == TRUE then
    doCreatureAddHealth(cid, 500)
    doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
    doCreatureSay(cid, "Health+.", TALKTYPE_ORANGE_1)
    elseif getPlayerMoney(cid) < cost then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have enough skulls.")
        end
        return TRUE
    end

Try this one.

If it wont work try this.

LUA:
 config = {
 ["cost"] = 50000 -- costs
}
 function onUse(cid, item, fromPosition, itemEx, toPosition)
 if(getPlayerMoney(cid) >= config["cost"])then
 doCreatureAddHealth(cid, 500)
 doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
 doCreatureSay(cid, "Health+.", TALKTYPE_ORANGE_1)
 elseif getPlayerMoney(cid) < cost then
 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have enough skulls.")
        end
        return TRUE
    end
 
Last edited:
Doesn't work, =/

Try this

LUA:
 config = {
 ["cost"] = 50000 -- costs
}
 function onUse(cid, item, fromPosition, itemEx, toPosition)
 if(getPlayerMoney(cid) >= config["cost"])then
 doCreatureAddHealth(cid, 500)
 doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
 doCreatureSay(cid, "Health+.", TALKTYPE_ORANGE_1)
 elseif getPlayerMoney(cid) < cost then
 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have enough skulls.")
        end
        return TRUE
    end

Do ya get a new error by this one here?
 
@Cazar Alright, the new one doesn't give me errors. But, I click the thing, it does the effect, it doesn't take money or add health
 
LUA:
local config = {
cost = 50000 -- price per use
health = 500 -- health to add
} 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerMoney(cid) >= config.cost then
		doCreatureAddHealth(cid, config.health)
		doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
		doCreatureSay(cid, "Health+", TALKTYPE_ORANGE_1)
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have enough skulls.")
	end
return true
end

try that
Doesnt work
Code:
[26/09/2009 21:04:12] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/health.lua)
[26/09/2009 21:04:12] data/actions/scripts/other/health.lua:3: '}' expected (to close '{' at line 1) near 'health'
 
LUA:
local config = {
cost = 50000 -- price per use
health = 500 -- health to add
} 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerMoney(cid) >= config.cost then
		doCreatureAddHealth(cid, config.health)
		doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
		doCreatureSay(cid, "Health+", TALKTYPE_ORANGE_1)
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have enough skulls.")
	end
return true
end

try that


right, i could add the health config 2 Lol
i'm new in lua so :p
learning it^^

//Cazar
 
updated code below
should take money, but im not sure why the health isnt being added... it shouldve been
 
Last edited:
dont see why not...making sure you dont have full health already :P? havent tested but it looks like its perfect, might be missing something though

LUA:
local config = {
cost = 50000, -- price per use
health = 500 -- health to add
} 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getCreatureHealth(cid) ~= getCreatureMaxHealth(cid) then
		if doPlayerRemoveMoney(cid, config.cost) == true then
			doCreatureAddHealth(cid, config.health)
			doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
			doCreatureSay(cid, config.health.. "+", TALKTYPE_ORANGE_1)
		else
			doPlayerSendCancel(cid,'You do not have enough skulls!')
		end
	else
		doPlayerSendCancel(cid,'Your health is full already!')
	end
return true
end
that'll tell you if you have full ^^
 
Err, my bad, this script is suppose to add MAX Health, not heal health.. you know what I mean?
Current Max HP [100] / After you use it Max HP [600]
 
Last edited:
Oh you should have said that, here ya go.

LUA:
local config = {
cost = 50000, -- price per use
health = 500 -- health to add
} 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if doPlayerRemoveMoney(cid, config.cost) == true then
		setCreatureMaxHealth(cid, config.health)
		doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
		doCreatureSay(cid, config.health.. "+", TALKTYPE_ORANGE_1)
	else
		doPlayerSendCancel(cid,'You do not have enough skulls!')
	end
return true
end
 
Syntax, then you'll remove health from the player by setting max health as 500.
Should be:
LUA:
local config = {
cost = 50000, -- price per use
health = 500 -- health to add
} 
function onUse(cid, item, fromPosition, itemEx, toPosition)
        if doPlayerRemoveMoney(cid, config.cost) == TRUE then
                setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + config.health)
                doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
                doCreatureSay(cid, config.health.. "+", TALKTYPE_ORANGE_1)
        else
                doPlayerSendCancel(cid,'You do not have enough money!')
        end
return TRUE
end
 
Back
Top