• 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 LUA support

Cloow

Active Member
Joined
May 10, 2010
Messages
1,086
Reaction score
35
Hello, i want to make a teleport script.

Example - Player says !tp "<---City--->" it will teleport the player to that location.

This is my script atm.

Code:
local t = 
{        
      pos = {x=999, y=999, z=999},
}	   

function onSay(cid, words, param, channel)
     doTeleportThing(cid, local.pos, pushmove = true)
	end
	return TRUE
end


Now, if i want to make more avaible places how to ?

Example, i want it to be avaible to teleport to 7 diffrent towns.
Do i need to make 7 diffrent scripts then? Make 6 more exactly the same scripts but new ones? Or could i just repeat it in the same script?



NOTE: I dont even know if this script works or not >.<
 
Declare a table at beginning with all places, and then refer it by its key.

Code:
local t = {
	"city1" = {x=999, y=999, z=999},
	"city2" = {x=999, y=999, z=999},
	"city3" = {x=999, y=999, z=999}
}

function onSay(cid, words, param, channel)
	local pos = t[words]
	if(not pos) then
		doPlayerSendCancel(cid, "Invalid city.")
		return TRUE
	end

	doTeleportThing(cid, pos)
	return TRUE
end
 
Code:
local t = {
	[B][COLOR="Red"][[/COLOR][/B]"city1"[B][COLOR="Red"]][/COLOR][/B] = {x=999, y=999, z=999},
	[B][COLOR="Red"][[/COLOR][/B]"city2"[B][COLOR="Red"]][/COLOR][/B] = {x=999, y=999, z=999},
	[B][COLOR="Red"][[/COLOR][/B]"city3"[B][COLOR="Red"]][/COLOR][/B] = {x=999, y=999, z=999}

:p!
 
Back
Top