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

Teleport to pos with storageids

Cloow

Active Member
Joined
May 10, 2010
Messages
1,086
Reaction score
35
Hello, can someone please fix my script?
When entering a tile, you get teleported to your specific storageid

I can't see what im doing wrong.
Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) 
 
local config = {
		{storage = 10001, position = {x=1023, y=1017, z=6}, msg = "Floor [1]"},
		{storage = 10002, position = {x=1023, y=1017, z=5}, msg = "Floor [2]"},
		{storage = 10003, position = {x=1023, y=1017, z=4}, msg = "Floor [3]"},
		{storage = 10004, position = {x=1023, y=1017, z=3}, msg = "Floor [4]"},
		{storage = 10005, position = {x=1023, y=1017, z=2}, msg = "Floor [5]"},
		{storage = 10006, position = {x=1023, y=1017, z=1}, msg = "Floor [6]"},
		{storage = 10007, position = {x=1023, y=1017, z=0}, msg = "Floor [7]"}
}
if getCreatureStorage(cid, config.storage) >= 1 then
	doTeleportThing(cid, config.position)
	doSendMagicEffect(getCreaturePosition(cid),CONST_ME_TELEPORT)
	doSendMagicEffect(config.position, CONST_ME_TELEPORT)
	else
	doPlayerSendCancel(cid, "You can't go there right now")
	end
return true
end

upon entering the tile, it just sends me the cancel message. No console errors.

--------------------------------------------------------------------------------
Script for getting storageids (works properly I think)
Lua:
function onStepIn(cid, item, position, fromPosition)
	local pos = getCreaturePosition(cid)
	if(isPlayer(cid) and getCreatureStorage(cid, 10002) ~= 1) then
		doCreatureSetStorage(cid, 10002, 1)
		doPlayerSetStorageValue(cid, 10001, -1) -- removes the storageid for the old floor
		doCreatureSay(cid, "You've reached Floor [2]", TALKTYPE_MONSTER)
		doSendMagicEffect(pos, CONST_ME_MAGIC_RED)
	end
	return true
end

- - - Updated - - -

Like this
http://otland.net/f82/advanced-checkpoint-system-172371/
but without the dialog and opportunity to choose checkpoint, instead just teleport the player to its storageid without questions asked.
 
Hello,

I would love to help you, but since i haven't learnt much about tables its hard for me to read it :/

So im bumping for you and hopefully someone can explain.
 
I've been gone from this community for a while now, and I've forgot a bit, but I hope this works. If not, i'll try to help
Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) 
 
	local config = {
			{storage = 10001, position = {x=1023, y=1017, z=6}, msg = "Floor [1]"},
			{storage = 10002, position = {x=1023, y=1017, z=5}, msg = "Floor [2]"},
			{storage = 10003, position = {x=1023, y=1017, z=4}, msg = "Floor [3]"},
			{storage = 10004, position = {x=1023, y=1017, z=3}, msg = "Floor [4]"},
			{storage = 10005, position = {x=1023, y=1017, z=2}, msg = "Floor [5]"},
			{storage = 10006, position = {x=1023, y=1017, z=1}, msg = "Floor [6]"},
			{storage = 10007, position = {x=1023, y=1017, z=0}, msg = "Floor [7]"}
	}
	
	for i = 1, #config do
		if(getCreatureStorage(cid, config.storage[i][1]) >= 1) then
			doTeleportThing(cid, config.position[i][2])
			doSendMagicEffect(getCreaturePosition(cid),CONST_ME_TELEPORT)
			doSendMagicEffect(config.position[i][2], CONST_ME_TELEPORT)
		else
			doPlayerSendCancel(cid, "You can't go there right now")
		end
	end
return true
end
 
with one storage you can make it a way shorter while -1 and 0 are cancel positions(set position near tile to throw them away)
Code:
function onStepIn(cid, item, pos)

config = {
[-1] = {x=512, y=512, z=7},
[0] = {x=512, y=512, z=7},
[1] = {x=1000, y=1000, z=7},
[2] = {x=854, y=771, z=7}
}

doTeleportThing(cid,config[getCreatureStorage(cid, 10001)])
doSendMagicEffect(getCreaturePosition(cid),CONST_ME_TELEPORT)
if getCreatureStorage(cid, 10001) <= 0 then
doPlayerSendCancel(cid, "You can't go there right now")
end
return 1
end
 
with one storage you can make it a way shorter while -1 and 0 are cancel positions(set position near tile to throw them away)
Code:
function onStepIn(cid, item, pos)

config = {
[-1] = {x=512, y=512, z=7},
[0] = {x=512, y=512, z=7},
[1] = {x=1000, y=1000, z=7},
[2] = {x=854, y=771, z=7}
}

doTeleportThing(cid,config[getCreatureStorage(cid, 10001)])
doSendMagicEffect(getCreaturePosition(cid),CONST_ME_TELEPORT)
if getCreatureStorage(cid, 10001) <= 0 then
doPlayerSendCancel(cid, "You can't go there right now")
end
return 1
end

Works with the first floor, after that it just sends me cancel no console errors

Im not quite sure it should look like this. I need to remove the storageid totally from the player. Since when they reach checkpoint nr 2 storageid from checkpoint nr 1 should be removed
wt-qng.png


Lua:
doPlayerSetStorageValue(cid, 10001, 0)
instead of
Lua:
doPlayerSetStorageValue(cid, 10001, -1)
Perhaps? That's the only thing I can come up with :s
It's such a simple script, still I have been trying to fix it for like 3 days lol
---Edit---
tested
Lua:
doTeleportThing(cid,config[getCreatureStorage(cid, 10001)] >= 1)
didnt work either

- - - Updated - - -

Hello,

I would love to help you, but since i haven't learnt much about tables its hard for me to read it :/

So im bumping for you and hopefully someone can explain.

Haha, that bump! fucking love you man
I've been gone from this community for a while now, and I've forgot a bit, but I hope this works. If not, i'll try to help
Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) 
 
	local config = {
			{storage = 10001, position = {x=1023, y=1017, z=6}, msg = "Floor [1]"},
			{storage = 10002, position = {x=1023, y=1017, z=5}, msg = "Floor [2]"},
			{storage = 10003, position = {x=1023, y=1017, z=4}, msg = "Floor [3]"},
			{storage = 10004, position = {x=1023, y=1017, z=3}, msg = "Floor [4]"},
			{storage = 10005, position = {x=1023, y=1017, z=2}, msg = "Floor [5]"},
			{storage = 10006, position = {x=1023, y=1017, z=1}, msg = "Floor [6]"},
			{storage = 10007, position = {x=1023, y=1017, z=0}, msg = "Floor [7]"}
	}
	
	for i = 1, #config do
		if(getCreatureStorage(cid, config.storage[i][1]) >= 1) then
			doTeleportThing(cid, config.position[i][2])
			doSendMagicEffect(getCreaturePosition(cid),CONST_ME_TELEPORT)
			doSendMagicEffect(config.position[i][2], CONST_ME_TELEPORT)
		else
			doPlayerSendCancel(cid, "You can't go there right now")
		end
	end
return true
end

getting console error
6LP03I.png



--- Solved ---
Working script, for those who wants to know
Lua:
local config = {
	[10001] = {position = {x=1023, y=1017, z=6}, msg = "Floor [1]"},
	[10002] = {position = {x=1023, y=1017, z=5}, msg = "Floor [2]"},
	[10003] = {position = {x=1023, y=1017, z=4}, msg = "Floor [3]"},
	[10004] = {position = {x=1023, y=1017, z=3}, msg = "Floor [4]"},
	[10005] = {position = {x=1023, y=1017, z=2}, msg = "Floor [5]"},
	[10006] = {position = {x=1023, y=1017, z=1}, msg = "Floor [6]"},
	[10007] = {position = {x=1023, y=1017, z=0}, msg = "Floor [7]"}
}
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
	for k, v in pairs(config) do
		if getCreatureStorage(cid, k) >= 1 then
			doTeleportThing(cid, v.position)
			doSendMagicEffect(getCreaturePosition(cid),CONST_ME_TELEPORT)
			doSendMagicEffect(v.position, CONST_ME_TELEPORT)
			return true
		end
	end
	return doPlayerSendCancel(cid, "You can't go there right now")
end
 
Last edited:
My script is working
1, 2, 3... are floors, -1 and 0 are "cancels"

I don't fully understand what you want to do, I'm trying to imagine a tower with advance tiles one per floor

Use tiles like this one while 1 is storage required to enter first floor, change floorid with every level of your construction

just create folder chp in movements/scripts and create these files:

portals.lua - you define amount of floors here, I used this code for testing:
Code:
function onStepIn(cid, item, pos)

config = {
[-1] = {x=310, y=264, z=15},
[0] = {x=310, y=264, z=15},
[1] = {x=304, y=268, z=15},
[2] = {x=307, y=268, z=15},
[3] = {x=310, y=268, z=15}
}

doTeleportThing(cid,config[getCreatureStorage(cid, 10001)])
doSendMagicEffect(getCreaturePosition(cid),CONST_ME_TELEPORT)
if getCreatureStorage(cid, 10001) <= 0 then
doPlayerSendCancel(cid, "You can't go there right now")
end
return 1
end

chp2.lua - for second floor(tile for first floor is unnecessary if something else sets storage 10001, 1)
remember to change floorid in every code
Code:
function onStepIn(cid, item, position, fromPosition)
local floorid = 2
	if(isPlayer(cid) and getCreatureStorage(cid, 10001) < floorid) then
		doCreatureSetStorage(cid, 10001, floorid)
		doCreatureSay(cid, "You've reached Floor [" .. floorid .. "]", TALKTYPE_MONSTER)
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_RED)
	end
	return true
end

and last floor tile(in my case it's chp4.lua):
Code:
function onStepIn(cid, item, position, fromPosition)
local floorid = 4
	if(isPlayer(cid) and getCreatureStorage(cid, 10001) == 3) then
		doCreatureSetStorage(cid, 10001, -1)
		doCreatureSay(cid, "You've reached Floor [" .. floorid .. "], congratulions!", TALKTYPE_MONSTER)
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_RED)
	end
	return true
end

then go to movements.xml and paste this:
Code:
<movevent type="StepIn" actionid="20700" event="script" value="chp/portal.lua" />
	<movevent type="StepIn" actionid="20701" event="script" value="chp/chp1.lua" />
	<movevent type="StepIn" actionid="20702" event="script" value="chp/chp2.lua" />
	<movevent type="StepIn" actionid="20703" event="script" value="chp/chp3.lua" />
	<movevent type="StepIn" actionid="20704" event="script" value="chp/chp4.lua" />

Area where I tested script with passing through walls to check portal(and it worked):
chpg.png
 
Last edited:
Yeah, that's right :) It's a tower with 7 floors, when you reach the next floor you get the storageid thats because if you die in the floor you should be able to teleport back to just that floor

Lua:
function onStepIn(cid, item, pos)

config = {
[-1] = {x=1027, y=1015, z=8}, -- Cancel pos
[0] = {x=1028, y=1014, z=8}, -- Cancel pos
[1] = {x=1023, y=1017, z=6}, -- Floor 1 starts here
[2] = {x=1023, y=1017, z=5}, 
[3] = {x=1023, y=1017, z=4}, 
[4] = {x=1023, y=1017, z=3}, 
[5] = {x=1023, y=1017, z=2}, 
[6] = {x=1023, y=1017, z=1}, 
[7] = {x=1023, y=1017, z=0}
}

doTeleportThing(cid,config[getCreatureStorage(cid, 10001)] >= 1)
doSendMagicEffect(getCreaturePosition(cid),CONST_ME_TELEPORT)
if getCreatureStorage(cid, 10001) <= 0 then
doPlayerSendCancel(cid, "You can't go there right now")
end
return 1
end

I used that code and these for the setStorage
fl1
Lua:
function onStepIn(cid, item, position, fromPosition)
	local pos = getCreaturePosition(cid)
	if(isPlayer(cid) and getCreatureStorage(cid, 10001) ~= 1) then
		doCreatureSetStorage(cid, 10001, 1)
		doCreatureSay(cid, "You've reached Floor [1]", TALKTYPE_MONSTER)
		doSendMagicEffect(pos, CONST_ME_MAGIC_RED)
	end
	return true
end
fl2
Lua:
function onStepIn(cid, item, position, fromPosition)
	local pos = getCreaturePosition(cid)
	if(isPlayer(cid) and getCreatureStorage(cid, 10002) ~= 1) then
		doCreatureSetStorage(cid, 10002, 1)
		doPlayerSetStorageValue(cid, 10001, -1)
		doCreatureSay(cid, "You've reached Floor [2]", TALKTYPE_MONSTER)
		doSendMagicEffect(pos, CONST_ME_MAGIC_RED)
	end
	return true
end
fl3
Lua:
function onStepIn(cid, item, position, fromPosition)
	local pos = getCreaturePosition(cid)
	if(isPlayer(cid) and getCreatureStorage(cid, 10003) ~= 1) then
		doCreatureSetStorage(cid, 10003, 1)
		doPlayerSetStorageValue(cid, 10002, -1)
		doCreatureSay(cid, "You've reached Floor [3]", TALKTYPE_MONSTER)
		doSendMagicEffect(pos, CONST_ME_MAGIC_RED)
	end
	return true
end
fl4
Lua:
function onStepIn(cid, item, position, fromPosition)
	local pos = getCreaturePosition(cid)
	if(isPlayer(cid) and getCreatureStorage(cid, 10004) ~= 1) then
		doCreatureSetStorage(cid, 10004, 1)
		doPlayerSetStorageValue(cid, 10003, -1)
		doCreatureSay(cid, "You've reached Floor [4]", TALKTYPE_MONSTER)
		doSendMagicEffect(pos, CONST_ME_MAGIC_RED)
	end
	return true
end
fl5
Lua:
function onStepIn(cid, item, position, fromPosition)
	local pos = getCreaturePosition(cid)
	if(isPlayer(cid) and getCreatureStorage(cid, 10005) ~= 1) then
		doCreatureSetStorage(cid, 10005, 1)
		doPlayerSetStorageValue(cid, 10004, -1)
		doCreatureSay(cid, "You've reached Floor [5]", TALKTYPE_MONSTER)
		doSendMagicEffect(pos, CONST_ME_MAGIC_RED)
	end
	return true
end
fl6
Lua:
function onStepIn(cid, item, position, fromPosition)
	local pos = getCreaturePosition(cid)
	if(isPlayer(cid) and getCreatureStorage(cid, 10006) ~= 1) then
		doCreatureSetStorage(cid, 10006, 1)
		doPlayerSetStorageValue(cid, 10005, -1)
		doCreatureSay(cid, "You've reached Floor [6]", TALKTYPE_MONSTER)
		doSendMagicEffect(pos, CONST_ME_MAGIC_RED)
	end
	return true
end
f7
Lua:
function onStepIn(cid, item, position, fromPosition)
	local pos = getCreaturePosition(cid)
	if(isPlayer(cid) and getCreatureStorage(cid, 10007) ~= 1) then
		doCreatureSetStorage(cid, 10007, 1)
		doPlayerSetStorageValue(cid, 10006, -1)
		doCreatureSay(cid, "You've reached Floor [7 (BONUS FLOOR)]", TALKTYPE_MONSTER)
		doSendMagicEffect(pos, CONST_ME_MAGIC_RED)
	end
	return true
end
 
Back
Top