• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action Tp Item

Wazzap

Killing Elite
Joined
Jun 15, 2010
Messages
124
Reaction score
4
Location
London / Poland
If Can by use one time
Data/Actions/Scripts/tpitem.lua
local config = {
teleportOnlyIfNoBattle = 1,
teleportToTemple = 1,
teleportPosition = { x=1000, y=1000, z=7 },
removeItem = 1,
startMagicEffect = 2,
destinationMagicEffect = 10,
errorMessage = "You may not use teleportation while you have battle!"
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if config.teleportOnlyIfNoBattle == 1 then
if getCreatureCondition(cid, 1024) == FALSE then
if config.teleportToTemple == 1 then
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid))) doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)), config.destinationMagicEffect)
doSendMagicEffect(toPosition, config.startMagicEffect)
if config.removeItem == 1 then
doRemoveItem(item.uid, 1)
else
return FALSE
end
else
doTeleportThing(cid, config.teleportPosition)
doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)), config.destinationMagicEffect)
doSendMagicEffect(toPosition, config.startMagicEffect)
if config.removeItem == 1 then
doRemoveItem(item.uid, 1)
else
return FALSE
end
end
else
doPlayerSendCancel(cid, config.errorMessage)
end
else
if config.teleportToTemple == 1 then
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)), config.destinationMagicEffect) -- daj efekt na miejscu
doSendMagicEffect(toPosition, config.startMagicEffect)
if config.removeItem == 1 then
doRemoveItem(item.uid, 1)
else
return FALSE
end
else doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)), config.destinationMagicEffect)
doSendMagicEffect(toPosition, config.startMagicEffect)
if config.removeItem == 1 then
doRemoveItem(item.uid, 1)
else
return FALSE
end
end
end
end

actions.xml
<action itemid="ID ITEM" script="tpitem.lua" />
 
not working...
error :
[21/06/2010 14:48:43] [Error - LuaScriptInterface::loadFile] data/actions/scripts/tp scroll.lua:14: ')' expected near 'own'
[21/06/2010 14:48:43] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/tp scroll.lua)
[21/06/2010 14:48:43] data/actions/scripts/tp scroll.lua:14: ')' expected near 'own'
[21/06/2010 14:48:43] [Error - LuaScriptInterface::loadFile] data/globalevents/scripts/magic effect.lua:27: ')' expected (to close '(' at line 26) near 'end'
[21/06/2010 14:48:43] [Warning - Event::loadScript] Cannot load script (data/globalevents/scripts/magic effect.lua)
[21/06/2010 14:48:43] data/globalevents/scripts/magic effect.lua:27: ')' expected (to close '(' at line 26) near 'end'
 
This one will work:

PHP:
local config = {
teleportOnlyIfNoBattle = 1,
teleportToTemple = 1,
teleportPosition = { x=1000, y=1000, z=7 },
removeItem = 1,
startMagicEffect = 2,
destinationMagicEffect = 10,
errorMessage = "You may not use teleportation while you have battle!"
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if config.teleportOnlyIfNoBattle == 1 then
if getCreatureCondition(cid, 1024) == FALSE then
if config.teleportToTemple == 1 then
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid))) doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)), config.destinationMagicEffect)
doSendMagicEffect(toPosition, config.startMagicEffect)
if config.removeItem == 1 then
doRemoveItem(item.uid, 1)
else
return FALSE
end
else
doTeleportThing(cid, config.teleportPosition)
doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)), config.destinationMagicEffect)
doSendMagicEffect(toPosition, config.startMagicEffect)
if config.removeItem == 1 then
doRemoveItem(item.uid, 1)
else
return FALSE
end
end
else
doPlayerSendCancel(cid, config.errorMessage)
end
else
if config.teleportToTemple == 1 then
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)), config.destinationMagicEffect) -- daj efekt na miejscu
doSendMagicEffect(toPosition, config.startMagicEffect)
if config.removeItem == 1 then
doRemoveItem(item.uid, 1)
else
return FALSE
end
else doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)), config.destinationMagicEffect)
doSendMagicEffect(toPosition, config.startMagicEffect)
if config.removeItem == 1 then
doRemoveItem(item.uid, 1)
else
return FALSE
end
end
end
end
 
PHP:
local config = {
			teleportOnlyIfNoBattle = 1,
			teleportToTemple = 1,
			teleportPosition = { x=1000, y=1000, z=7 },
			removeItem = 1,
			startMagicEffect = 2,
			destinationMagicEffect = 10,
			errorMessage = "You may not use teleportation while you have battle!"
			}			
function onUse(cid, item, fromPosition, itemEx, toPosition)
			if config.teleportOnlyIfNoBattle == 1 then
				if getCreatureCondition(cid, 1024) == FALSE then
					if config.teleportToTemple == 1 then
						doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid))) doSendMagicEffect(getTownTemplePosition(getPlayerT own(cid)), config.destinationMagicEffect)
						doSendMagicEffect(toPosition, config.startMagicEffect)
							if config.removeItem == 1 then
							doRemoveItem(item.uid, 1)
							else
					return FALSE
				end
			else
				doTeleportThing(cid, config.teleportPosition)
				doSendMagicEffect(getTownTemplePosition(getPlayerT own(cid)), config.destinationMagicEffect)
				doSendMagicEffect(toPosition, config.startMagicEffect)	
		
							if config.removeItem == 1 then
								doRemoveItem(item.uid, 1)
							else
						return FALSE
					end
				end
			else
			doPlayerSendCancel(cid, config.errorMessage)
			end
		else
			if config.teleportToTemple == 1 then
				doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
				doSendMagicEffect(getTownTemplePosition(getPlayerT own(cid)), config.destinationMagicEffect) -- daj efekt na miejscu
				doSendMagicEffect(toPosition, config.startMagicEffect)		
			if config.removeItem == 1 then
				doRemoveItem(item.uid, 1)
			else
		return FALSE
		end
			else doSendMagicEffect(getTownTemplePosition(getPlayerT own(cid)), config.destinationMagicEffect)
					doSendMagicEffect(toPosition, config.startMagicEffect)
				if config.removeItem == 1 then
					doRemoveItem(item.uid, 1)
				else
				return FALSE
			end
		end
	end
end

Tabbed correctly ?
sorry if no :( just learning :/
 
:peace:
LUA:
function onUse(cid, item, frompos, item2, topos)
ppos = getPlayerPosition(cid)
temple = getPlayerMasterPos(cid)
if ((getTilePzInfo(getPlayerPosition(cid)) ~= true) and (getCreatureCondition(cid, CONDITION_INFIGHT) == FALSE)) then
doRemoveItem(item.uid,2)
doTeleportThing(cid, temple, TRUE)
doSendMagicEffect(ppos,66)
doSendAnimatedText(frompos,'Teleport!',16)
else
doPlayerSendCancel(cid,"You can't teleport immediately after fight or leave PZ zone.")
doSendMagicEffect(ppos,2)
end
return 1
end

:peace:
 
LUA:
local config = {
	teleportOnlyIfNoBattle = true,
	teleportToTemple = true,
	teleportPosition = { x=1000, y=1000, z=7 },
	removeItem = true,
	startMagicEffect = 2, --poff
	destinationMagicEffect = 10, --TP
	errorMessage = "You may not use teleportation while you have battle!"
	}
	
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if config.teleportOnlyIfNoBattle and getCreatureCondition(cid, 1024) then	
		return doPlayerSendCancel(cid, config.errorMessage);
	end
	doSendMagicEffect(getCreaturePosition(cid), config.startMagicEffect);
	doTeleportThing(cid, config.teleportToTemple and getPlayerMasterPos(cid) or config.teleportPosition);
	doSendMagicEffect(getCreaturePosition(cid), config.destinationMagicEffect);
	return config.removeItem and doRemoveItem(item.uid, 1) or true;
end
heh..
 
Last edited:
Back
Top