• 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] Warper

Alyhide

Banned User
Joined
Aug 21, 2010
Messages
1,945
Reaction score
55
Location
Switzerland
Hello, I would like a script where an NPC could warp a player to multiple destinations of my choosing if they are VIP. Is this possible?
Explanation :

VIP Player : Hello
Warper : Hello VIP Player , ask me for a teleport if you'd like one!
VIP Player : Dragon Spawn 1
Warper : Do you want to teleport to "Dragon Spawn 1 for 500 gold?
VIP Player : Yes
Warper *Warps VIP Player*

Basic NPC for it :

Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Warper" script="data/npc/scripts/Warp.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="129" head="79" body="113" legs="105" feet="86" addons="0"/>
        <parameters>
                <parameter key="message_greet" value="Hello |PLAYERNAME|, ask me for a {teleport} if you'd like one!"/>
                <parameter key="message_farewell" value="Good bye |PLAYERNAME|, come back soon!."/>
 
    </parameters>
 
</npc>
 
Last edited:
Explain a little more please.
These multiple destinations are cities? or random places? I mean, do they have names?
And about the vip thing, what VIP system are you using?
 
Explain a little more please.
These multiple destinations are cities? or random places? I mean, do they have names?
And about the vip thing, what VIP system are you using?

Mock VIP System

and no not random places, like if your VIP you can talk to the NPC and he can teleport you to spawns all around the map :)


EDIT : Is there a better VIP system that has been released?
 
Just a small bit of them, there is much more but, would this be easy to update?

Code:
Hydra Island - X: 1142, Y: 121, Z: 7
Dragon Island - X: 140, Y: 71, Z: 7
Trainers - X: 2000, Y: 2000, Z: 7
Orc Fortress - X: 953, Y: 409, Z: 6
 
Last edited:
Okay,
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}
 
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

local Hydrapos = {x= 142,y=121,z=7}
local Dragonpos = {x= 140,y=71,z=7}
local Trainerpos = {x= 2000,y=2000,z=7}
local Orcpos = {x= 953,y=409,z=6}
----------------------- To add another one just set it as [EXAMPLE]: local Behemothpos, set where the behemoths are [POSITION] and then put it like this doTeleportThing(cid, Behemothpos)

function creatureSayCallback(cid, type, msg)
if (msgcontains(msg, 'travel')) and vip.hasVip(cid) == TRUE then
   npcHandler:say('Where would you like to travel? {Hydras}, {Dragons}, {Trainers} or {Orc Fortress}', cid) ---- Add more by typing them beetween { }
                         Topic[cid] = 1
elseif msgcontains(msg, 'travel') and vip.hasVip(cid) == FALSE then
       npcHandler:say('I only travel with vip players!', cid)
                         Topic[cid] = 0

elseif msgcontains(msg, 'Hydras') and Topic[cid] == 1 then  --- Copy this line always, JUST CHANGE (msg, '????') for the words beetween { } up there
       npcHandler:say('There you go!')
       doTeleportThing(cid, Hydrapos)
                            Topic[cid] = 0

elseif msgcontains(msg, 'Dragons') and Topic[cid] == 1 then
       npcHandler:say('There you go')
       doTeleportThing(cid, Dragonpos)
                            Topic[cid] = 0

elseif msgcontains(msg, 'Trainers') and Topic[cid] == 1 then
       npcHandler:say('There you go')
       doTeleportThing(cid, Trainerpos)
                            Topic[cid] = 0

elseif msgcontains(msg, 'Orc Fortress') and Topic[cid] == 1 then
       npcHandler:say('There you go')
       doTeleportThing(cid, Orcpos)
                            Topic[cid] = 0 
                            end
       return true
end 

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

So,
Ima give you example:
local HydraPos = ... ---- Is the position of the place where hydras are thats why...
when it says
doTeleportThing(cid, Hydrapos) ---- It will teleport to that position.

So if i want to set the new position and the npc to send me to behemoth its just add

below
LUA:
local Orcpos = { ...etc.

LUA:
local Behemothpos ={ ...etc

and below
LUA:
elseif msgcontains(msg, 'Orc Fortress') and Topic[cid] == 1 then
       npcHandler:say('There you go')
       doTeleportThing(cid, Orcpos)
                            Topic[cid] = 0

LUA:
elseif msgcontains(msg, 'Behemoth') and Topic[cid] == 1 then
       npcHandler:say('There you go')
       doTeleportThing(cid, Behemothpos)
                            Topic[cid] = 0

I think you get it, just gettin sure
 
Last edited:
Okay,
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}
 
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

local Hydrapos = {x= 142,y=121,z=7}
local Dragonpos = {x= 140,y=71,z=7}
local Trainerpos = {x= 2000,y=2000,z=7}
local Orcpos = {x= 953,y=409,z=6}
----------------------- To add another one just set it as [EXAMPLE]: local Behemothpos, set where the behemoths are [POSITION] and then put it like this doTeleportThing(cid, Behemothpos)

function creatureSayCallback(cid, type, msg)
if (msgcontains(msg, 'travel')) and vip.hasVip(cid) == TRUE then
   npcHandler:say('Where would you like to travel? {Hydras}, {Dragons}, {Trainers} or {Orc Fortress}', cid) ---- Add more by typing them beetween { }
                         Topic[cid] = 1
elseif msgcontains(msg, 'travel') and vip.hasVip(cid) == FALSE then
       npcHandler:say('I only travel with vip players!', cid)
                         Topic[cid] = 0

elseif msgcontains(msg, 'Hydras') and Topic[cid] == 1 then  --- Copy this line always, JUST CHANGE (msg, '????') for the words beetween { } up there
       npcHandler:say('There you go!')
       doTeleportThing(cid, Hydrapos)
                            Topic[cid] = 0

elseif msgcontains(msg, 'Dragons') and Topic[cid] == 1 then
       npcHandler:say('There you go')
       doTeleportThing(cid, Dragonpos)
                            Topic[cid] = 0

elseif msgcontains(msg, 'Trainers') and Topic[cid] == 1 then
       npcHandler:say('There you go')
       doTeleportThing(cid, Trainerpos)
                            Topic[cid] = 0

elseif msgcontains(msg, 'Orc Fortress') and Topic[cid] == 1 then
       npcHandler:say('There you go')
       doTeleportThing(cid, Orcpos)
                            Topic[cid] = 0 
                            end
       return true
end 

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

So,
Ima give you example:
local HydraPos = ... ---- Is the position of the place where hydras are thats why...
when it says
doTeleportThing(cid, Hydrapos) ---- It will teleport to that position.


Does this work for only VIP players?
 
I don't know, since I use shawaks system, which uses if isPlayerVip(cid)
And I think Mock system uses, if vip.hasVip(cid). But Idk :/
Btw, you should give me ALL your spawns with ALL your positions, so I can set 'em all to you, trust me its better than doing it by your own and Im bored :)
 
@Up: Yah, I can make now the script if you want, if you can give me all the spawns with positions it would be awesome :D
 
You can use it as a table way :p , you just need to add monster names,pos,price in table
LUA:
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 =  	{	
						["Hydra"] = {pos = {x=89,y=126,z=7} , price = 500},  -- monster name,pos,price
						["Dragons"] = {pos = {x=92,y=132,z=7} , price = 800},
						["demons"] = {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, 'teleport') then
		if getPlayerVipDays(cid) > 0 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
		else
			selfSay("I only serve Vip player.",cid)
		end
 
 
	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("Come back when you have 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())

XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Wraper" script="XXXX.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="129" head="79" body="113" legs="105" feet="86" addons="0"/>
        <parameters>
                <parameter key="message_greet" value="Hello |PLAYERNAME|, to teleport say {teleport}!"/>
                <parameter key="bye" value="Good bye |PLAYERNAME|, come back if you want to be teleported!."/>
    </parameters>

</npc>
 
Back
Top