• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua NPC's

DiegoRulez

Member
Joined
Apr 16, 2012
Messages
99
Reaction score
13
Location
Feira de Santana - Brasil
I need an NPC to the boat carrying the player talking to him ( Hi, city, yes)
And that quickly transport those who did not say " Hi " and who are in the queue.
Those who are in the queue should say: bring me to [city ]

This script below , found here in OTLAND , and it works just saying bring to me when normally speak
hi , city, yes it does not carry .

I wish someone arrumasse the script or make one that works both ways.

I use the distro OTX Version Lord Zedd to 7.72

Code:
-- Town name, Price, x.pos, y.pox, z.pos --
local config = {
   ["Thais"] = {cost = 100, location = {x = 31310, y = 32210, z = 6}},
   ["Venore"] = {cost = 100, location = {x = 31310, y = 32210, z = 6}}
   }

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState, xmsg = {}, {}
local talkState = {}
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
function creatureSayCallback(cid, type, msg)
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
     local tm = config[msg:lower()]
     if msgcontains(msg, "bring me to") then
         for mes, t in pairs(config) do
             if msgcontains(msg, mes) then
                if isPlayerPzLocked(cid) == true then
                    doPlayerSendTextMessage(cid,MESSAGE_STATUS_SMALL,"Those hands look pretty bloody")
                    npcHandler:say("Hah, Seems like you got blood on your hands you shall not sail with me.", cid)
                    return false
                end
                    if doPlayerRemoveMoney(cid, t.cost) then
                        npcHandler:say("You paid ".. t.cost .." gold coins to travel and you have ".. getPlayerMoney(cid) .." gold coins left in your backpack", cid)
                        doTeleportThing(cid, t.location)
                    else
                     npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it costs ".. t.cost .." gold coins to travel.", cid)
                end
             end
         end  
     elseif tm then
         if getPlayerMoney(cid) >= tm.cost then
             npcHandler:say("Do you want to go to ".. msg .." for ".. tm.cost .." gold coins? ... you do have ".. getPlayerMoney(cid) .." gold coins!", cid)
             talkState[talkUser] = 1
             xmsg[cid] = msg
         else
             npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it t.cost's ".. tm.cost .." gold coins to travel.", cid)
         end
     elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
         local tm = config[xmsg[cid]:lower()]
                if isPlayerPzLocked(cid) == true then
                    doPlayerSendTextMessage(cid,MESSAGE_STATUS_SMALL,"Those hands look pretty bloody")
                    npcHandler:say("Hah, Seems like you got blood on your hands you shall not sail with me.", cid)
                    return false
                end
         if doPlayerRemoveMoney(cid, tm.cost) == true then
             npcHandler:say("You paid ".. tm.cost .." gold coins to travel and you have ".. getPlayerMoney(cid) .." gold coins left in your backpack", cid)
             doTeleportThing(cid, tm.location)
         else
             npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it t.cost's ".. cost[cid] .." gold coins to travel.", cid)
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, "no") and talkState[talkUser] > 0 then
         npcHandler:say("Ok.", cid)
         talkState[talkUser] = 0
     end
     return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top