• 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 Teleport for GMs/all players (for nob servers)

Gesior.pl

Mega Noob&LOL 2012
Senator
Joined
Sep 18, 2007
Messages
3,389
Solutions
125
Reaction score
4,255
Location
Poland
GitHub
gesior
TESTED ON TFS 0.3.4pl2
-----------------------------------------
Script requested:
http://otland.net/f132/request-advanced-tp-commands-48765/
How to use:
(X = number)
!savepos X - save player position with ID X (empty position name)
!savepos X,name - save player position with ID X and name
!deletepos X - delete saved position with ID X
!pos X - teleport player to position with ID X
!pos - (without parameter) show saved positions
10:45 Saved positions ( ID - name ):
10:45 2 - Trainers
10:45 3 - depo in Carlin
10:45 4 - depo in Thais
10:45 5 - waz
10:45 7 - Spawn
for pvp servers/servers without teleports to monsters better leave SAVE_ONLY_IN_PZ and TELEPORT_ONLY_IN_PZ = true or players will abuse it to trap or stack on one position and combo [pvp]
-----------------------------------------
In data/talkactions/talkactions.xml remove:
PHP:
<talkaction log="yes" access="1" words="!pos" event="script" value="position.lua"/>
In data/talkactions/talkactions.xml add:
PHP:
	<talkaction words="!savepos" event="script" value="advtp.lua"/>
	<talkaction words="!deletepos" event="script" value="advtp.lua"/>
	<talkaction words="!pos" event="script" value="advtp.lua"/>
(you can add access="3" to each line to block it only for GMs)
PHP:
PLAYER_STORAGE_START_VALUE = 11350 -- script use storages from this id to +400 ids
MAX_NUMBER_OF_POSITION = 10 -- player can save max. 10 positions, script limit is 100
SAVE_ONLY_IN_PZ = true -- player can save position only when he is in PZ (house/depot/trainers?) - true/false
TELEPORT_ONLY_IN_PZ = true -- player can teleport to position only when he is in PZ (house/depot/trainers?) - true/false
GROUP_ID_NOT_BLOCKED = 3 -- players with that group can teleport from/to any position


function onSay(cid, words, param, channel)
	if(param == "") then
		if(words == '!pos') then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Saved positions ( ID - name ):")
			for i = 1, MAX_NUMBER_OF_POSITION do
				local posName = getPlayerStorageValue(cid, PLAYER_STORAGE_START_VALUE + i + 300)
				if(posName ~= -1) then
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, i .. " - " .. posName)
				end
			end
		end
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
		return TRUE	
	end
	local params = string.explode(param, ",")
	params[1] = tonumber(params[1])
	local pos = getCreaturePosition(cid)
	if(#params == 1) then
		params[2] = ""
	end
	if(words == '!savepos') then
		if(params[1] < 1 or params[1] > MAX_NUMBER_OF_POSITION) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Position ID (first parameter) must be between 1 and " .. MAX_NUMBER_OF_POSITION)
			return TRUE
		end
		if(SAVE_ONLY_IN_PZ and getPlayerGroupId(cid) < GROUP_ID_NOT_BLOCKED and getTileInfo(pos).protection == true) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can save positions only when you are in protection zone.")
			return TRUE
		end
		setPlayerStorageValue(cid, PLAYER_STORAGE_START_VALUE + params[1], pos.x)
		setPlayerStorageValue(cid, PLAYER_STORAGE_START_VALUE + params[1] + 100, pos.y)
		setPlayerStorageValue(cid, PLAYER_STORAGE_START_VALUE + params[1] + 200, pos.z)
		setPlayerStorageValue(cid, PLAYER_STORAGE_START_VALUE + params[1] + 300, params[2])
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Position ID " .. params[1] .. " (" .. params[2] .. ") saved.")
	elseif(words == '!deletepos') then
		if(params[1] < 1 or params[1] > MAX_NUMBER_OF_POSITION) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Position ID (first parameter) must be between 1 and " .. MAX_NUMBER_OF_POSITION)
			return TRUE
		end
		setPlayerStorageValue(cid, PLAYER_STORAGE_START_VALUE + params[1], -1)
		setPlayerStorageValue(cid, PLAYER_STORAGE_START_VALUE + params[1] + 100, -1)
		setPlayerStorageValue(cid, PLAYER_STORAGE_START_VALUE + params[1] + 200, -1)
		setPlayerStorageValue(cid, PLAYER_STORAGE_START_VALUE + params[1] + 300, -1)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Position ID " .. params[1] .. " deleted.")
	elseif(words == '!pos') then
		if(params[1] < 1 or params[1] > MAX_NUMBER_OF_POSITION) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Position ID (first parameter) must be between 1 and " .. MAX_NUMBER_OF_POSITION)
			return TRUE
		end
		if(TELEPORT_ONLY_IN_PZ and getPlayerGroupId(cid) < GROUP_ID_NOT_BLOCKED and getTileInfo(pos).protection == true) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can teleport to positions only when you are in protection zone.")
			return TRUE
		end
		strPos = getPlayerStorageValue(cid, PLAYER_STORAGE_START_VALUE + params[1])
		if(strPos == -1) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You didn't save positon with ID " .. params[1])
			return TRUE
		end
		toPos = {x = getPlayerStorageValue(cid, PLAYER_STORAGE_START_VALUE + params[1]), y = getPlayerStorageValue(cid, PLAYER_STORAGE_START_VALUE + params[1] + 100), z = getPlayerStorageValue(cid, PLAYER_STORAGE_START_VALUE + params[1] + 200)}
		posName = getPlayerStorageValue(cid, PLAYER_STORAGE_START_VALUE + params[1] + 300)
		if(doTeleportThing(cid, toPos, TRUE) ~= LUA_ERROR and isPlayerGhost(cid) ~= TRUE) then
			doSendMagicEffect(pos, CONST_ME_POFF)
			doSendMagicEffect(toPos, CONST_ME_TELEPORT)
		end
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You were teleported to position ID " .. params[1] .. " - " .. posName)
	end
	return TRUE
end
 
yes but i have already solved it took me a bit but i got it
thank you for responding to my question though ^^
for people who have the same question do this
after
function onSay(cid, words, param, channel


add this

if getPlayerStorageValue(cid, vip) < 1 then
doPlayerSendCancel(cid, "You must be a vip player to use this command.")
return TRUE
end
 
very good script.
great idea gesior.pl
thank you i have make this one script for me using your idea.
 
Back
Top