kito2
www.masteria.net
Have you noted that some times you want to travel to thais, but you got travelled to carlin? Well this happens because the NPC system doesn't check who says what... So it sux a little... I decided to make my own travel NPC system... How it works? You say hi, then the city and you got teleported inmediatly and the NPC stops talking you.
Important: You can't travel if you attacked a player, but if you were attacked by a player, monsters or maybe run into a field, you will be able to travel.
Here is the script:
Note:
The cost is 100 gps, you can change it where it says doPlayerRemoveMoney(cid, 100).
To change the position of where you are teleported, change {x=32387, y=31821, z=6}.
To change the name of the city that you are going to travel, change msgcontains(msg, 'carlin')
You can copy and create more cities to travel, example:
Quite simple, quite cool.
Important: You can't travel if you attacked a player, but if you were attacked by a player, monsters or maybe run into a field, you will be able to travel.
Here is the script:
Lua:
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) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
if (not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, 'thais') and not isPlayerPzLocked(cid) then
if doPlayerRemoveMoney(cid, 100) == true then
doTeleportThing(cid,{x=32311, y=32210, z=6})
self:releaseFocus(cid)
else
npcHandler:say('You don\'t have enought money to travel!', cid)
self:releaseFocus(cid)
end
end
if msgcontains(msg, 'carlin') and not isPlayerPzLocked(cid) then
if doPlayerRemoveMoney(cid, 100) == true then
doTeleportThing(cid,{x=32387, y=31821, z=6})
self:releaseFocus(cid)
else
npcHandler:say('You don\'t have enought money to travel!', cid)
self:releaseFocus(cid)
end
end
if isPlayerPzLocked(cid) then
npcHandler:say('You can\'t travel, you have pz!', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
keywordHandler:addKeyword({'travel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can take you to all places: {thais}, {carlin}.'})
npcHandler:addModule(FocusModule:new())
Note:
The cost is 100 gps, you can change it where it says doPlayerRemoveMoney(cid, 100).
To change the position of where you are teleported, change {x=32387, y=31821, z=6}.
To change the name of the city that you are going to travel, change msgcontains(msg, 'carlin')
You can copy and create more cities to travel, example:
Lua:
if msgcontains(msg, 'NEW_CITY') and not isPlayerPzLocked(cid) then
if doPlayerRemoveMoney(cid, 550) == true then
doTeleportThing(cid,{x=X, y=Y, z=Z})
self:releaseFocus(cid)
else
npcHandler:say('You don\'t have enought money to travel!', cid)
self:releaseFocus(cid)
end
end
Quite simple, quite cool.
Last edited: