• 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 Temple changer NPC

sikkee

New Member
Joined
Feb 27, 2010
Messages
89
Reaction score
2
Hi, I have a npc which should change my temple (where i respawn) but it doesn't seem to work, it doesn't respawn me in the new town I chose, and it doesnt write the town_id to the database. How to fix this?

My script:

PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
 
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    
    if (msgcontains(msg, "yes")) then
        if getPlayerItemCount(cid, 2160) >= 750 then
            npcHandler:say("Welcome! You are now a citizen of VIP City!", cid)
            doPlayerSetTown(cid, 2)
            doPlayerRemoveMoney(cid, 7500000)
        else
            npcHandler:say("Sorry but you don't have enough money!", cid)
        end
        end
 

return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())



I'm thankful for any help!
 
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
 
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    
    if (msgcontains(msg, "yes")) then
        if doPlayerRemoveMoney(cid, 7500000) then
            npcHandler:say("Welcome! You are now a citizen of VIP City!", cid)
            doPlayerSetTown(cid, 2)
        else
            npcHandler:say("Sorry but you don't have enough money!", cid)
        end
        end
 

return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


you only checked if they have 750 of item 2160, rather than currency equal to it, which may cause problems.

Also, the map has Town 2 with a temple position set, right?
 
Back
Top