Last active
September 11, 2015 13:21
-
-
Save dalvorsn/ddd2e23ab8c651fb91da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local cities = { | |
['city1'] = { | |
storage = 10015; | |
pos = {x = 2205, y=573, z = 7}; | |
level = 250; | |
}; | |
['city2'] = { | |
storage = 10015; | |
pos = {x = 2205, y=573, z = 7}; | |
level = 250; | |
}; | |
['city3'] = { | |
storage = 10015; | |
pos = {x = 2205, y=573, z = 7}; | |
level = 250; | |
}; | |
} | |
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:lower()) end | |
function onThink() npcHandler:onThink() end | |
local talkState = {} | |
local cityChoosed = {} | |
function creatureSayCallback(cid, type, msg) | |
if(not npcHandler:isFocused(cid)) then | |
return false | |
end | |
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid | |
for cityName, param in pairs(cities) do | |
if msgcontains(msg, cityName) then | |
selfSay("Você deseja viajar para " .. cityName .. "?", cid) | |
talkState[talkUser] = 1 | |
cityChoosed[talkUser] = cityName | |
return true | |
end | |
end | |
if msgcontains(msg, "yes") and talkState[talkUser] == 1 then | |
local city = cityChoosed[talkUser] | |
if city and cities[city] then | |
local cityParam = cities[city] | |
if getPlayerStorageValue(cid, cityParam.storage) > 0 and getPlayerLevel(cid) >= cityParam.level then | |
selfSay("Chegamos!", cid) | |
doSendMagicEffect(getThingPos(cid), 10) | |
npcHandler:releaseFocus(cid) | |
doTeleportThing(cid, cityParam.pos) | |
doSendMagicEffect(cityParam.pos, 10) | |
else | |
selfSay("você não pode viajar", cid) | |
end | |
end | |
talkState[talkUser] = 0 | |
cityChoosed[talkUser] = nil | |
end | |
return true | |
end | |
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) | |
npcHandler:addModule(FocusModule:new()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment