• 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 Advanced Teleportation by Marks

Delirium

OTLand veteran
Staff member
Global Moderator
Joined
May 28, 2007
Messages
3,365
Solutions
1
Reaction score
289
Location
Athens, Greece
Hello. Once again I was bored and I wrote a nob script. With this script you can specify map marks and gamemasters can teleport there by specifying the mark's name.

First add this file on talkactions/scripts folder:
marks.lua
Lua:
-- KuGaSh1rA's Mark Teleportation Script -- 
local marks = 
{
    { "temple", {x = 1000, y = 1000, z = 7}, "City Temple" },
    { "depot", {x = 1000, y = 1000, z = 7}, "City Depot" }
}
local accessToUse = 3

function onSay(cid, words, param, channel)
	if param == "" then
		warnPlayer(cid, "Command requires a parameter.")
		return TRUE
	end
	
	if getPlayerAccess(cid) >= accessToUse then
		param = param:lower()
		tmp = getPlayerPosition(cid)
		for _, m in ipairs(marks) do
			if(m[1] == param) then
				doSendMagicEffect(tmp, CONST_ME_POFF)
				doTeleportThing(cid, m[2])
				doSendMagicEffect(m[2], CONST_ME_TELEPORT)
				doPlayerSendTextMessage(cid, 25, "You have been teleporter to the " ..m[3]..".")
			else
				warnPlayer(cid, "Teleportation mark does not exist.")
			end
		end
	else
		warnPlayer(cid, "You cannot execute this command.")
	end
	return TRUE
end

function warnPlayer(cid, message)
	doPlayerSendCancel(cid, message)
	doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
Then in talkactions.xml add this:
talkactions.xml
HTML:
<talkaction log="yes" access="3" words="/marktp" event="script" value="marks.lua"/>

Do not forget to edit these:
Lua:
local marks = 
{
	{ "temple", {x = 1000, y = 1000, z = 7}, "City Temple" },
	{ "depot", {x = 1000, y = 1000, z = 7}, "City Depot" }
}

In case you wish to add more marks then simply do this:
Add a comma (,) at the end of this line:
Lua:
{ "depot", {x = 1000, y = 1000, z = 7}, "City Depot" }

and after it add:
Lua:
{ "markname", {x = 1000, y = 1000, z = 7}, "fullplacenamehere" }

If you have any further question do not hesitate to post.
 
Last edited:
local accessToUse = 3 - For GM ^^


or add:

if (hasCondition(cid, CONDITION_INFIGHT) == FALSE) then

....


else
doPlayerSendCancel(cid, 'Can not teleport after the fight!')
end
 
/town?
Then add your "marks" as towns in your map editor.

Would take you a lot of time and could be a waste. Not to mention that you can add a lot of places without the need of editing your map.
 
sry but wont use this. why do u waste computer power with for when u can use if o_O u need learn how to use tables i guess. anyways rest looks good. also why have access-check in both xml and script also total waste

another thing: for lol, m in ipairs(marks) do

wtf? that n00b scripting. if you dont need to use the first syntax, use for _, m ......... no lol
 
Agreed gregg there are a couple of things to put a finger on in this script. Its good scripting, but you are choosing the wrong methods for this kind of script :p

I rewrote the script to show how I would've made it:

(Assuming you use 0,3 and access-check in xml)
PHP:
local marks = 
{
    ["temple"] = {{x=100,y=100,z=7}, "City Temple" },
    ["depot"] = {{x=100,y=100,z=7}, "City Depot" }
}

function onSay(cid, words, param)
local pos = marks[string.lower(param)]
	if pos ~= nil then
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
		doTeleportThing(cid, pos[1])
		doSendMagicEffect(pos[1], CONST_ME_TELEPORT)
		doPlayerSendTextMessage(cid, 25, "You have been teleporter to the " ..pos[2]..".")
	else
		warnPlayer(cid, "Teleportation mark does not exist.")
	end			
	return TRUE
end

Keep scripting, im sure you will learn fast
 
sry but wont use this. why do u waste computer power with for when u can use if o_O u need learn how to use tables i guess. anyways rest looks good. also why have access-check in both xml and script also total waste

another thing: for lol, m in ipairs(marks) do

wtf? that n00b scripting. if you dont need to use the first syntax, use for _, m ......... no lol

Didn't know what _ was for :p
I tried to do it the way Tufte did but for some reason I am getting an error.Also I wrote the access check so the script can be used with old tfs versions too

@Tufte
Thanks bro ;)
 
i think the reason you couldnt do it, was because your table was wrong set up. look how i made the table, and im 100% sure you would have done it without loop
 
Back
Top