Lava Titan
Developer
Hello, so I'm trying to make something that when you look at yourself or another player it will show they're health and mana stats, it works fine if I look at myself or another player but if I try to look at anything else I get boolean error in console because of line:
I assume cuz it's trying to get the stats from the tile or item that I'm looking at, so how do I stop that and make the script only show this if the creature i'm looking at is a player?
here's the full script:
Lua:
local health = (getCreatureHealth(thing.uid) / 1000)
I assume cuz it's trying to get the stats from the tile or item that I'm looking at, so how do I stop that and make the script only show this if the creature i'm looking at is a player?
here's the full script:
Lua:
function onLook(cid, thing, position, lookDistance)
local info = ""
local health = (getCreatureHealth(thing.uid) / 1000)
local maxhealth = (getCreatureMaxHealth(thing.uid) / 1000)
local mana = (getPlayerMana(thing.uid) / 1000)
local maxmana = (getPlayerMaxMana(thing.uid) / 1000)
if isPlayer(thing.uid) then
info = "".. getPlayerName(thing.uid) .." has ".. math.ceil(health) .."k/".. math.ceil(maxhealth) .."k health and ".. math.ceil(mana) .."k/".. math.ceil(maxmana) .."k mana!"
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, info)
doCreatureSay(cid, info, TALKTYPE_MONSTER_SAY, false, cid, getThingPos(thing.uid))
end
return true
end