• 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.

Action Warp map

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Reaction score
106
Location
Brazil
  • Author: Mock
  • Tested on: TFS 0.3.6
With this script, you use the map(item), and it save the pos in the map (item). And when you need just use the map (item) and if you are not pz locked or infight you wil be teleported to saved pos.

I am using this map:
Golem_Blueprint.gif

Itemid 1956
If you want just change.

Add this tag on actions.xml
Code:
<action itemid="1956" event="script" value="warp_map.lua"/>
E o script:
Lua:
function onUse(cid, item, frompos, item2, topos) --Script by Mock The Bear (MTB)
	local map = getItemAttribute(item.uid,'text')
	if not map then
		local p = getCreaturePosition(cid)
		local pos_str = ('X: %d Y: %d Z: %d'):format(p.x,p.y,p.z)
		doItemSetAttribute(item.uid,'name','Map to telepor to '..pos_str)
		doItemSetAttribute(item.uid,'text',pos_str)
		doPlayerPopupFYI(cid,'You have defined position.')
		return true
	else

		if map:match('X: (%d+) Y: (%d+) Z: (%d+)') then
			local x,y,z= map:match('X: (%d+) Y: (%d+) Z: (%d+)')
			local pos = {x=tonumber(x),y=tonumber(y),z=tonumber(z)}
			if hasCondition(cid,CONDITION_INFIGHT) or isPlayerPzLocked(cid) then
				doPlayerPopupFYI(cid,'You cannot use the map now.')
				return true
			else
				if isWalkable(pos, true,true,false) then
					doTeleportThing(cid,pos)
					doRemoveItem(item.uid,1)
				else
					doPlayerPopupFYI(cid,'Invalid position')
				end
			end
		else
			doPlayerPopupFYI(cid,'Invalid position')
		end
	end
	return true
end
--Script by Mock The Bear (MTB)
function isWalkable(pos, creature, proj, pz)-- by Nord
	if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
	if getTopCreature(pos).uid > 0 and creature then return false end
	if getTileInfo(pos).protection and pz then return false, true end
	local n = not proj and 3 or 2
	for i = 0, 255 do
		pos.stackpos = i
		local tile = getTileThingByPos(pos)
		if tile.itemid ~= 0 and not isCreature(tile.uid) then
			if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
				return false
			end
		end
	end
	return true
end
 
E o script:
=
And the script:

Lua:
function isWalkable(pos, creature, proj, pz)-- by Nord
	if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
	if getTopCreature(pos).uid > 0 and creature then return false end
	if getTileInfo(pos).protection and pz then return false, true end
	local n = not proj and 3 or 2
	for i = 0, 255 do
		pos.stackpos = i
		local tile = getTileThingByPos(pos)
		if tile.itemid ~= 0 and not isCreature(tile.uid) then
			if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
				return false
			end
		end
	end
	return true
end

put in other code :)
 
Look you can just save the map in a quest room then give it to another character and come there? xddd
 
it was example, any smart person would find a way to prevent all kinds of abuse
 
@Strawberry
i know.
you can save inside one house, (one map by SQM) and sell the house, when another play buy you just use the map.

Its better use only to GMs ;D
 
Yes, it's obviously susceptible to abuse. But it's a very nice example to learn from for other things :)
 
Back
Top