step = 0 timing = 0 customer = 0 queue = 0 spawn = {x = 0, y = 0, z = 0} function onCreate() spawn = selfGetPos() end function onDeath() end function walkAround() x = math.random(7) if x > 4 then npos = selfGetPos() xdist = spawn.x - npos.x ydist = spawn.y - npos.y xab = math.abs(xdist) yab = math.abs(ydist) if (xab < 3) and (yab < 3) and (x == 7) then -- dentro do range pode andar avontade selfRandomWalk() else -- fora so pode voltar pro spawn if x == 5 then if xdist > 0 then selfWalk(DIR_EAST) elseif xdist < 0 then selfWalk(DIR_WEST) end elseif x == 6 then if ydist > 0 then selfWalk(DIR_SOUTH) elseif ydist < 0 then selfWalk(DIR_NORTH) end end end end end function checkDir(cid) mpos = selfGetPos() cpos = creatureGetPos(cid) if cpos.z ~= mpos.z then customer = 0 selfSay(SAY_NORMAL, "Good bye then..."); end xdist = cpos.x - mpos.x ydist = cpos.y - mpos.y xab = math.abs(xdist) yab = math.abs(ydist) if yab > xab then if ydist >= 0 then selfSetDirection(DIR_SOUTH) else selfSetDirection(DIR_NORTH) end else if xdist > 0 then selfSetDirection(DIR_EAST) else selfSetDirection(DIR_WEST) end end end function onThink() if customer == 0 then if queue ~= 0 then step, timing, customer, queue = 1, 0, queue, 0 name = playerGetInfo(customer, PI_NAME) selfSay(SAY_NORMAL, "Hello " .. name .. "! Want to travel somewhere?") checkDir(customer) else walkAround() end else timing = timing + 1 if timing > 30 then if queue ~= 0 then customer = queue queue, timing = 0, 0 selfSay(SAY_NORMAL, "Next please...") -- else -- selfSay(SAY_NORMAL, "ZzZz...") end end end end function onSay(cid, pos, txt, mode) name = playerGetInfo(cid, PI_NAME) str = string.lower(txt) if customer == 0 then if (str == "hi") or (str == "hello") then step, timing, customer = 1, 0, cid selfSay(SAY_NORMAL, "Hello " .. name .. "! Want to travel somewhere?") checkDir(customer) end elseif customer ~= cid then if (str == "hi") or (str == "hello") then if queue ~= cid then selfSay(SAY_NORMAL, "Hey " .. name .. ", wait for your turn!") else queue = cid selfSay(SAY_NORMAL, "You are on the queue, " .. name); end end else if str == "bye" then customer = 0 selfSay(SAY_NORMAL, "Good bye then..."); elseif step == 1 then if str == "city" then step, timing = 2, 0 selfSay(SAY_NORMAL, "Back to the city?") elseif str == "jungle" then step, timing = 3, 0 selfSay(SAY_NORMAL, "Ready to the jungle?") end elseif step > 1 then if str == "no" then customer = 0 selfSay(SAY_NORMAL, "Then not..."); elseif str == "yes" then selfSay(SAY_NORMAL, "Bye bye!") if step == 2 then playerTeleport(customer, 31, true) elseif step == 3 then playerTeleport(customer, 33, true) end customer = 0 end end end end function onCreatureAppear(cid) if (customer ~= 0) and (timing > 60) then selfSay(SAY_NORMAL, "Hurry up, someone is comming!") end end function onCreatureDisappear(cid) if queue == cid then queue = 0 end end function onCreatureMove(cid) if cid == customer then checkDir(customer) end end