• 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!

Change script onUse

Koozaczek

New Member
Joined
Jul 19, 2008
Messages
53
Reaction score
0
Hello everyone.
I have script who give hp and mana when you click.
Its work fine, but my problem is that i dont know how to add exhaust to this item.
And if i want add another item i must put some storagevavle?
Please if somebody can do this for me will be great.

And how to change if i want to script give hp/mana but not in %?

script:

local config = {
hp = 10, -- ile procent hp
mana = 25, -- ile procent many
konczysie = true -- konczy sie? (true = tak, false = nie)
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if(config.konczysie) then
doRemoveItem(item.uid)
end
doCreatureAddHealth(cid, getCreatureMaxHealth(cid)*(config.hp/100))
doCreatureAddMana(cid, getCreatureMaxMana(cid)*(config.mana/100))
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_CAKE)
return true
end
 
What kind of exhaust? You can add an exhaustion condition, like potions have.
Above function onUse.
Code:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 1000)

Under function onUse.
Code:
if getCreatureCondition(cid, CONDITION_EXHAUST) then
    doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
    doPlayerSendCancel(cid, "You are exhausted")
    return true
end

doAddCondition(cid, exhaust)

If you want a long exhaustion you can use exhaustion.check/set, so it will still be there when people relog.
 
i dont understand a bit, i put this what you write and now i cant use this item, at the moment i have pernament exhaust on this item.
please help

[30/06/2014 12:09:44] Lua Script Error: [Action Interface]
[30/06/2014 12:09:44] data/actions/scripts/hmonk.lua

[30/06/2014 12:09:44] luaSetConditionParam(). Condition not found

p.s i use tfs 7.6 v2
 
Last edited:
i add this that:
to actions.xml:

<action itemid="2218" script="hmonk.lua" />

to hmonk.lua :

local config = {
hp = 10, -- ile procent hp
mana = 25, -- ile procent many
konczysie = false -- konczy sie? (true = tak, false = nie)
}
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 1000)
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getCreatureCondition(cid, CONDITION_EXHAUST) then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "You are exhausted")
return true
end

doAddCondition(cid, exhaust)
if(config.konczysie) then
doRemoveItem(item.uid)
end
doCreatureAddHealth(cid, getCreatureMaxHealth(cid)*(config.hp/100))
doCreatureAddMana(cid, getCreatureMaxMana(cid)*(config.mana/100))
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_CAKE)
return true
end
 
Back
Top