• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction My teleport system

KylerXX

Active Member
Joined
Jun 24, 2010
Messages
439
Reaction score
30
Hello, I will present my teleport system.
Function:
If you are not in the sacred position, then you can not teleport, if you're in the sacred position, and you say for example <<tp hydras>>, you will be teleported to hydras.
First let's go to data/talkactions/scripts, and create a lua file called tp.lua, and then write in:
PHP:
function onSay(cid, words, param)
posx = getPlayerPosition(cid).x
posy = getPlayerPosition(cid).y
par = {
book = param == 'book', --param of book
hydra = param == 'hydras', -- param of destinations.
demon = param == 'demons',
pirate = param == 'pirates'
}
msg = {
nopos1 = 'Debes estar en el suelo sagrado.',
nomoney = 'No tienes suficiente dinero para utilizar este servicio.',
donetp = 'Has llegado con éxito.'
}
pos = {
hydra = {x = 95, y = 118, z = 7},
demon = {x = 1000, y = 1000, z = 7}, 
pirate = {x = 1000, y = 1000, z = 7} 
} -- Destinos.
cost = {
tp = 50000, -- Cost of service
book = 10000, --Cost of book
money = getPlayerMoney(cid)-- player money
}
local money1 = getPlayerMoney(cid) > cost.tp
local money2 = getPlayerMoney(cid) < cost.book
pos1 = {x = 95, y = 117, z = 7} -- Sacred position
-- This is text of the book.
text = '* Remember that the cost of this service is 1 cc. \ nIf you want to use this exclusive service, you must remember to be vip, below, shows what you should say on the sacred position to go to different areas: \ ntp hydras, \ ntp demons, \ ntp pirates. \ n * The cost of such services is of 5 cc. " 
 
 
---------- HYDRAS
if posx == pos1.x and posy == pos1.y and par.hydra and money1 then -- this indicates that if the player's position is equal to the principal, and say tp hydras and has more than 5 cc -It will run the below.
doTeleportThing(cid, pos.hydra)
doPlayerRemoveMoney(cid, 50000)
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, msg.donetp)
doSendMagicEffect(pos.hydra, CONST_ME_TELEPORT)
elseif posx == pos1.x and posy == pos1.y and par.hydra and money2 then -- this indicates that if the player's position is equal to the principal and say  tp hydtas and has lesst han  de 5 cc--It will run the below.
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, msg.nomoney)
elseif posx ~= pos1.x and posy ~= pos1.y and par.hydra then -- this indicate that the player's position is not equal to the principal and say  tp hydras, It will run the below.
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, msg.nopos1)
elseif posx == pos1.x and posy ~= pos1.y and par.hydra then
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, msg.nopos1)
elseif posx ~= pos1.x and posy == pos1.y and par.hydra then
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, msg.nopos1)
 
 
----DEMONS
elseif posx == pos1.x and posy == pos1.y and par.demon and money1 then
doTeleportThing(cid, pos.demon)
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, msg.nopos1)
doPlayerRemoveMoney(cid, 50000)
doSendMagicEffect(pos.demon, CONST_ME_TELEPORT)
elseif posx == pos1.x and posy == pos1.y and par.demon and money2 then
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, msg.nomoney)
elseif posx ~= pos1.x and posy ~= pos1.y and par.demon then
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, msg.nopos1)
elseif posx == pos1.x and posy ~= pos1.y and par.demon then
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, msg.nopos1)
elseif posx ~= pos1.x and posy == pos1.y and par.demon then
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, msg.nopos1)
 
 
----PIRATES
elseif posx == pos1.x and posy == pos1.y and par.pirate and money1 then
doTeleportThing(cid, pos.pirate)
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, msg.donetp)
doPlayerRemoveMoney(cid, 50000)
doSendMagicEffect(pos.pirate, CONST_ME_TELEPORT)
elseif posx == pos1.x and posy == pos1.y and par.pirate and money2 then
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, msg.nomoney)
elseif posx ~= pos1.x and posy ~= pos1.y and par.pirate then
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, msg.nopos1)
elseif posx == pos1.x and posy ~= pos1.y and par.pirate then
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, msg.nopos1)
elseif posx ~= pos1.x and posy == pos1.y and par.pirate then
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, msg.nopos1)
 
---BOOK
elseif posx == pos1.x and posy == pos1.y and par.book and money1 then
addEvent(doShowTextDialog, 2000, cid, 7704, text)
doPlayerRemoveMoney(cid, 10000)
doSendMagicEffect(pos1, CONST_ME_POFF)
elseif posx == pos1.x and posy == pos1.y and par.book and money2 then
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, msg.nomoney)
elseif posx ~= pos1.x and posy ~= pos1.y and par.book then
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, msg.nopos1)
----------------------------
end
end

You can add more destinations adding this:
PHP:
---NAMEDESTINATION
elseif posx == pos1.x and posy == pos1.y and PARAM OF DEST and money1 then -- you can add on par table
doTeleportThing(cid, POSITION DESTINATION) -- you can add on table pos
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, msg.donetp)
doPlayerRemoveMoney(cid, 50000)
doSendMagicEffect(pos.pirate, CONST_ME_TELEPORT)
elseif posx == pos1.x and posy == pos1.y and PARAM OF DEST  and money2 then-- you can add on par table
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, msg.nomoney)
elseif posx ~= pos1.x and posy ~= pos1.y and PARAM OF DEST then-- you can add on par table
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, msg.nopos1)
elseif posx == pos1.x and posy ~= pos1.y and PARAM OF DEST  then-- you can add on par table
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, msg.nopos1)
elseif posx ~= pos1.x and posy == pos1.y and PARAM OF DEST  then-- you can add on par table
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, msg.nopos1)

Now you go to talkactions.xml and add:
PHP:
<talkaction words="tp" event="script" value="tp.lua"/>

I hope you like it:thumbup:
 
:huh:Are you Xafterin?
 
I optimized your code a bit.

Lua:
local positions = {
	["hydra"] = {x = 95, y = 118, z = 7},
	["demon"] = {x = 1000, y = 1000, z = 7},
	["pirate"] = {x = 1000, y = 1000, z = 7} 
}
local config = {
	sacredPos = {x = 95, y = 117, z = 7},
	cost = 50000
}

function onSay(cid, words, param)

	if(param == "book") then
		if(doPlayerRemoveMoney(cid, 10000)) then
			doShowTextDialog(cid, 7704, "Remember that the cost of this service is 1 cc. \ nIf you want to use this exclusive service, you must remember to be vip, below, shows what you should say on the sacred position to go to different areas: \ ntp hydras, \ ntp demons, \ ntp pirates. \ n * The cost of such services is of 5 cc.")
		end
		return true
	end
	if(positions[string.lower(param)]) then
		if(getPlayerPosition(cid) == config.sacredPos) then
			if(doPlayerRemoveMoney(cid, config.cost)) then
				doTeleportThing(cid, positions[string.lower(param)].pos)
				doSendMagicEffect(positions[string.lower(param)].pos, CONST_ME_TELEPORT)
				doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, "You were teleported to the " .. string.lower(param))
			else
				doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, "You don't have enought money")
			end
		else
			doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, "You're not in a sacred position")
		end
	else
		doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, "There is no such a place")
	end
	return true
end
 
Last edited:
hahausd the second time it's done :D
Code:
-- Destinos
local p = {
        ['hydra'] = {x = 95, y = 118, z = 7}, 
        ['demon'] = {x = 1000, y = 1000, z = 7}, 
        ['pirate'] = {x = 1000, y = 1000, z = 7},
    } 
 
function onSay(cid, words, param, channel)
    pos = {x = 95, y = 117, z = 7} -- Posicion principal(sagrada)
    texto = '*Recuerda que el coste de este servicio es de 1 cc.\nSi quieres usar este servicio exclusivo debes recordar que debes ser vip, a continuación(abajo), se muestra lo que has de decir en el suelo teletransportador para ir a diversas zonas:\ntp hydras,\ntp demons,\ntp pirates.\n*El coste de estos servicios es de 5 cc.'
 
    if getThingPos(cid) ~= pos then
        doPlayerSendCancel(cid, 'Debes estar en suelo sagrado.')
        return true
    end
 
    if param:lower() == 'libro' then 
        if not doPlayerRemoveMoney(cid, 10000) then 
            doPlayerSendCancel(cid, 'No tienes suficiente dinero para utilizar este servicio.')
            return true
        else
            addEvent(doShowTextDialog, 2000, cid, 7704, texto)
            doSendMagicEffect(pos, CONST_ME_POFF)
        end
    end
 
    if p[param:lower()] then 
        if not doPlayerRemoveMoney(cid, 50000) then 
            doPlayerSendCancel(cid, 'Te hacen falta 50000 gps.')
            return true
        else
            doTeleportThing(cid, p[param:lower()])
            doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, 'Has llegado con éxito.')
            doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
        end
    end    
 
    return true
end
 
hahausd the second time it's done :D
Lua:
-- Destinos
local p = {
        ['hydra'] = {x = 95, y = 118, z = 7}, 
        ['demon'] = {x = 1000, y = 1000, z = 7}, 
        ['pirate'] = {x = 1000, y = 1000, z = 7},
    } 
 
function onSay(cid, words, param, channel)
    pos = {x = 95, y = 117, z = 7} -- Posicion principal(sagrada)
    texto = '*Recuerda que el coste de este servicio es de 1 cc.\nSi quieres usar este servicio exclusivo debes recordar que debes ser vip, a continuación(abajo), se muestra lo que has de decir en el suelo teletransportador para ir a diversas zonas:\ntp hydras,\ntp demons,\ntp pirates.\n*El coste de estos servicios es de 5 cc.'
 
    if getThingPos(cid) ~= pos then
        doPlayerSendCancel(cid, 'Debes estar en suelo sagrado.')
        return true
    end
 
    if param:lower() == 'libro' then 
        if not doPlayerRemoveMoney(cid, 10000) then 
            doPlayerSendCancel(cid, 'No tienes suficiente dinero para utilizar este servicio.')
            return true
        else
            addEvent(doShowTextDialog, 2000, cid, 7704, texto)
            doSendMagicEffect(pos, CONST_ME_POFF)
        end
    end
 
    if p[param:lower()] then 
        if not doPlayerRemoveMoney(cid, 50000) then 
            doPlayerSendCancel(cid, 'Te hacen falta 50000 gps.')
            return true
        else
            doTeleportThing(cid, p[param:lower()])
            doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, 'Has llegado con éxito.')
            doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
        end
    end    
 
    return true
end

2 minutes faster than you xd


NP. : )
 
Lua:
local positions = {
	["hydra"] = {x = 95, y = 118, z = 7},
	["demon"] = {x = 1000, y = 1000, z = 7},
	["pirate"] = {x = 1000, y = 1000, z = 7} 
}
local config = {
	sacredPos = {x = 95, y = 117, z = 7},
	cost = 50000
}
function onSay(cid, words, param)
 
	if(param == "book") then
		if(doPlayerRemoveMoney(cid, 10000) == true) then
			doShowTextDialog(cid, 7704, "Remember that the cost of this service is 1 cc. \ nIf you want to use this exclusive service, you must remember to be vip, below, shows what you should say on the sacred position to go to different areas: \ ntp hydras, \ ntp demons, \ ntp pirates. \ n * The cost of such services is of 5 cc.")
		end
		return true
	end
	if((not positions[string.lower(param)]) or (getPlayerPosition(cid) ~= config.sacredPos) or (getPlayerMoney(cid) < config.cost))then
		doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, "You don't have enough money or neither there's no such place or you're not in a sacred position.")
		return true;
	end
	doPlayerRemoveMoney(cid, config.cost)
	doTeleportThing(cid, positions[string.lower(param)].pos)
	doSendMagicEffect(positions[string.lower(param)].pos, CONST_ME_TELEPORT)
	doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, "You were teleported to the " .. string.lower(param))
	return true
end
 
Lua:
local positions = {
	["hydra"] = {x = 95, y = 118, z = 7},
	["demon"] = {x = 1000, y = 1000, z = 7},
	["pirate"] = {x = 1000, y = 1000, z = 7} 
}
local config = {
	sacredPos = {x = 95, y = 117, z = 7},
	cost = 50000
}
function onSay(cid, words, param)
 
	if(param == "book") then
		if(doPlayerRemoveMoney(cid, 10000) == true) then
			doShowTextDialog(cid, 7704, "Remember that the cost of this service is 1 cc. \ nIf you want to use this exclusive service, you must remember to be vip, below, shows what you should say on the sacred position to go to different areas: \ ntp hydras, \ ntp demons, \ ntp pirates. \ n * The cost of such services is of 5 cc.")
		end
		return true
	end
	if((not positions[string.lower(param)]) or (getPlayerPosition(cid) ~= config.sacredPos) or (getPlayerMoney(cid) < config.cost))then
		doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, "You don't have enough money or neither there's no such place or you're not in a sacred position.")
		return true;
	end
	doPlayerRemoveMoney(cid, config.cost)
	doTeleportThing(cid, positions[string.lower(param)].pos)
	doSendMagicEffect(positions[string.lower(param)].pos, CONST_ME_TELEPORT)
	doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, "You were teleported to the " .. string.lower(param))
	return true
end

If I was a player, I would like to know exactly what I've done wrong, not a list of things that I could have done wrong, but thats only my opinion.
 
I update my code, its more short and more configurable:
Code:
function onSay(cid, words, param)
local params = {
["hydra"] = {{x = 95, y = 118, z = 7}},
["demon"] = {{x = 1000, y = 1000, z = 7}},
["pirate"] = {{x = 1000, y = 1000, z = 7}}
}
local parame = params[param]
posx = getPlayerPosition(cid).x
posy = getPlayerPosition(cid).y
costs = {
tp = 50000,
bok = 10000,
}
 
pos1 = {x = 95, y = 117, z = 7} -- Sacred position
texto = 'Remember that the cost of this service is 1 cc. \ nIf you want to use this exclusive service, you must remember to be vip, below, shows what you should say on the sacred position to go to different areas: \ ntp hydras, \ ntp demons, \ ntp pirates. \ n * The cost of such services is of 5 cc.'
 ------------------
if parame then
if posx == pos1.x and posy == pos1.y then
if doPlayerRemoveMoney(cid, costss.tp) then
doTeleportThing(cid, parame[1])
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, 'You have been teleported!')
doSendMagicEffect(parame[1], CONST_ME_TELEPORT)
else
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, 'You dont have enough money to use this service.')
end
elseif posx ~= pos1.x and posy ~= pos1.y then
 doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, 'You aren't steping the sacred position.')
 elseif posx == pos1.x and posy ~= pos1.y then
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, 'You aren't steping the sacred position.')
 elseif posx ~= pos1.x and posy == pos1.y then
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, 'You aren't steping the sacred position.')
end
elseif param == 'libro' and doPlayerRemoveMoney(cid, costs.bok) then
addEvent(doShowTextDialog, 2000, cid, 7704, texto)
doSendMagicEffect(pos1, CONST_ME_POFF)
elseif param == 'libro' and not doPlayerRemoveMoney(cid, costs.bok) then
doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, 'You dont have enough money to use this service.')
end
return true
end

:)
 
Last edited:
Yes but I want to work for my originial script, I dont like script remade of other persones, you understand me?
 
Yes but I want to work for my originial script, I dont like script remade of other persones, you understand me?

But your code sucks hard. It's useless for real ots' admins. It could be usefull for newbies who don't know how to use loops. You should thank people who optimize your codes.
 

Similar threads

Back
Top