--here my code. that was in mods/
<?xml version="1.0" encoding="UTF-8"?>
<mod name="healFunc" version="1.0" author="Adahox" contact="[email protected]" enabled="yes">
<config name="healFunc"><![CDATA[
char = {
HEAL_SAFE = 0,
SPELL_SAFE = ""
}
function healPlayer(cid, current_hp)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "current HP: "..current_hp.." => ".. char.HEAL_SAFE )
if current_hp < char.HEAL_SAFE then
say("Local Chat", char.SPELL_SAFE)
end
end
function setHealSafe(value, cid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "setHealSafe() called." )
if value then
char.HEAL_SAFE = value
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "char.HEAL_SAFE = ".. tostring(value) )
end
end
function setSpellSafe(value,cid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "setSpellSafe() called." )
if value then
char.SPELL_SAFE = tostring(value)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "char.SPELL_SAFE = ".. tostring(value) )
end
end
]]></config>
<event type="login" name="LootLogin" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "MonsterAttack")
return true
end]]></event>
<event type="death" name="LootEventDeath" event="script"><![CDATA[
domodlib('Loot_func')
function onDeath(cid, corpse, deathList)
local killer,pos = deathList[1],getCreaturePosition(cid)
addEvent(corpseRetireItems,1,killer,pos)
return true
end]]></event>
<event type="combat" name="MonsterAttack" event="script"><![CDATA[
domodlib('healFunc')
if isPlayer(cid) then
local current_hp = getCreatureHealth(cid)
addEvent(healPlayer,1, cid, current_hp)
end
return true]]></event>
<talkaction words="!autoheal;/autoheal" event="buffer">
<![CDATA[
domodlib('healFunc')
local t = string.explode(string.lower(param), " ")
local strlen = table.getn(t) -- pega o tamanho do array.
addEvent(setSpellSafe,1, t[strlen], cid)
addEvent(setHealSafe,1, t[strlen - 1], cid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "let's heal with "..t[strlen].." when my HP is above "..t[strlen - 1])
return true
]]></talkaction>
</mod>
you don't
tfs 1.2 doesn't use mods, no server versions have used mods since 0.3.6
--here my code. that was in mods/
Code:--here my code. that was in mods/ <?xml version="1.0" encoding="UTF-8"?> <mod name="healFunc" version="1.0" author="Adahox" contact="[email protected]" enabled="yes"> <config name="healFunc"><![CDATA[ char = { HEAL_SAFE = 0, SPELL_SAFE = "" } function healPlayer(cid, current_hp) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "current HP: "..current_hp.." => ".. char.HEAL_SAFE ) if current_hp < char.HEAL_SAFE then say("Local Chat", char.SPELL_SAFE) end end function setHealSafe(value, cid) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "setHealSafe() called." ) if value then char.HEAL_SAFE = value doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "char.HEAL_SAFE = ".. tostring(value) ) end end function setSpellSafe(value,cid) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "setSpellSafe() called." ) if value then char.SPELL_SAFE = tostring(value) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "char.SPELL_SAFE = ".. tostring(value) ) end end ]]></config> <event type="login" name="LootLogin" event="script"><![CDATA[ function onLogin(cid) registerCreatureEvent(cid, "MonsterAttack") return true end]]></event> <event type="death" name="LootEventDeath" event="script"><![CDATA[ domodlib('Loot_func') function onDeath(cid, corpse, deathList) local killer,pos = deathList[1],getCreaturePosition(cid) addEvent(corpseRetireItems,1,killer,pos) return true end]]></event> <event type="combat" name="MonsterAttack" event="script"><![CDATA[ domodlib('healFunc') if isPlayer(cid) then local current_hp = getCreatureHealth(cid) addEvent(healPlayer,1, cid, current_hp) end return true]]></event> <talkaction words="!autoheal;/autoheal" event="buffer"> <![CDATA[ domodlib('healFunc') local t = string.explode(string.lower(param), " ") local strlen = table.getn(t) -- pega o tamanho do array. addEvent(setSpellSafe,1, t[strlen], cid) addEvent(setHealSafe,1, t[strlen - 1], cid) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "let's heal with "..t[strlen].." when my HP is above "..t[strlen - 1]) return true ]]></talkaction> </mod>
my question is: how to check if the user is on battle all the time. and if its true, how can i check the user HP?
<talkaction words="!autoheal;/autoheal" event="buffer">
<![CDATA[
domodlib('healFunc')
local t = string.explode(string.lower(param), " ")
local strlen = table.getn(t) -- pega o tamanho do array.
addEvent(setSpellSafe,1, t[strlen], cid)
addEvent(setHealSafe,1, t[strlen - 1], cid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "let's heal with "..t[strlen].." when my HP is above "..t[strlen - 1])
return true
]]></talkaction>
i do not remember mods being in 0.4 o.o0.4 and 0.3.7 (A) :>
What you do is you split the mod, a mod file is actually just alot of scripts in one.
Take a look at this;
Lua:<talkaction words="!autoheal;/autoheal" event="buffer"> <![CDATA[ domodlib('healFunc') local t = string.explode(string.lower(param), " ") local strlen = table.getn(t) -- pega o tamanho do array. addEvent(setSpellSafe,1, t[strlen], cid) addEvent(setHealSafe,1, t[strlen - 1], cid) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "let's heal with "..t[strlen].." when my HP is above "..t[strlen - 1]) return true ]]></talkaction>
What we need to do is create a Lua file in talkactions named autoheal.lua, make the healFunc config global (ex global.lua or a new lib file).
Then register the script in talkactions.xml.
Do that with everything, restart the server and look for bugs, read what they say I can see right now you are missing function onSay(...) and the end.
i do not remember mods being in 0.4 o.o
u are not an elephant
0.4 and 0.3.7 (A) :>
What you do is you split the mod, a mod file is actually just alot of scripts in one.
Take a look at this;
Lua:<talkaction words="!autoheal;/autoheal" event="buffer"> <![CDATA[ domodlib('healFunc') local t = string.explode(string.lower(param), " ") local strlen = table.getn(t) -- pega o tamanho do array. addEvent(setSpellSafe,1, t[strlen], cid) addEvent(setHealSafe,1, t[strlen - 1], cid) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "let's heal with "..t[strlen].." when my HP is above "..t[strlen - 1]) return true ]]></talkaction>
What we need to do is create a Lua file in talkactions named autoheal.lua, make the healFunc config global (ex global.lua or a new lib file).
Then register the script in talkactions.xml.
Do that with everything, restart the server and look for bugs, read what they say I can see right now you are missing function onSay(...) and the end.
can u explain better? i not undestand what u said
Well in short words you need to split the file into files.
Insted of having a talkactions script (the one I copied) you make a talkactions script in data/talkactions/scripts and then include it in talkactions.xml.
ya this part i undestand.
but, i need, for example, the script checks everytime if the user is in an battle and if return "true", the script should send an say() with healling spell.
talkactions run only when user say the special words. and i need the script runs "all the time"