Watchdog87
Member
- Joined
- Mar 2, 2014
- Messages
- 30
- Solutions
- 1
- Reaction score
- 5
Hello!
I'm using OTHire 0.0.2.
I'm trying to create a movement script that gives players faster health and mana regeneration when they are sitting on benches.
The problem is that, when stepping away from the bench or logging out, it doesen't stop the Event, so the console gives an error that it can't find the player.
And this is what I added in the movement.xml file:
I'm using OTHire 0.0.2.
I'm trying to create a movement script that gives players faster health and mana regeneration when they are sitting on benches.
The problem is that, when stepping away from the bench or logging out, it doesen't stop the Event, so the console gives an error that it can't find the player.
Code:
local cfg = {
health = 13, --change how much health the player recieves--
mana = 13, --change how much mana the player recieves--
timeInMilli = 1000 --change in how much time the player receives health and mana, 1000ms = 1 second--
}
function onStepIn(cid, item, pos)
local function ManaHealthRegen(parameter)
doPlayerAddHealth(parameter.cid, cfg.health)
doPlayerAddMana(parameter.cid, cfg.mana)
addEvent(ManaHealthRegen, cfg.timeInMilli, {cid = parameter.cid})
doPlayerSay(cid,"Your health and mana regeration has increased by 10%.",16)
doSetCreatureLight(cid, 10, 11, 20000)
return true
end
addEvent(ManaHealthRegen, cfg.timeInMilli, {cid = cid})
return true
end
function onStepOut(cid, item, pos)
stopEvent(ManaHealthRegen)
return true
end
And this is what I added in the movement.xml file:
Code:
<!-- Bench Extra Regen -->
<movevent event="StepIn" itemid="1662" script="bench.lua" />
<movevent event="StepOut" itemid="1662" script="bench.lua" />
<movevent event="StepIn" itemid="1663" script="bench.lua" />
<movevent event="StepOut" itemid="1663" script="bench.lua" />
<movevent event="StepIn" itemid="1664" script="bench.lua" />
<movevent event="StepOut" itemid="1664" script="bench.lua" />
<movevent event="StepIn" itemid="1665" script="bench.lua" />
<movevent event="StepOut" itemid="1665" script="bench.lua" />