• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Mount NPC

hasbro

Member
Joined
Feb 15, 2009
Messages
286
Reaction score
6
Hello, Today i try create a mount npc like a real tibia with world changes...But on npc rent 30 Horses each 3 hours create one respaw on map for Wild Horse and not rent more npcs on day.

I create globalevents on the respaw of the Wild horse but i dont have idea ...how i can start this script after rented 30 Horses

Follow the globalevents:
LUA:
monsters = {
        ["Horse"] = {
                ["Wild Horse"] = {pos = {x=33063, y=30996, z=3}, delay = 10800},
                ["Wild Horse"] = {pos = {x=33064, y=30996, z=3}, delay = 21600},
                 ["Wild Horse"] = {pos = {x=33063, y=30996, z=3}, delay = 32400},
                ["Wild Horse"] = {pos = {x=33064, y=30996, z=3}, delay = 43200}
                }
                }
                           

function onThink(interval, lastExecution)
if getGlobalStorageValue(27779) >= 30 then 
local summons = monsters[getCreatureName(cid)]
if summons then
for i, v in pairs(summons) do
addEvent(doSummonCreature, v.delay, i, v.pos)
end
return TRUE
end
else
return FALSE
end
end
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid)        end
function onCreatureDisappear(cid)        npcHandler:onCreatureDisappear(cid)        end
function onCreatureSay(cid, type, msg)        npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                npcHandler:onThink()                end
local mountsfull = 'Today all mounts is rented!'
npcHandler:setMessage(MESSAGE_GREET, "Greetings, |PLAYERNAME|.")
function mount(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    if getGlobalStorageValue(27779) < 30 then 
    doPlayerAddMount(cid, 10)
    setGlobalStorageValue(27779, 1)
    else
                npcHandler:say(mountsfull)
                end
    

    end
 keywordHandler:addKeyword({'rent'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Today I have mounts for you rent."})

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

- - - Updated - - -

BUmp
 
Last edited:
Back
Top