guiismiti
Well-Known Member
- Joined
- May 19, 2014
- Messages
- 313
- Solutions
- 3
- Reaction score
- 67
Hi,
I'm trying to set an exhaustion for the summon to heal the master.
Here's my script, but it isn't working. I thought os.time() would return a value in seconds. When I set the exhaustion to 0 it has no exhaustion, so, no problem there. But when I set the exhaustion to 2, it just doesn't work.
Note: the storage value 35647 is set to zero every time the player logs in.
I'm trying to set an exhaustion for the summon to heal the master.
Here's my script, but it isn't working. I thought os.time() would return a value in seconds. When I set the exhaustion to 0 it has no exhaustion, so, no problem there. But when I set the exhaustion to 2, it just doesn't work.
Note: the storage value 35647 is set to zero every time the player logs in.
Code:
function onThink(cid)
local master = getCreatureMaster(cid)
local lastHeal = getPlayerStorageValue(master, 35647)
local nextHeal = os.time()
if((nextHeal - lastHeal) > 0) then
setPlayerStorageValue(master, 35647, nextHeal)
local maxhealth = getCreatureMaxHealth(master)
local currenthealth = getCreatureHealth(master)
local criticalhealth = 0.4 * maxhealth
if not isInParty(master) then
if currenthealth < criticalhealth then
doCreatureAddHealth(master, math.random((maxhealth * 0.125), (maxhealth * 0.20)))
local position = getThingPosition(master)
doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
end
end
end
return true
end