• 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 OTX 2 Adventurer's Stone

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
871
Solutions
19
Reaction score
409
Location
Santiago - Chile
Hi again! I would like to request a script for OTX 2 (TFS 0.3.7) version 8.60. Something similar to the adventurer's stone, the request is:
  1. Be able to use the item to teleport to a certain place, with a cooldown on use.
  2. Requeriement of dont be in fight (players or pve)
  3. Automatically give the "adventurer stone" to players who has died recently.
  4. Get back to the position where you use the item when leaving the zone.
Hope someone can gift me this!
Best wishes, ralke
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,541
Solutions
384
Reaction score
3,664
Lua:
local teleport_location = {x = 1000, y = 1000, z = 7}

local positionStorage = {x = 45001,	y = 45002, z = 45003} -- change storages to un-used values
local cooldown = {} -- used to hold player information for cooldown

function onUse(cid, item, fromPosition, itemEx, toPosition)
	
	-- cooldown
	if cooldown[cid] and cooldown[cid] > os.time() then
		doSendMagicEffect(fromPosition, CONST_ME_POFF)
		doPlayerSendCancel(cid, "Item on cooldown.")
		return true
	end
	cooldown[cid] = os.time() + 5
	
	-- in-fight
	if getCreatureCondition(cid, CONDITION_INFIGHT) then
		doSendMagicEffect(fromPosition, CONST_ME_POFF)
		doPlayerSendCancel(cid, "Can't use this object while in combat.")
		return true
	end
	
	-- teleport to destination
	if getPlayerStorageValue(cid, positionStorage.x) < 0 then
		local currentPosition = getCreaturePosition(cid)
		setPlayerStorageValue(cid, positionStorage.x, currentPosition.x)
		setPlayerStorageValue(cid, positionStorage.y, currentPosition.y)
		setPlayerStorageValue(cid, positionStorage.z, currentPosition.z)
		doTeleportThing(cid, teleport_location)	
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You've been teleported to blah blah. Use the item again to teleport back to your previous location.")
		return true
	end
	
	-- teleport back
    local backPosition = {x = getPlayerStorageValue(cid, positionStorage.x), y = getPlayerStorageValue(cid, positionStorage.y), z = getPlayerStorageValue(cid, positionStorage.z)}
	doTeleportThing(cid, backPosition)	
	setPlayerStorageValue(cid, positionStorage.x, -1)
	setPlayerStorageValue(cid, positionStorage.y, -1)
	setPlayerStorageValue(cid, positionStorage.z, -1)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You've been teleported to your previous location.")
	return true
end
 
Last edited:

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,541
Solutions
384
Reaction score
3,664
Hi again! I would like to request a script for OTX 2 (TFS 0.3.7) version 8.60. Something similar to the adventurer's stone, the request is:
  1. Be able to use the item to teleport to a certain place, with a cooldown on use.
  2. Requeriement of dont be in fight (players or pve)
  3. Automatically give the "adventurer stone" to players who has died recently.
  4. Get back to the position where you use the item when leaving the zone.
Hope someone can gift me this!
Best wishes, ralke
Let me know if it works as intended?
 
OP
ralke

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
871
Solutions
19
Reaction score
409
Location
Santiago - Chile
@Xikini Yes for sure! Im currently full of job at work 😵, but as soon I get free time I'll test as always, thanks again, you're always helping me on this stuff
 
OP
ralke

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
871
Solutions
19
Reaction score
409
Location
Santiago - Chile
@Xikini works perfectly, no errors on console. But it has one glitch, we need to make a requierement that you only can use the item if the item is in a backpack, the reason, is that if you use the item on the floor, you will get teleported and you won't have an item to get back to your starting position. Even better, dont be allowed to drop the item untill you go back to the starting position. thanks again!

Also.. If you can add a cooldown that starts after using the item two times (after teleport and comming back) of 15 minutes I'll aprecciate that a lot! It would be helpfull :)
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,541
Solutions
384
Reaction score
3,664
@Xikini works perfectly, no errors on console. But it has one glitch, we need to make a requierement that you only can use the item if the item is in a backpack, the reason, is that if you use the item on the floor, you will get teleported and you won't have an item to get back to your starting position. Even better, dont be allowed to drop the item untill you go back to the starting position. thanks again!

Also.. If you can add a cooldown that starts after using the item two times (after teleport and comming back) of 15 minutes I'll aprecciate that a lot! It would be helpfull :)
There is no good way to stop people from dropping the item, unfortunately.
If you stop them from dropping it, they'll trade it, or they'll put it in a depot, or they'll put it in a bag and drop the bag.
Too many things to account for.

The additional timers, and the requirement of the item being in the players inventory are things I can do, tho.

Lua:
local teleport_location = {x = 1000, y = 1000, z = 7}

local positionStorage = {x = 45001,	y = 45002, z = 45003} -- change storages to un-used values
local cooldown = {} -- used to hold player information for cooldown

function onUse(cid, item, fromPosition, itemEx, toPosition)
	
	-- cooldown
	local cur_time = os.time()
	if cooldown[cid] and cooldown[cid] > cur_time then
		doSendMagicEffect(fromPosition, CONST_ME_POFF)
		doPlayerSendCancel(cid, "Item on cooldown. " .. os.date('!%T', (cooldown[cid] - cur_time)))
		return true
	end
	cooldown[cid] = cur_time + 5
	
	-- in-fight
	if getCreatureCondition(cid, CONDITION_INFIGHT) then
		doSendMagicEffect(fromPosition, CONST_ME_POFF)
		doPlayerSendCancel(cid, "Can't use this object while in combat.")
		return true
	end
	
	-- item must be in player inventory
	if fromPosition.x == 65535 then
		doSendMagicEffect(fromPosition, CONST_ME_POFF)
		doPlayerSendCancel(cid, "This object must be in your inventory to be used.")
		return true
	end
	
	-- teleport to destination
	if getPlayerStorageValue(cid, positionStorage.x) < 0 then
		local currentPosition = getCreaturePosition(cid)
		setPlayerStorageValue(cid, positionStorage.x, currentPosition.x)
		setPlayerStorageValue(cid, positionStorage.y, currentPosition.y)
		setPlayerStorageValue(cid, positionStorage.z, currentPosition.z)
		doTeleportThing(cid, teleport_location)	
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You've been teleported to blah blah. Use the item again to teleport back to your previous location.")
		return true
	end
	
	-- teleport back
    local backPosition = {x = getPlayerStorageValue(cid, positionStorage.x), y = getPlayerStorageValue(cid, positionStorage.y), z = getPlayerStorageValue(cid, positionStorage.z)}
	doTeleportThing(cid, backPosition)	
	setPlayerStorageValue(cid, positionStorage.x, -1)
	setPlayerStorageValue(cid, positionStorage.y, -1)
	setPlayerStorageValue(cid, positionStorage.z, -1)
	cooldown[cid] = cur_time + 900 -- 900 = 15 minutes cooldown
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You've been teleported to your previous location.")
	return true
end
Post automatically merged:

This post will probably get merged. xD

But, because of the extended cooldown timer of 15 minutes, it's prudent that we use a storage value instead of the table now, otherwise a player could logout and back in to get a new cid, and no longer be on cooldown.

Please use this updated version.

Lua:
local teleport_location = {x = 1000, y = 1000, z = 7}

local positionStorage = {x = 45001,	y = 45002, z = 45003} -- change storages to un-used values
local cooldownStorage = 45004

function onUse(cid, item, fromPosition, itemEx, toPosition)
	
	-- cooldown
	local cur_time = os.time()
	local cooldown = getPlayerStorageValue(cid, cooldownStorage)
	if cooldown > cur_time then
		doSendMagicEffect(fromPosition, CONST_ME_POFF)
		doPlayerSendCancel(cid, "Item on cooldown. " .. os.date('!%H:%M:%S', (cooldown - cur_time)))
		return true
	end
	setPlayerStorageValue(cid, cooldownStorage, cur_time + 5)
	
	-- in-fight
	if getCreatureCondition(cid, CONDITION_INFIGHT) then
		doSendMagicEffect(fromPosition, CONST_ME_POFF)
		doPlayerSendCancel(cid, "Can't use this object while in combat.")
		return true
	end
	
	-- item must be in player inventory
	if fromPosition.x == 65535 then
		doSendMagicEffect(fromPosition, CONST_ME_POFF)
		doPlayerSendCancel(cid, "This object must be in your inventory to be used.")
		return true
	end
	
	-- teleport to destination
	if getPlayerStorageValue(cid, positionStorage.x) < 0 then
		local currentPosition = getCreaturePosition(cid)
		setPlayerStorageValue(cid, positionStorage.x, currentPosition.x)
		setPlayerStorageValue(cid, positionStorage.y, currentPosition.y)
		setPlayerStorageValue(cid, positionStorage.z, currentPosition.z)
		doTeleportThing(cid, teleport_location)	
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You've been teleported to blah blah. Use the item again to teleport back to your previous location.")
		return true
	end
	
	-- teleport back
    local backPosition = {x = getPlayerStorageValue(cid, positionStorage.x), y = getPlayerStorageValue(cid, positionStorage.y), z = getPlayerStorageValue(cid, positionStorage.z)}
	doTeleportThing(cid, backPosition)	
	setPlayerStorageValue(cid, positionStorage.x, -1)
	setPlayerStorageValue(cid, positionStorage.y, -1)
	setPlayerStorageValue(cid, positionStorage.z, -1)
	setPlayerStorageValue(cid, cooldownStorage, cur_time + 900)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You've been teleported to your previous location.")
	return true
end
 
Last edited:
OP
ralke

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
871
Solutions
19
Reaction score
409
Location
Santiago - Chile
@Xikini the first one crashes the server, and the second one (that you merged) is sending me this message on use
advstone.png

other observations are that the cooldown of 5 second is working good. I used the key of numerous locks as action item.
thanks for replying :) I will be attentive to the changes
 
Last edited:

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,541
Solutions
384
Reaction score
3,664
@Xikini the first one crashes the server, and the second one (that you merged) is sending me this message on use
View attachment 53458

other observations are that the cooldown of 5 second is working good. I used the key of numerous locks as action item.
thanks for replying :) I will be attentive to the changes
There's no way my script crashed the server. lol
At best it'd show an error in console.

Anyway, to fix the issue..
Lua:
if fromPosition.x == 65535 then
change to
Lua:
if fromPosition.x ~= 65535 then
 
Top