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

Remove a part from a script! Takes 10 sec!

andii95

New Member
Joined
Aug 21, 2009
Messages
413
Reaction score
2
Location
Sweden
Please help me with this.

Code:
			selfSay("So do you want to go to {"..chosen[cid].."} for "..monsters[chosen[cid]].price.."?",cid)

What part should i remove so he doesnt say the price? Cuz i dont wanna remove to many dots or so xP
 
Ok thanks but look at this,
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
 
local Topic = {}
local chosen = {}
 
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 greetCallback(cid)
	Topic[cid] = 0
	chosen[cid] = nil
	return true
end
 
local monsters = {	
						["xxx"] = {pos = {x=1021,y=1038,z=7} , price = 500},  -- monster name,pos,price
						["xxx"] = {pos = {x=1030,y=932,z=7} , price = 500},
						["xxx"] = {pos = {x=98,y=125,z=7} , price = 1500}
					}
 
function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
        return false
    end
	local str = ""
	if msgcontains(msg, 'travel') then
			for k,v in pairs(monsters) do
				str = str..""..(string.len(str) > 0 and ', ' or '').."{"..k.."}"
			end
			npcHandler:say("Where to? I can take you to "..str..".", cid) 
			Topic[cid] = 1
	elseif Topic[cid] == 1 then
		for k,v in pairs(monsters) do
			if msgcontains(msg, k) then 
				chosen[cid] = k
			end
		end
		if chosen ~= nil then
			selfSay("So do you want to go to {"..chosen[cid].."} for "..monsters[chosen[cid]].price.."?",cid)
			Topic[cid] = 2
		end
	elseif msgcontains(msg, 'yes') and Topic[cid] == 2 then
		if doPlayerRemoveMoney(cid,monsters[chosen[cid]].price) then
			selfSay("There you go.",cid)
			addEvent(doTeleportThing,200,cid,monsters[chosen[cid]].pos,false)
			addEvent(doSendMagicEffect,300,monsters[chosen[cid]].pos,10)
			Topic[cid] = 0
		else
			selfSay("You dont have enough money...",cid)
			Topic[cid] = 0
		end
	elseif msgcontains(msg, 'no') and Topic[cid] == 2 then	
		selfSay("Maybe later then.",cid)
		chosen[cid] = nil
		Topic[cid] = 0
	end
    return true
end 
 
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

When i want to add
Code:
						["xxx"] = {pos = {x=98,y=125,z=7} , price = 1500}
a new town then the npc doesnt work. Why? It looks like this when i add

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
 
local Topic = {}
local chosen = {}
 
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 greetCallback(cid)
	Topic[cid] = 0
	chosen[cid] = nil
	return true
end
 
local monsters = {	
						["xxx"] = {pos = {x=1021,y=1038,z=7} , price = 500},  -- monster name,pos,price
						["xxx"] = {pos = {x=1030,y=932,z=7} , price = 500},
						["xxx"] = {pos = {x=98,y=125,z=7} , price = 1500}
						["xxx"] = {pos = {x=98,y=125,z=7} , price = 1500}
					}
 
function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
        return false
    end
	local str = ""
	if msgcontains(msg, 'travel') then
			for k,v in pairs(monsters) do
				str = str..""..(string.len(str) > 0 and ', ' or '').."{"..k.."}"
			end
			npcHandler:say("Where to? I can take you to "..str..".", cid) 
			Topic[cid] = 1
	elseif Topic[cid] == 1 then
		for k,v in pairs(monsters) do
			if msgcontains(msg, k) then 
				chosen[cid] = k
			end
		end
		if chosen ~= nil then
			selfSay("So do you want to go to {"..chosen[cid].."} for "..monsters[chosen[cid]].price.."?",cid)
			Topic[cid] = 2
		end
	elseif msgcontains(msg, 'yes') and Topic[cid] == 2 then
		if doPlayerRemoveMoney(cid,monsters[chosen[cid]].price) then
			selfSay("There you go.",cid)
			addEvent(doTeleportThing,200,cid,monsters[chosen[cid]].pos,false)
			addEvent(doSendMagicEffect,300,monsters[chosen[cid]].pos,10)
			Topic[cid] = 0
		else
			selfSay("You dont have enough money...",cid)
			Topic[cid] = 0
		end
	elseif msgcontains(msg, 'no') and Topic[cid] == 2 then	
		selfSay("Maybe later then.",cid)
		chosen[cid] = nil
		Topic[cid] = 0
	end
    return true
end 
 
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
They must have different names, you can't have all towns named 'xxx' :p.

And
Code:
local monsters = {	
	["xxx"] = {pos = {x=1021,y=1038,z=7} , price = 500},  -- monster name,pos,price
	["xxx"] = {pos = {x=1030,y=932,z=7} , price = 500},
	["xxx"] = {pos = {x=98,y=125,z=7} , price = 1500}[B][COLOR="red"],[/COLOR][/B]
	["xxx"] = {pos = {x=98,y=125,z=7} , price = 1500}
}
 
Back
Top