Tibia Leaves
New Member
- Joined
- Jun 1, 2019
- Messages
- 63
- Reaction score
- 2
I want this code to be only possible to run once every hour how can we achieve that ? this is currently in movements.
so t
so t
Lua:
---<movevent event="StepIn" actionid="47401" script="test.lua"/>
-- action id 47401 for StepIn Tile" can even be fucking grass but pressure pads are cool"
local position1 = {x="32103",y="32172",z="8"}
local position2 = {x="32103",y="32171",z="8"}
local monstertospawn = "rat"
--32103 32172 8
--32103 32171 8
--perfect
-- can u write these into x yz
-- local variables mean that it is value associated with variable name that can be used locally within THIS script global variables can be written into /data/lib as separate file! I
-- if you want to understand stop removing comments
--function onStepIn(tile, itemid, whereistile, wherewasplayerlaststandingbefore)
--addevent(timefunction , 1000 ms, seconds)
function onStepIn(cid, item, position, fromPosition, player)
addEvent(onThink, 1000, seconds)
end
--function timefunction handler
--this is a tes script
function onThink()-- npcHandler:onThink() -- we are not handling anything via NPC so i guess it is not needed we will see
chance = math.random(1,10)
-- math random number generating variable chance within FUNCTION "warning this is not local variable so chance can only be used within this function not whole script!"
if chance == 1 then
--1st option this script does not have to have option for each generater number simply haivng 1 chance and 1,100 generation will make it 1 to 100 chance to spawn upon step.
doSummonCreature("rat", position1)
doSummonCreature("rat", position2)
-- docreate monster seems to be useless
elseif chance == 2 then
--2nd option
doSummonCreature("rat", position1)
doSummonCreature("rat", position2)
elseif chance == 3 then
--3rd option
doSummonCreature("rat", position1)
doSummonCreature("rat", position2)
elseif chance == 4 then
--4th option
doSummonCreature("rat", position1)
doSummonCreature("rat", position2)
end
end