• 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!

NPC Who change Temple

merfus

Member
Joined
Dec 27, 2011
Messages
214
Reaction score
5
Location
Poland
is there any chance to create script that npc change you temple?
I mean NPC change player main town.

Like that, you go to npc and write:
Player -> Hi.
NPC -> Hi, do you want to change Family Town, it cost 10cc.
Player -> Yes (He lose 10cc now)
NPC -> Welcome in Surva Town! It's now you're main Town

And when i die i should resp now in Surva Town.

Can anyone help me with that?
 
PHP:
<?xml version="1.0"?>
<npc name="Temple" script="templenpc.lua" lookdir="2" walkinterval="2000">
    <mana now="800" max="800"/>
    <health now="200" max="200"/>
<look type="57" corpse="6080"/>
 <parameters>
  <parameter key="message_greet" value="Hi! Would you like to change your home town for 10 crystal coins?"/>
    </parameters>
</npc>
Thats the npc, and here is the npc's 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) >= 10 then
			npcHandler:say("Welcome! You are now a citizen of Surva Town", cid)
			doPlayerSetTown(cid, 1)
		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())
Its working perfectly, i tested on my server, so you better rep+ me ^^
 
PHP:
<?xml version="1.0"?>
<npc name="Temple" script="templenpc.lua" lookdir="2" walkinterval="2000">
    <mana now="800" max="800"/>
    <health now="200" max="200"/>
<look type="57" corpse="6080"/>
 <parameters>
  <parameter key="message_greet" value="Hi! Would you like to change your home town for 10 crystal coins?"/>
    </parameters>
</npc>
Thats the npc, and here is the npc's 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) >= 10 then
			npcHandler:say("Welcome! You are now a citizen of Surva Town", cid)
			doPlayerSetTown(cid, 1)
		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())
Its working perfectly, i tested on my server, so you better rep+ me ^^

It works almost perfectly, he change town id, he dont change if dont have money, BUT he don't take money from me ;d
Can you solve this? :P
 
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) >= 10 then
			npcHandler:say("Welcome! You are now a citizen of Surva Town", cid)
			doPlayerSetTown(cid, 1)
			doRemoveItem(cid[2160, 10])
		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())
 
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) >= 10 then
			npcHandler:say("Welcome! You are now a citizen of Surva Town", cid)
			doPlayerSetTown(cid, 1)
			doRemoveItem(cid[2160, 10])
		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())

[30/01/2012 13:50:33] [Error - LuaScriptInterface::loadFile] data/npc/scripts/templenpc.lua:22: ']' expected near ','
[30/01/2012 13:50:33] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/templenpc.lua
[30/01/2012 13:50:33] data/npc/scripts/templenpc.lua:22: ']' expected near ','

it's that line:

PHP:
            doRemoveItem(cid[2160, 10])

But i solved this.

Here is worked script for that who want

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) >= 10 then
            npcHandler:say("Welcome! You are now a citizen of Surva Town", cid)
            doPlayerSetTown(cid, 2)
			doPlayerRemoveMoney(cid, 100000)
        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 just change line:
PHP:
doRemoveItem(cid[2160, 10])
for that:
PHP:
doPlayerRemoveMoney(cid, 100000)

Ofc REP+++ For you Sir Bananas
 
Last edited:
You mean that you want to set the xyz for town like ID 3? You must do it in map editor.
RME> Edit > Towns or Ctrl+T

No, I mean that if I use the npc to change respawn town, it needs to insert the town_id which is 2 to the database, or else I wont respawn in the new town.

EDIT: I have already set the xyz for town ID 2, which is my VIP town :)
 
No, I mean that if I use the npc to change respawn town, it needs to insert the town_id which is 2 to the database, or else I wont respawn in the new town.

EDIT: I have already set the xyz for town ID 2, which is my VIP town :)

It insert automaticly you can set town id in this lane:

LUA:
doPlayerSetTown(cid, 1)

1= Town ID
 
I did that but still doesnt change the town_id in my database

i really don't know how to help you, for me all working fine, maybe you just don't have the town with ID 2? and you must add it in map editor what i say ;d. Check that!

If You have that town ID in map can't do anything more for you, sry.
 
i really don't know how to help you, for me all working fine, maybe you just don't have the town with ID 2? and you must add it in map editor what i say ;d. Check that!

If You have that town ID in map can't do anything more for you, sry.

Dude I'm not stupid xD, I have everything exactly as it should be, tested like 5 times, checked everything in the map editor, everything was right and so on.
 
Back
Top