Action Create Escape Teleport with Awesome Countdown!

Status
Not open for further replies.

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
READ:
The item you use must be usable, eg. Star Tear. You use this and click the ground.

actions/actions.xml
PHP:
<action itemid="7735" event="script" value="teleport.lua"/>
actions/scripts/teleport.lua
Code:
local cfg = {
	time = 15, -- Time the teleport is open.
	exhausted = 60, -- Time you are exhausted.
	storage = 1337, -- Storage used for "exhaust."
	to = { x = 100, y = 100, z = 7 } -- Where the teleport takes you.
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(getPlayerStorageValue(cid, cfg.storage) > os.time()) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You must wait another " .. getPlayerStorageValue(cid, cfg.storage) - os.time() .. ' second' .. ((getPlayerStorageValue(cid, cfg.storage) - os.time()) == 1 and "" or "s") .. " to create another teleport.")
	elseif(getTilePzInfo(getCreaturePosition(cid)) == true) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You cannot create a teleport in a protection zone.")
	elseif(getCreatureCondition(cid, CONDITION_INFIGHT) == true) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You may not create a teleport while fighting.")
	elseif(hasProperty(getThingFromPos(toPosition).uid, CONST_PROP_BLOCKSOLID) == true) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You cannot create a teleport here.")
	else
		local function deleteTeleport()
			local teleport = getTileItemById(toPosition, 1387).uid
			if(teleport > 0) then
				doRemoveItem(teleport)
				doSendMagicEffect(toPosition, CONST_ME_POFF)
				doSendAnimatedText(toPosition, "Closed", TEXTCOLOR_RED)
			end
			return true
		end
		for x = 1, cfg.time do
		local n = cfg.time - x
			addEvent(doSendAnimatedText, x * 1000, toPosition, n > 0 and tostring(n), TEXTCOLOR_WHITE)
		end
		doCreateTeleport(1387, cfg.to, toPosition)
		doSendMagicEffect(toPosition, CONST_ME_ENERGYAREA)
		addEvent(deleteTeleport, cfg.time * 1000)
		setPlayerStorageValue(cid, cfg.storage, os.time() + cfg.exhausted)
	end
	return true
end
 
Last edited:

Fallen

Freelancer
Joined
Aug 21, 2009
Messages
3,713
Best answers
0
Reaction score
247
Location
Egypt
This is a nice script, Rep++ for sure! God job m8:thumbup:
 

Lava Titan

Developer
Joined
Jul 25, 2009
Messages
1,495
Best answers
0
Reaction score
1
Location
Portugal
If use star tear on the pos that you go when you step in the teleport your server will crash.
 

Znote

<?php echo $title; ?>
Staff member
Global Moderator
Premium User
Joined
Feb 14, 2008
Messages
6,668
Best answers
202
Reaction score
1,376
Location
Norway, Oslo
Closed on authors request, he doesn't support it any longer.
 
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
Opened

Feel free to comment. :thumbup:
 

calum69

New Member
Joined
Aug 12, 2007
Messages
346
Best answers
0
Reaction score
3
Location
Great Britain
is the bug fixed then? because otherwise this is useless, unless you use it to teleport into something that you cant create a teleporter onto (wall, tree, etc....)

its an awesome script but being able to create a teleport on the square you teleport to makes the serv crash, please fix :)
 
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
is the bug fixed then? because otherwise this is useless, unless you use it to teleport into something that you cant create a teleporter onto (wall, tree, etc....)

its an awesome script but being able to create a teleport on the square you teleport to makes the serv crash, please fix :)
It doesn't create on walls, no worries. ^_^
 

calum69

New Member
Joined
Aug 12, 2007
Messages
346
Best answers
0
Reaction score
3
Location
Great Britain
It doesn't create on walls, no worries. ^_^
Is it possible to make a function that doesnt allow you to create a teleport on x pos? so u cant create a teleport on the destination sqm? atm i have it teleporting onto a tree so you cant crash the server
 

Cykotitan

Experienced G'
Joined
Nov 4, 2008
Messages
16,894
Best answers
4
Reaction score
817
Code:
	elseif[B][COLOR="Red"]([/COLOR][/B]hasProperty([B][COLOR="Red"]getThingFromPos(toPosition)[/COLOR][/B].uid, CONST_PROP_BLOCKSOLID)[B][COLOR="Red"] == true)[/COLOR][/B] then
=
Code:
	elseif hasProperty([B][COLOR="Red"]itemEx[/COLOR][/B].uid, CONST_PROP_BLOCKSOLID) then
 

Jano

oturhaN
Joined
Feb 21, 2008
Messages
876
Best answers
0
Reaction score
67
Location
Chile
Code:
    elseif[B][COLOR=Red]([/COLOR][/B]hasProperty([B][COLOR=Red]getThingFromPos(toPosition)[/COLOR][/B].uid, CONST_PROP_BLOCKSOLID)[B][COLOR=Red] == true)[/COLOR][/B] then
=
Code:
    elseif hasProperty([B][COLOR=Red]itemEx[/COLOR][/B].uid, CONST_PROP_BLOCKSOLID) then
both are wrong, he should check the entire tile, because ...





Is it possible to make a function that doesnt allow you to create a teleport on x pos? so u cant create a teleport on the destination sqm? atm i have it teleporting onto a tree so you cant crash the server
Lua:
local notAllowed =
    {
        {x = 100, y = 100, z = 7},
        {x = 200, y = 200, z = 7}
    }
    
function comparePos(pos, pos_)
    return (pos.x == pos_.x and pos.y == pos_.y and pos.z == pos_.z)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    for _, pos in ipairs(notAllowed) do
        if comparePos(pos, toPosition) then
            return false
        end
    end
    --Script
    return true
end
 
Last edited:
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
It doesn't create on any wall or tree, but it can take you there.
 

Jano

oturhaN
Joined
Feb 21, 2008
Messages
876
Best answers
0
Reaction score
67
Location
Chile
It doesn't create on any wall or tree, but it can take you there.
check my image and reproduce what i mean :x if there is a item (without block prop) upon other that have block prop, you can... 8D
 
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
check my image and reproduce what i mean :x if there is a item (without block prop) upon other that have block prop, you can... 8D
Okay, but regular players cannot move onto a rock and create an item.
I will still change it though, when I get some time.
 

Jano

oturhaN
Joined
Feb 21, 2008
Messages
876
Best answers
0
Reaction score
67
Location
Chile
Okay, but regular players cannot move onto a rock and create an item.
I will still change it though, when I get some time.
what about of item loaded with map, like a npc shop with runes 8D, look for my function tile checker (in train / car / some post) it could help you.
 
Status
Not open for further replies.
Top