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

TalkAction Basic Check HP

Slafesko

New Member
Joined
Jan 6, 2016
Messages
101
Reaction score
2
Hello OTLanders, for sure it is easy script for old people but a bit hard for new one ;P so this one for them.
Check your HP, Mana by command with exhaustion for 5 seconds if you are using 100%/100% system , HP/Mana (High exp otservs)

talkactions.xml
Code:
    <talkaction words="!hp" event="script" value="hp.lua"/>

hp.lua
Code:
function onSay(cid, words, param, channel)
   local maxhp = getCreatureMaxHealth(cid)
   local hp = getCreatureHealth(cid)
   local maxmana = getCreatureMaxMana(cid)
   local mana = getCreatureMana(cid)
   local level = getPlayerLevel(cid)
   if exhaustion.check(cid, 7182) == true then
       doPlayerSendCancel(cid, "You are exhausted, You should wait for 5 seconds.")
       return true
   end
   if level > 0 then
       msg = "Your Health " .. hp .. " / " .. maxhp.. "  \n-- Your Mana " .. mana .. " / " .. maxmana .. "."
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, msg)
       exhaustion.set(cid, 7182, 5)
       return true   
   end
end
 
Last edited by a moderator:
Since 'level' is uint and TFS would go crazy if level == 0 (e.g. getExpForLevel(0) would return more than 1 trillion), you can omit that check for level.
You don't need all those local variables since you are using them only once, try to make code as short as possible to improve readability.
One 'end' went missing, probably it run away along with some tabs.
 
Since 'level' is uint and TFS would go crazy if level == 0 (e.g. getExpForLevel(0) would return more than 1 trillion), you can omit that check for level.
Can you explain it o.o?
You don't need all those local variables since you are using them only once, try to make code as short as possible to improve readability.
I like to make it easier with local variables :D
 
In case someone need this without exhaust check for TFS 1.3

Lua:
function onSay(player, words, param)

 
   player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Max HP: " .. player:getMaxHealth())
   player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Current HP: " .. player:getHealth())
   player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Max Mana: " .. player:getMaxMana())
   player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Current Mana: " .. player:getMana())
 
end

Kind Regards
 
Back
Top