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

Player can't go into teleport

VirrageS

←•†ĿuĀ && ©¤¤•→
Joined
May 30, 2010
Messages
984
Reaction score
63
Location
Poland
Hello :thumbup:

I looking for script. So I player don't have storage (2000) then player can't go into teleport.
I tried to make it but don't work. Here is script:

LUA:
function onStepIn(cid, item, fromPosition, item2, toPosition)
	if (item.uniqueid == 40000) then
		if (getCreatureStorage(cid, 2000) == -1) then
			doTeleportThing(cid, fromPosition)
			doPlayerSendCancel(cid, "Sorry, You don't have required thing.")
		end
	end
end

Can someone fix it??
I will be very thankful. Rep of course.
 
That's dumb advice. That function works fine. The script is just shit.
I suggested that, because, if 'doCreateTeleport' is used in that mod, the movement part would not work --[[with something like this:
Code:
local newPosition = {x = EDIT, y = EDIT, z = EDIT}

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
	if(item.actionid == 1500 and getCreatureStorage(cid, 20044) == -1) then
		doPlayerSendCancel(cid, "You can\'t enter here with a mount.")
		doTeleportThing(cid, lastPosition)
	else
		doTeleportThing(cid, newPosition)
		doSendMagicEffect(newPosition, 
CONST_ME_TELEPORT)
	end

	return true
end
]]--

BTW, the script works. I tried it in my own server.

EDIT: I'll continue this tomorrow since I had some work to do today.
 
Last edited:
Code:
function onStepIn(cid, item, fromPosition, item2, toPosition)
	if (item.uniqueid == 40000) and (getPlayerStorageValue(cid, 2000) == 1) then
			doTeleportThing(cid, {x = 750, y = 673, z = 7})
           else
                      		doPlayerSendCancel(cid, "Sorry, You don't have required thing.")
                                 doTeleportThing(cid, fromPosition)
	end
return 1
end
 
There are a few more things to change, I'm still checking the script.

That's dumb advice. That function works fine. The script is just shit.

So tell me what's wrong with script. <_<
I'm still learning lua so any advice are welcome. ^_^


@Ratser
What will if player set other positon than is in
LUA:
local newPosition = {x = EDIT, y = EDIT, z = EDIT}
 
specialteleport.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Portal_config" version="1.0" author="VirrageS" contact="otland.net" enabled="yes">
	<config name="Portal_config"><![CDATA[
		setup = {
			[1] = {
				level = 1,
				premium = "false",
				souls = 0,
				levelMagic = 0,
				castTime = 10,
				portalClosing = "true",
				portalTime = 10,
				money = 5,
				effectType = 45,
				storage = 20044
			},
			[2] = {
				level = 1,
				premium = "false",
				souls = 0,
				levelMagic = 0,
				castTime = 10,
				portalClosing = "true",
				portalTime = 10,
				money = 5,
				effectType = 45,
				storage = 20044
			},
			[3] = {
				level = 1,
				premium = "false",
				souls = 0,
				levelMagic = 0,
				castTime = 10,
				portalClosing = "true",
				portalTime = 10,
				money = 5,
				effectType = 45,
				storage = 20044
			},
			[4] = {
				level = 1,
				premium = "false",
				souls = 0,
				levelMagic = 0,
				castTime = 10,
				portalClosing = "true",
				portalTime = 10,
				money = 5,
				effectType = 45,
				storage = 20044
			}
		}
		destination = { --EDIT THE DESTINATIONS HERE
			["temple"] = {
				closed = 500,
				open = 1500,
				position = {x = 96, y = 120, z = 7}
			},
			["other"] = {
				closed = 501,
				open = 1501,
				position = {x = 96, y = 125, z = 7}
			},
			["hello"] = {
				closed = 502,
				open = 1502,
				position = {x = 96, y = 125, z = 7}
			}
		}
	]]></config>
	<talkaction words="!portal" event="script"><![CDATA[
		domodlib("Portal_config")
		local countdownEvent = {}
		function onSay(cid, words, param)
			local voc = setup[getPlayerVocation(cid)]
			if(param == '') then
				local tutorialText = "¤ How to create a portal? ¤\n      !portal destination, number of players / closed\n\n          - closed - you can only go into portal\n          - number of player - which can go into portal"
				local destiText = "\n\n\n¤ You can choose one of this destinations: ¤\n    [1] - temple\n    [2] - other\n    [3] - hello"
				local vocaText = "\n\n¤ Your vocation require: ¤\n    - Level: ".. voc.level .."\n    - Magic Level: ".. voc.levelMagic .."\n    - Souls: ".. voc.souls .."\n    - Money: ".. voc.money .."\n    - Premium: \"".. voc.premium .."\""
				local abilityText = "\n\n¤ Abilities: ¤\n    - Cast portal: ".. voc.castTime .. "\n    - Portal\'s time ".. voc.portalTime .."\n    - Closing portal: \"".. voc.portalClosing .."\""
				local totalText = tutorialText .. destiText .. vocaText .. abilityText
				doPlayerPopupFYI(cid, "                              [ Portal Info ] \n\n" .. totalText)
				return true
			end
			
			local t = string.explode(param, ",")
			if(t[1] ~= nil) then
				if(not destination[t[1]]) then
					doPlayerSendCancel(cid, "Invalid destination specified.")
					return true
				end

				if(t[2] ~= "open") then
					if(t[2] ~= "closed") then
						doPlayerSendCancel(cid, "Invalid param specified.")
						return true
					end
				end

				if(not voc) then
					doPlayerSendCancel(cid, "You don\'t have the required vocation!")
					return true
				end

				if(getPlayerLevel(cid) < voc.level) then
					doPlayerSendCancel(cid, "You don\'t have the required level!")
					return true
				end

				if(getCreatureStorage(cid, voc.storage) ~= -1) then
					doPlayerSendCancel(cid, "You\'ve already created a portal!")
					return true
				end

				if(getPlayerMagLevel(cid) < voc.levelMagic) then
					doPlayerSendCancel(cid, "You don\'t have the required magic level!")
					return true
				end

				if(countdownEvent[cid] == nil or countdownEvent[cid] == 0) then
					if(getPlayerMoney(cid) >= voc.money) then
						doPlayerRemoveMoney(cid, voc.money)
					else
						doPlayerSendCancel(cid, "You don\'t have enough money! You need: ".. voc.money .." gold coins.")
						return false
					end

					if(getPlayerSoul(cid) >= voc.souls) then
						doPlayerAddSoul(cid, -voc.souls)
					else
						doPlayerSendCancel(cid, "You don\'t have enough mana to create a portal! You need: ".. voc.souls .."")
						return false
					end

					function finalCountdown(cid, countLeft, playerPos)
						if(not isPlayer(cid) or countLeft == 0) then
							if isPlayer(cid) then
								doPlayerSendTextMessage(cid, 19, "You have created a teleport.")
								pos = getCreatureLookPosition(cid)
								teleport = doCreateItem(1387, 1, playerPos)
								doCreatureSetStorage(cid, voc.storage, 1)
								doSendMagicEffect(playerPos, voc.effectType)

								function deleteTeleport()
									local teleport = getTileItemById(playerPos, 1387).uid
									if(teleport > 0) then
										doRemoveItem(teleport)
										doCreatureSetStorage(cid, voc.storage, -1)
										if(getCreatureStorage(cid, 20045) > 0) then
											doCreatureSetStorage(cid, 20045, -1)
										end

										doPlayerSendTextMessage(cid, 19, "Your teleport run out of energy and colapsed.")
										doSendMagicEffect(playerPos, CONST_ME_POFF)
									end
								end

								if(t[2] == "closed") then
									doItemSetAttribute(teleport, "description", "This portal can only be used by ".. getCreatureName(cid) ..".")
									doItemSetAttribute(teleport, "aid", destination[t[1]].closed)
									doCreatureSetStorage(cid, 20045, 1)
									addEvent(deleteTeleport, voc.portalTime * 1000)
								elseif(t[2] == "open") then
									doItemSetAttribute(teleport, "description", "The portal can be freely used by people.")
									doItemSetAttribute(teleport, "aid", destination[t[1]].open)
									addEvent(deleteTeleport, voc.portalTime * 1000)
									return true
								end
							end

							countdownEvent[cid] = 0
							return
						end

						local tmpPos = getCreaturePosition(cid)
						if((tmpPos.x == playerPos.x) and (tmpPos.y == playerPos.y) and (tmpPos.z == tmpPos.z) and (not isPlayerPzLocked(cid))) then
							doSendAnimatedText(getCreaturePosition(cid), "Count: ".. countLeft .."", 11)
							local eventId = addEvent(finalCountdown, 1000, cid, countLeft - 1, playerPos)
							countdownEvent[cid] = eventId
						else
							doPlayerSendCancel(cid, "You moved or gained infight. You can\'t logout.")
							countdownEvent[cid] = 0
						end
					end
 
					local eventId = addEvent(finalCountdown, 0, cid, voc.castTime, getCreaturePosition(cid))
					countdownEvent[cid] = eventId
				else
					doPlayerSendCancel(cid, "You\'re already casting a teleport.")
					return true
				end
			else
				doPlayerSendCancel(cid, "No destination specified.")
			end
			return true
		end
	]]></talkaction>
	<movement type="StepIn" itemid="1387" event="script"><![CDATA[
		domodlib("Portal_config")
		local CLOSED = { --BETWEEN THE "[]" PUT THE ACTION.ID OF "CLOSED" (FOUND IN THE CONFIG) / IN "destination[X].position": X = DESTINATION NAME
			[500] = {destination["temple"].position},
			[501] = {destination["other"].position},
			[502] = {destination["hello"].position},
		}
		local OPEN = { --BETWEEN THE "[]" PUT THE ACTION.ID OF "OPEN" (FOUND IN THE CONFIG) / IN "destination[X].position": X = DESTINATION NAME
			[1500] = {destination["temple"].position},
			[1501] = {destination["other"].position},
			[1502] = {destination["hello"].position},
		}

		function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
			--[[if(item.actionid > actionid) then
				doItemSetAttribute(item.uid, "description", "The portal may enter ".. (item.actionid - actionid - 1) .." people left.")
				doItemSetAttribute(item.uid, "aid", item.actionid - 1)
				if((item.actionid - actionid) == 1) then
					doPlayerSendTextMessage(cid, 19, "Your teleport have outed of energy and colapsed.")
					doSendMagicEffect(fromPosition, 53)
					doCreatureSetStorage(cid, voc.storage, -1)
					doRemoveItem(item.uid, 1)
			end]]--

			if(item.actionid ~= CLOSED[item.actionid] and getCreatureStorage(cid, 20045) < 0) then
				if(item.actionid == OPEN[item.actionid]) then
					doTeleportThing(cid, OPEN[item.actionid][1])
					doSendMagicEffect(OPEN[item.actionid][1], 10)
				else
					doPlayerSendCancel(cid, "You can\'t enter here with a mount.")
					doTeleportThing(cid, lastPosition)
				end
				
				doPlayerSendCancel(cid, "You can\'t enter here with a mount.")
				doTeleportThing(cid, lastPosition)
			else
				doTeleportThing(cid, CLOSED[item.actionid][1])
				doSendMagicEffect(CLOSED[item.actionid][1], 10)
			end
			return true			
		end
	]]></movement>
</mod>

Talkaction words:
Code:
!portal [destination], [open/closed]

[destination] = eg. temple, other, hello
[open/closed] = {open = {Everyone can use the portal for 10 seconds}, closed = {Only the one who created the teleport can use it for 10 seconds}}

It's impossible to make it decrease the action.id for each player that enters when it's "open" so I changed it to be of free use for [voc.portalTime * 1000] secs.

If there's any bug just let me know.
 
Last edited:
EDIT:
I fixed it myself:

LUA:
	<movement type="StepIn" itemid="1387" event="script"><![CDATA[
		domodlib("Portal_config")
		local CLOSED = {
			[500] = {destination["temple"].position},
			[501] = {destination["other"].position},
			[502] = {destination["hello"].position},
		}
		local OPEN = {
			[1500] = {destination["temple"].position},
			[1501] = {destination["other"].position},
			[1502] = {destination["hello"].position},
		}

		function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)

			if (item.actionid ~= CLOSED[item.actionid] and getCreatureStorage(cid, 20045) < 0) then			
				if (item.actionid == 1500 or item.actionid == 1501 or item.actionid == 1502) then
					doTeleportThing(cid, OPEN[item.actionid][1])
				else				
					doPlayerSendCancel(cid, "You can\'t enter here with a mountaaa.")
					doTeleportThing(cid, lastPosition)
				end
			else
				doTeleportThing(cid, CLOSED[item.actionid][1])
			end
			return true
		end
	]]></movement>


But there are 2 problems:
1. Now teleport is teleporting to only 1 position. It's way to without (maybe any "for i = 0, 2 do...." function (I never used this function) ) ???

LUA:
if(item.actionid == 500) then 
	doTeleportThing(cid, CLOSED[item.actionid][1])
elseif(item.actionid == 501) then 
	doTeleportThing(cid, CLOSED[item.actionid][2])
elseif (item.actionid == 502) then 
	doTeleportThing(cid, CLOSED[item.actionid][3])
end

2. If two players create teleport at the same time (and first player create "closed" teleport) then second can go into first's teleport because have the same storage. So it's any solution to make that for each player is seting other storage or something else??
 
  1. 'for X do...'? As far as I understand it, that's for making loops. I'll check for other possible alternatives anyways.
    EDIT:
    I edited the script, try it now. Also, remember you have to change the destinations in the config.
  2. I was thinking that too. About this and the issue with "open" I think a new table in the database would be needed to store the id of the player who created the portal and the number of players that can enter the teleport.
 
Last edited:
I fixed some script:
LUA:
<?xml version='1.0' encoding='UTF-8'?>
<mod name='Portal_config' version='1.0' author='VirrageS' contact='otland.net' enabled='yes'>
	<config name='Portal_config'><![CDATA[
		setup = {
			[1] = {
				level = 1,
				premium = 'false',
				souls = 0,
				levelMagic = 0,
				castTime = 10,
				portalClosing = 'true',
				portalTime = 10,
				money = 5,
				effectType = 45,
				storage = 200415
			},
			[2] = {
				level = 1,
				premium = 'false',
				souls = 0,
				levelMagic = 0,
				castTime = 10,
				portalClosing = 'true',
				portalTime = 10,
				money = 5,
				effectType = 45,
				storage = 200425
			},
			[3] = {
				level = 1,
				premium = 'false',
				souls = 0,
				levelMagic = 0,
				castTime = 10,
				portalClosing = 'true',
				portalTime = 10,
				money = 5,
				effectType = 45,
				storage = 200435
			},
			[4] = {
				level = 1,
				premium = 'false',
				souls = 0,
				levelMagic = 0,
				castTime = 10,
				portalClosing = 'true',
				portalTime = 10,
				money = 5,
				effectType = 45,
				storage = 200445
			}
		}
		destination = { --EDIT THE DESTINATIONS HERE
			['temple'] = {
				closed = 500,
				open = 1500,
				position = {x = 96, y = 120, z = 7}
			},
			['other'] = {
				closed = 501,
				open = 1501,
				position = {x = 96, y = 125, z = 7}
			},
			['hello'] = {
				closed = 502,
				open = 1502,
				position = {x = 98, y = 126, z = 7}
			},
			['qwerty'] = {
				closed = 503,
				open = 1503,
				position = {x = 96, y = 130, z = 7}
			}
		}
	]]></config>

	<lib name='portal-lib'><![CDATA[
		function getPlayerIdByName()
			return db.getResult('SELECT `blue` FROM `Teams` WHERE `id`='' .. 1):getDataInt('blue')
		end

	]]></lib>

	<talkaction words='!portal' event='script'><![CDATA[
		domodlib('Portal_config')
		local countdownEvent = {}
		function onSay(cid, words, param)
			local voc = setup[getPlayerVocation(cid)]
			if(param == '') then
				local tutorialText = '¤ How to create a portal? ¤\n      !portal destination, number of players / closed\n\n          - closed - you can only go into portal\n          - number of player - which can go into portal'
				local destiText = '\n\n\n¤ You can choose one of this destinations: ¤\n    [1] - temple\n    [2] - other\n    [3] - hello'
				local vocaText = '\n\n¤ Your vocation require: ¤\n    - Level: '.. voc.level ..'\n    - Magic Level: '.. voc.levelMagic ..'\n    - Souls: '.. voc.souls ..'\n    - Money: '.. voc.money ..'\n    - Premium: \''.. voc.premium ..'\''
				local abilityText = '\n\n¤ Abilities: ¤\n    - Cast portal: '.. voc.castTime .. '\n    - Portal\'s time '.. voc.portalTime ..'\n    - Closing portal: \''.. voc.portalClosing ..'\''
				local totalText = tutorialText .. destiText .. vocaText .. abilityText
				doPlayerPopupFYI(cid, '                              [ Portal Info ] \n\n' .. totalText)
				return true
			end

			local t = string.explode(param, ',')
			
			if(t[1] ~= nil) then
				if(not destination[t[1]]) then
					doPlayerSendCancel(cid, 'Invalid destination specified.')
					return true
				end

				if(t[2] ~= 'open') then
					if(t[2] ~= 'closed') then
						doPlayerSendCancel(cid, 'Invalid param specified.')
						return true
					end
				end

				if(not voc) then
					doPlayerSendCancel(cid, 'You don\'t have the required vocation!')
					return true
				end

				if(getPlayerLevel(cid) < voc.level) then
					doPlayerSendCancel(cid, 'You don\'t have the required level!')
					return true
				end

				if(getCreatureStorage(cid, voc.storage) ~= -1) then
					doPlayerSendCancel(cid, 'You\'ve already created a portal!')
					return true
				end

				if(getPlayerMagLevel(cid) < voc.levelMagic) then
					doPlayerSendCancel(cid, 'You don\'t have the required magic level!')
					return true
				end

				if(countdownEvent[cid] == nil or countdownEvent[cid] == 0) then
					if(getPlayerMoney(cid) >= voc.money) then
						doPlayerRemoveMoney(cid, voc.money)
					else
						doPlayerSendCancel(cid, 'You don\'t have enough money! You need: '.. voc.money ..' gold coins.')
						return false
					end

					if(getPlayerSoul(cid) >= voc.souls) then
						doPlayerAddSoul(cid, -voc.souls)
					else
						doPlayerSendCancel(cid, 'You don\'t have enough mana to create a portal! You need: '.. voc.souls ..'')
						return false
					end

					function finalCountdown(cid, countLeft, playerPos)
						if(not isPlayer(cid) or countLeft == 0) then
							if isPlayer(cid) then
								teleport = doCreateItem(1387, 1, playerPos)
								
								function deleteTeleport()
									local teleport = getTileItemById(playerPos, 1387).uid
									if(teleport > 0) then
										doRemoveItem(teleport)
										if(getCreatureStorage(cid, voc.storage) > 0) then
											doCreatureSetStorage(cid, voc.storage, -1)
										end
										doPlayerSendTextMessage(cid, 19, 'Your teleport run out of energy and colapsed.')
										doSendMagicEffect(playerPos, CONST_ME_POFF)
									end
								end
								
								if(t[2] == 'closed') then
									doItemSetAttribute(teleport, 'description', 'This portal can only be used by '.. getCreatureName(cid) ..'.')
									doItemSetAttribute(teleport, 'aid', destination[t[1]].closed)
									doItemSetAttribute(teleport, 'uid', (getAccountIdByName(getCreatureName(cid)) + 10000))
								elseif(t[2] == 'open') then
									doItemSetAttribute(teleport, 'description', 'The portal can be freely used by people. Destination \"'.. t[1] ..'\".')
									doItemSetAttribute(teleport, 'aid', destination[t[1]].open)
								end
								
								addEvent(deleteTeleport, voc.portalTime * 1000)
								doCreatureSetStorage(cid, voc.storage, 1)
								doSendMagicEffect(playerPos, voc.effectType)
								doPlayerSendTextMessage(cid, 19, 'You have created a teleport.')
							end

							countdownEvent[cid] = 0
							return
						end

						local tmpPos = getCreaturePosition(cid)
						if((tmpPos.x == playerPos.x) and (tmpPos.y == playerPos.y) and (tmpPos.z == tmpPos.z) or (getCreatureCondition(cid, CONDITION_INFIGHT) == true)) then
							doSendAnimatedText(getCreaturePosition(cid), 'Count: '.. countLeft ..'', 11)
							local eventId = addEvent(finalCountdown, 1000, cid, countLeft - 1, playerPos)
							countdownEvent[cid] = eventId
						else
							doSendAnimatedText(getCreaturePosition(cid), 'Stop cast', TEXTCOLOR_RED)
							doPlayerSendCancel(cid, 'You moved or gained infight. You have stoped casting.')
							countdownEvent[cid] = 0
						end
					end

					local eventId = addEvent(finalCountdown, 0, cid, voc.castTime, getCreaturePosition(cid))
					countdownEvent[cid] = eventId
				else
					doPlayerSendCancel(cid, 'You\'re already casting a teleport!!')
					return true
				end
			else
				doPlayerSendCancel(cid, 'No destination specified.')
			end
			return true
		end
	]]></talkaction>
	<movement type='StepIn' itemid='1387' event='script'><![CDATA[
		domodlib('Portal_config')

		local CLOSED = {
			[500] = {destination['temple'].position},
			[501] = {destination['other'].position},
			[502] = {destination['hello'].position},
			[503] = {destination['qwerty'].position}
		}

		local OPEN = {
			[1500] = {destination['temple'].position},
			[1501] = {destination['other'].position},
			[1502] = {destination['hello'].position},
			[1503] = {destination['qwerty'].position}
		}

		function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
			if(isInArray({1500,1501,1502,1503}, item.actionid)) then
				doTeleportThing(cid, OPEN[item.actionid][1])
				doSendMagicEffect(OPEN[item.actionid][1], 10)
			elseif(isInArray({500,501,502,503}, item.actionid)) then
				if((item.uid - getAccountIdByName(getCreatureName(cid))) == 10000) then
					doTeleportThing(cid, CLOSED[item.actionid][1])
					doSendMagicEffect(CLOSED[item.actionid][1], 10)
				else
					doPlayerSendCancel(cid, 'You can\'t go into portal.')
					doTeleportThing(cid, lastPosition)
				end
			end
			return true
		end
	]]></movement>
</mod>

But there is 1 BIG problem. When first player casts teleport (for e.x "closed"), and this time second player will also cast teleport (for e.x "open") then they will have two ("open") teleport's (because second player change "actionID" (from "closed" to "open") for first player.

I don't know that I good describe problem. If you can test it yourself.
 
Last edited:
That happens while the first player is casting its teleport or after it's created?

EDIT:
If it happens WHILE the player is casting the teleport use 'doSetStorage(key, value)' to set a global storage after this:
Code:
if((tmpPos.x == playerPos.x) and (tmpPos.y == playerPos.y) and (tmpPos.z == tmpPos.z) or (getCreatureCondition(cid, CONDITION_INFIGHT) == true)) then
							doSendAnimatedText(getCreaturePosition(cid), 'Count: '.. countLeft ..'', 11)
Then, make a check ('if(getStorage(key) == 1)') at the beginning so if anyone tries to cast a teleport while someone else is using the same talkaction it'll send them a cancel message.
Finally, use 'doSetStorage(key, -1)' here:
Code:
if(t[2] == 'closed') then
									doItemSetAttribute(teleport, 'description', 'This portal can only be used by '.. getCreatureName(cid) ..'.')
									doItemSetAttribute(teleport, 'aid', destination[t[1]].closed)
									doItemSetAttribute(teleport, 'uid', (getAccountIdByName(getCreatureName(cid)) + 10000))
----------------------------------HERE-------------------------------------------------
								elseif(t[2] == 'open') then
									doItemSetAttribute(teleport, 'description', 'The portal can be freely used by people. Destination \"'.. t[1] ..'\".')
									doItemSetAttribute(teleport, 'aid', destination[t[1]].open)
---------------------------------- AND HERE-------------------------------------------
 
Last edited:
Ok. It's working. :thumbup:

But it raises a new problem that only one player is able to create teleport. Is any solution which solve it??
 
LUA:
<?xml version='1.0' encoding='UTF-8'?>
<mod name='Portal_config' version='1.0' author='VirrageS' credits='Ratser' contact='otland.net' enabled='yes'>
	<config name='Portal_config'><![CDATA[
		setup = {
			[1] = {
				level = 1,
				premium = 'false',
				souls = 0,
				levelMagic = 0,
				castTime = 10,
				portalClosing = 'true',
				portalTime = 10,
				money = 5,
				reagentItem = 2478,
				effectType = 45,
				storage = 200415
			},
			[2] = {
				level = 1,
				premium = 'false',
				souls = 0,
				levelMagic = 0,
				castTime = 10,
				portalClosing = 'true',
				portalTime = 10,
				money = 5,
				reagentItem = 2478,
				effectType = 45,
				storage = 200425
			},
			[3] = {
				level = 1,
				premium = 'false',
				souls = 0,
				levelMagic = 0,
				castTime = 10,
				portalClosing = 'true',
				portalTime = 10,
				money = 5,
				reagentItem = 2478,
				effectType = 45,
				storage = 200435
			},
			[4] = {
				level = 1,
				premium = 'false',
				souls = 0,
				levelMagic = 0,
				castTime = 10,
				portalClosing = 'true',
				portalTime = 10,
				money = 5,
				reagentItem = 2478,
				effectType = 45,
				storage = 200445
			}
		}
		destination = { --EDIT THE DESTINATIONS HERE
			['temple'] = {
				closed = 500,
				open = 1500,
				position = {x = 96, y = 120, z = 7}
			},
			['other'] = {
				closed = 501,
				open = 1501,
				position = {x = 96, y = 125, z = 7}
			},
			['hello'] = {
				closed = 502,
				open = 1502,
				position = {x = 98, y = 126, z = 7}
			},
			['qwerty'] = {
				closed = 503,
				open = 1503,
				position = {x = 96, y = 130, z = 7}
			}
		}
	]]></config>

	<talkaction words='!portal' event='script'>
		<![CDATA[
			domodlib('Portal_config')

			local countdownEvent, globalStorage = {}, 5002

			function onSay(cid, words, param)
				local voc = setup[getPlayerVocation(cid)]
				if(param == '') then
					local tutorialText = '¤ How to create a portal? ¤\n      !portal destination, number of players / closed\n\n          - closed - you can only go into portal\n          - number of player - which can go into portal'
					local destiText = '\n\n\n¤ You can choose one of this destinations: ¤\n    [1] - temple\n    [2] - other\n    [3] - hello'
					local vocaText = '\n\n¤ Your vocation require: ¤\n    - Level: '.. voc.level ..'\n    - Magic level: '.. voc.levelMagic ..'\n    - Souls: '.. voc.souls ..'\n    - Money: '.. voc.money ..' gold\'s\n    - Premium: \''.. voc.premium ..'\'\n    - Reagent item: '.. getItemInfo(voc.reagentItem).name ..''
					local abilityText = '\n\n¤ Abilities: ¤\n    - Cast portal: '.. voc.castTime .. '\n    - Portal\'s time '.. voc.portalTime ..'\n    - Closing portal: \''.. voc.portalClosing ..'\''
					local totalText = tutorialText .. destiText .. vocaText .. abilityText
					doPlayerPopupFYI(cid, '                              [ Portal Info ] \n\n' .. totalText)
					
					doCreatureSay(cid, words, TALKTYPE_ORANGE_1)
					return true
				end

				local t = string.explode(param, ',')

				if(t[1] ~= nil) then
					if(not destination[t[1]]) then
						doPlayerSendCancel(cid, 'Invalid destination specified.')
						return true
					end

					if(t[2] ~= 'open') then
						if(t[2] ~= 'closed') then
							doPlayerSendCancel(cid, 'Invalid param specified.')
							return true
						end
					end

					if(not voc) then
						doPlayerSendCancel(cid, 'You don\'t have the required vocation!')
						return true
					end

					if(getPlayerLevel(cid) < voc.level) then
						doPlayerSendCancel(cid, 'You don\'t have the required level!')
						return true
					end

					if(getCreatureStorage(cid, voc.storage) ~= -1) then
						doPlayerSendCancel(cid, 'You\'ve already created a portal!')
						return true
					end

					if(getPlayerMagLevel(cid) < voc.levelMagic) then
						doPlayerSendCancel(cid, 'You don\'t have the required magic level!')
						return true
					end

					if(getStorage(cid, globalStorage) < 0) then
						if(countdownEvent[cid] == nil or countdownEvent[cid] == 0) then

							if(getPlayerSoul(cid) >= voc.souls) then
								doPlayerAddSoul(cid, -voc.souls)
							else
								doPlayerSendCancel(cid, 'You don\'t have enough mana to create a portal! You need: '.. voc.souls ..'')
								return false
							end

							if(getPlayerItemCount(cid, voc.reagentItem) > 0) then
								doPlayerRemoveItem(cid, voc.reagentItem, 1)
							else
								doPlayerSendCancel(cid, 'You don\'t have \''.. getItemInfo(voc.reagentItem).name ..'\' which are/is reqiure to create portal!')
								return false
							end

							if(getPlayerMoney(cid) >= voc.money) then
								doPlayerRemoveMoney(cid, voc.money)
							else
								doPlayerSendCancel(cid, 'You don\'t have enough money! You need: '.. voc.money ..' gold coins.')
								return false
							end

							function finalCountdown(cid, countLeft, playerPos)
								if(not isPlayer(cid) or countLeft == 0) then
									if isPlayer(cid) then
										teleport = doCreateItem(1387, 1, playerPos)

										function deleteTeleport()
											local teleport = getTileItemById(playerPos, 1387).uid
											if(teleport > 0) then
												doRemoveItem(teleport)
												if(getCreatureStorage(cid, voc.storage) > 0) then
													doCreatureSetStorage(cid, voc.storage, -1)
												end
												doPlayerSendTextMessage(cid, 19, 'Your teleport run out of energy and colapsed.')
												doSendMagicEffect(playerPos, CONST_ME_POFF)
											end
										end

										if(t[2] == 'closed') then
											doItemSetAttribute(teleport, 'description', 'This portal can only be used by '.. getCreatureName(cid) ..'.')
											doItemSetAttribute(teleport, 'aid', destination[t[1]].closed)
											doItemSetAttribute(teleport, 'uid', (getAccountIdByName(getCreatureName(cid)) + 10000))
											doSetStorage(cid, globalStorage, -1)
										elseif(t[2] == 'open') then
											doItemSetAttribute(teleport, 'description', 'The portal can be freely used by people. Destination \''.. t[1] ..'\'.')
											doItemSetAttribute(teleport, 'aid', destination[t[1]].open)
											doSetStorage(cid, globalStorage, -1)
										end

										addEvent(deleteTeleport, voc.portalTime * 1000)
										doCreatureSetStorage(cid, voc.storage, 1)
										doSendMagicEffect(playerPos, voc.effectType)
										doPlayerSendTextMessage(cid, 19, 'You have created a teleport.')
									end

									countdownEvent[cid] = 0
									return
								end

								local tmpPos = getCreaturePosition(cid)
								if((tmpPos.x == playerPos.x) and (tmpPos.y == playerPos.y)) then
									doSendAnimatedText(playerPos, 'Cast: '.. countLeft ..'', 11)
									doSendMagicEffect(playerPos, CONST_ME_FIREATTACK)
									local eventId = addEvent(finalCountdown, 1000, cid, countLeft - 1, playerPos)
									countdownEvent[cid] = eventId
								else
									doSendAnimatedText(getCreaturePosition(cid), 'Stop cast!', TEXTCOLOR_RED)
									doPlayerSendCancel(cid, 'You moved or gained infight. You have stoped casting.')
									countdownEvent[cid] = 0
									doSetStorage(cid, globalStorage, -1)
								end
							end

							local eventId = addEvent(finalCountdown, 0, cid, voc.castTime, getCreaturePosition(cid))
							countdownEvent[cid] = eventId
							doSetStorage(cid, globalStorage, 1)
						else
							doPlayerSendCancel(cid, 'You\'re already casting a teleport!!')
							return true
						end
					else
						doPlayerSendCancel(cid, 'Someone is casting teleport. Wait.')
						return true
					end
				else
					doPlayerSendCancel(cid, 'No destination specified.')
				end
				
				doCreatureSay(cid, words .. ' ' .. t[1] .. ', ' .. t[2], TALKTYPE_ORANGE_1)
				return true
			end
		]]>
	</talkaction>
	
	<movement type='StepIn' itemid='1387' event='script'>
		<![CDATA[
			domodlib('Portal_config')

			local CLOSED = {
				[500] = {destination['temple'].position},
				[501] = {destination['other'].position},
				[502] = {destination['hello'].position},
				[503] = {destination['qwerty'].position}
			}

			local OPEN = {
				[1500] = {destination['temple'].position},
				[1501] = {destination['other'].position},
				[1502] = {destination['hello'].position},
				[1503] = {destination['qwerty'].position}
			}

			function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
				if(isInArray({1500,1501,1502,1503}, item.actionid)) then
					doTeleportThing(cid, OPEN[item.actionid][1])
					doSendMagicEffect(OPEN[item.actionid][1], 10)
				elseif(isInArray({500,501,502,503}, item.actionid)) then
					if((item.uid - getAccountIdByName(getCreatureName(cid))) == 10000) then
						doTeleportThing(cid, CLOSED[item.actionid][1])
						doSendMagicEffect(CLOSED[item.actionid][1], 10)
					else
						doPlayerSendCancel(cid, 'You can\'t go into portal.')
						doTeleportThing(cid, lastPosition)
					end
				end
				return true
			end
		]]>
	</movement>
	
</mod>
 
Last edited:
Here (tested and it works):

LUA:
<?xml version='1.0' encoding='UTF-8'?>
<mod name='Portal_config' version='1.0' author='VirrageS' credits='Ratser' contact='otland.net' enabled='yes'>
	<config name='Portal_config'><![CDATA[
		setup = {
			[1] = {
				level = 1,
				premium = 'false',
				souls = 0,
				levelMagic = 0,
				castTime = 10,
				portalClosing = 'true',
				portalTime = 10,
				money = 5,
				reagentItem = 2478,
				effectType = 45,
				storage = 200415
			},
			[2] = {
				level = 1,
				premium = 'false',
				souls = 0,
				levelMagic = 0,
				castTime = 10,
				portalClosing = 'true',
				portalTime = 10,
				money = 5,
				reagentItem = 2478,
				effectType = 45,
				storage = 200425
			},
			[3] = {
				level = 1,
				premium = 'false',
				souls = 0,
				levelMagic = 0,
				castTime = 10,
				portalClosing = 'true',
				portalTime = 10,
				money = 5,
				reagentItem = 2478,
				effectType = 45,
				storage = 200435
			},
			[4] = {
				level = 1,
				premium = 'false',
				souls = 0,
				levelMagic = 0,
				castTime = 10,
				portalClosing = 'true',
				portalTime = 10,
				money = 5,
				reagentItem = 2478,
				effectType = 45,
				storage = 200445
			}
		}
		destination = { --EDIT THE DESTINATIONS HERE
			['temple'] = {
				closed = 500,
				open = 1500,
				position = {x = 96, y = 120, z = 7}
			},
			['other'] = {
				closed = 501,
				open = 1501,
				position = {x = 96, y = 125, z = 7}
			},
			['hello'] = {
				closed = 502,
				open = 1502,
				position = {x = 98, y = 126, z = 7}
			},
			['qwerty'] = {
				closed = 503,
				open = 1503,
				position = {x = 96, y = 130, z = 7}
			}
		}
	]]></config>
 
	<talkaction words='!portal' event='script'>
		<![CDATA[
			domodlib('Portal_config')
 
			local countdownEvent, globalStorage = {}, 5002

			function onSay(cid, words, param)
				local voc = setup[getPlayerVocation(cid)]
				if(param == '') then
					local tutorialText = "¤ How to create a portal? ¤\n	!portal 'destination', 'open'/'closed'\n		'open': The portal may be used freely by anyone\n		'closed': Only the one who casted the portal may enter it"
					local destiText = "\n\n¤ You can choose one of this destinations: ¤\n	'temple'\n	'other'\n	'hello'\n	'qwerty'"
					local vocaText = "\n\n¤ Vocation requirements: ¤\n	Level: ".. voc.level .."\n	Magic level: ".. voc.levelMagic .."\n	Souls: ".. voc.souls .."\n	Money: ".. voc.money .." gold coin(s)\n	Premium: ".. voc.premium .."\n	Reagent item: ".. getItemInfo(voc.reagentItem).name ..""
					local abilityText = "\n\n¤ Abilities: ¤\n	Cast portal: ".. voc.castTime .. "\n	Portal\'s time ".. voc.portalTime .."\n	Closing portal: ".. voc.portalClosing ..""
					local totalText = tutorialText .. destiText .. vocaText .. abilityText
					doPlayerPopupFYI(cid, "                                           [ Portal Info ]\n\n" .. totalText)
 
					doCreatureSay(cid, words, TALKTYPE_ORANGE_1)
					return true
				end
 
				local t = string.explode(param, ',')
				if(t[1] ~= nil) then
					if(not destination[t[1]]) then
						doPlayerSendCancel(cid, 'Invalid destination specified.')
						return true
					end
 
					if(t[2] ~= 'open') then
						if(t[2] ~= 'closed') then
							doPlayerSendCancel(cid, 'Invalid param specified.')
							return true
						end
					end
 
					if(not voc) then
						doPlayerSendCancel(cid, 'You don\'t have the required vocation!')
						return true
					end
 
					if(getPlayerLevel(cid) < voc.level) then
						doPlayerSendCancel(cid, 'You don\'t have the required level!')
						return true
					end
 
					if(getCreatureStorage(cid, voc.storage) ~= -1) then
						doPlayerSendCancel(cid, 'You\'ve already created a portal!')
						return true
					end
 
					if(getPlayerMagLevel(cid) < voc.levelMagic) then
						doPlayerSendCancel(cid, 'You don\'t have the required magic level!')
						return true
					end
 
					if(getStorage(cid, globalStorage) < 0) then
						if(countdownEvent[cid] == nil or countdownEvent[cid] == 0) then
 
							if(getPlayerSoul(cid) >= voc.souls) then
								doPlayerAddSoul(cid, -voc.souls)
							else
								doPlayerSendCancel(cid, 'You don\'t have enough mana to create a portal! You need: '.. voc.souls ..'')
								return false
							end
 
							if(getPlayerItemCount(cid, voc.reagentItem) > 0) then
								doPlayerRemoveItem(cid, voc.reagentItem, 1)
							else
								doPlayerSendCancel(cid, 'You don\'t have \''.. getItemInfo(voc.reagentItem).name ..'\' which are/is reqiure to create portal!')
								return false
							end
 
							if(getPlayerMoney(cid) >= voc.money) then
								doPlayerRemoveMoney(cid, voc.money)
							else
								doPlayerSendCancel(cid, 'You don\'t have enough money! You need: '.. voc.money ..' gold coins.')
								return false
							end
 
							function finalCountdown(cid, countLeft, playerPos)
								if(not isPlayer(cid) or countLeft == 0) then
									if isPlayer(cid) then
										teleport = doCreateItem(1387, 1, playerPos)

										function deleteTeleport()
											local teleport = getTileItemById(playerPos, 1387).uid
											if(teleport > 0) then
												doRemoveItem(teleport)
												doCreatureSetStorage(cid, voc.storage, -1)
												doPlayerSendTextMessage(cid, 19, 'Your teleport run out of energy and colapsed.')
												doSendMagicEffect(playerPos, CONST_ME_POFF)
											end
										end
 
										if(t[2] == 'closed') then
											doItemSetAttribute(teleport, 'description', 'This portal can only be used by '.. getCreatureName(cid) ..'.')
											doItemSetAttribute(teleport, 'aid', destination[t[1]].closed)
											doItemSetAttribute(teleport, 'uid', (getAccountIdByName(getCreatureName(cid)) + 10000))
										elseif(t[2] == 'open') then
											doItemSetAttribute(teleport, 'description', 'The portal can be freely used by people. Destination \''.. t[1] ..'\'.')
											doItemSetAttribute(teleport, 'aid', destination[t[1]].open)
										end

										addEvent(deleteTeleport, voc.portalTime * 1000)
										doCreatureSetStorage(cid, voc.storage, 1)
										doSetStorage(cid, globalStorage, -1)
										doSendMagicEffect(playerPos, voc.effectType)
										doPlayerSendTextMessage(cid, 19, 'You have created a teleport.')
									end
 
									countdownEvent[cid] = 0
									return
								end
 
								local tmpPos = getCreaturePosition(cid)
								if((tmpPos.x == playerPos.x) and (tmpPos.y == playerPos.y)) then
									doSendAnimatedText(playerPos, 'Cast: '.. countLeft ..'', 11)
									doSendMagicEffect(playerPos, CONST_ME_FIREATTACK)
									doSetStorage(cid, globalStorage, 1)
									local eventId = addEvent(finalCountdown, 1000, cid, countLeft - 1, playerPos)
									countdownEvent[cid] = eventId
								else
									doSendAnimatedText(getCreaturePosition(cid), 'Casting cancelled!', TEXTCOLOR_RED)
									doPlayerSendCancel(cid, 'You moved or gained infight. You have stopped casting.')
									countdownEvent[cid] = 0
									doSetStorage(cid, globalStorage, -1)
								end
							end
 
							local eventId = addEvent(finalCountdown, 0, cid, voc.castTime, getCreaturePosition(cid))
							countdownEvent[cid] = eventId
						else
							doPlayerSendCancel(cid, 'You\'re already casting a teleport!!')
							return true
						end
					else
						doPlayerSendCancel(cid, 'Someone else is casting a teleport. Please Wait.')
						return true
					end
				else
					doPlayerSendCancel(cid, 'No destination specified.')
				end
 
				doCreatureSay(cid, words .. ' ' .. t[1] .. ', ' .. t[2], TALKTYPE_ORANGE_1)
				return true
			end
		]]>
	</talkaction>
 
	<movement type='StepIn' itemid='1387' event='script'>
		<![CDATA[
			domodlib('Portal_config')
 
			local CLOSED = {
				[500] = {destination['temple'].position},
				[501] = {destination['other'].position},
				[502] = {destination['hello'].position},
				[503] = {destination['qwerty'].position}
			}
 
			local OPEN = {
				[1500] = {destination['temple'].position},
				[1501] = {destination['other'].position},
				[1502] = {destination['hello'].position},
				[1503] = {destination['qwerty'].position}
			}
 
			function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
				if(isInArray({1500,1501,1502,1503}, item.actionid)) then
					doTeleportThing(cid, OPEN[item.actionid][1])
					doSendMagicEffect(OPEN[item.actionid][1], 10)
				elseif(isInArray({500,501,502,503}, item.actionid)) then
					if((item.uid - getAccountIdByName(getCreatureName(cid))) == 10000) then
						doTeleportThing(cid, CLOSED[item.actionid][1])
						doSendMagicEffect(CLOSED[item.actionid][1], 10)
					else
						doPlayerSendCancel(cid, 'You can\'t go into the portal.')
						doTeleportThing(cid, lastPosition)
					end
				end
				return true
			end
		]]>
	</movement>
</mod>
 
Strange...I tested it and that doesn't happens anymore. Are there any error messages in the console or does it says something like 'Invalid param" or any other cancel message?
 
Nope, only returning this message:
LUA:
doPlayerSendCancel(cid, 'Someone else is casting a teleport. Please Wait.')


Maybe bad script you copied beacuse it's looking that nothing have been changed or I'm wrong
 
Try with this one:

LUA:
<?xml version='1.0' encoding='UTF-8'?>
<mod name='Portal_config' version='1.0' author='VirrageS' credits='Ratser' contact='otland.net' enabled='yes'>
	<config name='Portal_config'><![CDATA[
		setup = {
			[1] = {
				level = 1,
				premium = 'false',
				souls = 0,
				levelMagic = 0,
				castTime = 10,
				portalClosing = 'true',
				portalTime = 10,
				money = 5,
				reagentItem = 2478,
				effectType = 45,
				storage = 200415
			},
			[2] = {
				level = 1,
				premium = 'false',
				souls = 0,
				levelMagic = 0,
				castTime = 10,
				portalClosing = 'true',
				portalTime = 10,
				money = 5,
				reagentItem = 2478,
				effectType = 45,
				storage = 200425
			},
			[3] = {
				level = 1,
				premium = 'false',
				souls = 0,
				levelMagic = 0,
				castTime = 10,
				portalClosing = 'true',
				portalTime = 10,
				money = 5,
				reagentItem = 2478,
				effectType = 45,
				storage = 200435
			},
			[4] = {
				level = 1,
				premium = 'false',
				souls = 0,
				levelMagic = 0,
				castTime = 10,
				portalClosing = 'true',
				portalTime = 10,
				money = 5,
				reagentItem = 2478,
				effectType = 45,
				storage = 200445
			}
		}
		destination = { --EDIT THE DESTINATIONS HERE
			['temple'] = {
				closed = 500,
				open = 1500,
				position = {x = 96, y = 120, z = 7}
			},
			['other'] = {
				closed = 501,
				open = 1501,
				position = {x = 96, y = 125, z = 7}
			},
			['hello'] = {
				closed = 502,
				open = 1502,
				position = {x = 98, y = 126, z = 7}
			},
			['qwerty'] = {
				closed = 503,
				open = 1503,
				position = {x = 96, y = 130, z = 7}
			}
		}
		globalStorage = 5002
	]]></config>
 
	<talkaction words='!portal' event='script'>
		<![CDATA[
			domodlib('Portal_config')
			local countdownEvent = {}
			function onSay(cid, words, param)
				local voc = setup[getPlayerVocation(cid)]
				if(param == '') then
					local tutorialText = "¤ How to create a portal? ¤\n	!portal 'destination', 'open'/'closed'\n		'open': The portal may be used freely by anyone\n		'closed': Only the one who casted the portal may enter it"
					local destiText = "\n\n¤ You can choose one of this destinations: ¤\n	'temple'\n	'other'\n	'hello'\n	'qwerty'"
					local vocaText = "\n\n¤ Vocation requirements: ¤\n	Level: ".. voc.level .."\n	Magic level: ".. voc.levelMagic .."\n	Souls: ".. voc.souls .."\n	Money: ".. voc.money .." gold coin(s)\n	Premium: ".. voc.premium .."\n	Reagent item: ".. getItemInfo(voc.reagentItem).name ..""
					local abilityText = "\n\n¤ Abilities: ¤\n	Cast portal: ".. voc.castTime .. "\n	Portal\'s time ".. voc.portalTime .."\n	Closing portal: ".. voc.portalClosing ..""
					local totalText = tutorialText .. destiText .. vocaText .. abilityText
					doPlayerPopupFYI(cid, "                                           [ Portal Info ]\n\n" .. totalText)
 
					doCreatureSay(cid, words, TALKTYPE_ORANGE_1)
					return true
				end
 
				local t = string.explode(param, ',')
				if(t[1] ~= nil) then
					if(not destination[t[1]]) then
						doPlayerSendCancel(cid, 'Invalid destination specified.')
						return true
					end
 
					if(t[2] ~= 'open') then
						if(t[2] ~= 'closed') then
							doPlayerSendCancel(cid, 'Invalid param specified.')
							return true
						end
					end
 
					if(not voc) then
						doPlayerSendCancel(cid, 'You don\'t have the required vocation!')
						return true
					end
 
					if(getPlayerLevel(cid) < voc.level) then
						doPlayerSendCancel(cid, 'You don\'t have the required level!')
						return true
					end
 
					if(getCreatureStorage(cid, voc.storage) ~= -1) then
						doPlayerSendCancel(cid, 'You\'ve already created a portal!')
						return true
					end
 
					if(getPlayerMagLevel(cid) < voc.levelMagic) then
						doPlayerSendCancel(cid, 'You don\'t have the required magic level!')
						return true
					end
 
					if(getStorage(cid, globalStorage) == -1) then
						if(countdownEvent[cid] == nil or countdownEvent[cid] == 0) then
 
							if(getPlayerSoul(cid) >= voc.souls) then
								doPlayerAddSoul(cid, -voc.souls)
							else
								doPlayerSendCancel(cid, 'You don\'t have enough mana to create a portal! You need: '.. voc.souls ..'')
								return false
							end
 
							if(getPlayerItemCount(cid, voc.reagentItem) > 0) then
								doPlayerRemoveItem(cid, voc.reagentItem, 1)
							else
								doPlayerSendCancel(cid, 'You don\'t have \''.. getItemInfo(voc.reagentItem).name ..'\' which are/is reqiure to create portal!')
								return false
							end
 
							if(getPlayerMoney(cid) >= voc.money) then
								doPlayerRemoveMoney(cid, voc.money)
							else
								doPlayerSendCancel(cid, 'You don\'t have enough money! You need: '.. voc.money ..' gold coins.')
								return false
							end
 
							function finalCountdown(cid, countLeft, playerPos)
								if(not isPlayer(cid) or countLeft == 0) then
									if isPlayer(cid) then
										teleport = doCreateItem(1387, 1, playerPos)

										function deleteTeleport()
											local teleport = getTileItemById(playerPos, 1387).uid
											if(teleport > 0) then
												doRemoveItem(teleport)
												doCreatureSetStorage(cid, voc.storage, -1)
												doPlayerSendTextMessage(cid, 19, 'Your teleport run out of energy and colapsed.')
												doSendMagicEffect(playerPos, CONST_ME_POFF)
											end
										end
 
										if(t[2] == 'closed') then
											doItemSetAttribute(teleport, 'description', 'This portal can only be used by '.. getCreatureName(cid) ..'.')
											doItemSetAttribute(teleport, 'aid', destination[t[1]].closed)
											doItemSetAttribute(teleport, 'uid', (getAccountIdByName(getCreatureName(cid)) + 10000))
										elseif(t[2] == 'open') then
											doItemSetAttribute(teleport, 'description', 'The portal can be freely used by people. Destination \''.. t[1] ..'\'.')
											doItemSetAttribute(teleport, 'aid', destination[t[1]].open)
										end

										addEvent(deleteTeleport, voc.portalTime * 1000)
										doCreatureSetStorage(cid, voc.storage, 1)
										doSetStorage(cid, globalStorage, -1)
										doSendMagicEffect(playerPos, voc.effectType)
										doPlayerSendTextMessage(cid, 19, 'You have created a teleport.')
									end
 
									countdownEvent[cid] = 0
									return
								end
 
								local tmpPos = getCreaturePosition(cid)
								if((tmpPos.x == playerPos.x) and (tmpPos.y == playerPos.y)) then
									doSendAnimatedText(playerPos, 'Cast: '.. countLeft ..'', 11)
									doSendMagicEffect(playerPos, CONST_ME_FIREATTACK)
									doSetStorage(cid, globalStorage, 1)
									local eventId = addEvent(finalCountdown, 1000, cid, countLeft - 1, playerPos)
									countdownEvent[cid] = eventId
								else
									doSendAnimatedText(getCreaturePosition(cid), 'Casting cancelled!', TEXTCOLOR_RED)
									doPlayerSendCancel(cid, 'You moved or gained infight. You have stopped casting.')
									countdownEvent[cid] = 0
									doSetStorage(cid, globalStorage, -1)
								end
							end
 
							local eventId = addEvent(finalCountdown, 0, cid, voc.castTime, getCreaturePosition(cid))
							countdownEvent[cid] = eventId
						else
							doPlayerSendCancel(cid, 'You\'re already casting a teleport!!')
							return true
						end
					else
						doPlayerSendCancel(cid, 'Someone else is casting a teleport. Please Wait.')
						return true
					end
				else
					doPlayerSendCancel(cid, 'No destination specified.')
				end
 
				doCreatureSay(cid, words .. ' ' .. t[1] .. ', ' .. t[2], TALKTYPE_ORANGE_1)
				return true
			end
		]]>
	</talkaction>
 
	<movement type='StepIn' itemid='1387' event='script'>
		<![CDATA[
			domodlib('Portal_config')
 
			local CLOSED = {
				[500] = {destination['temple'].position},
				[501] = {destination['other'].position},
				[502] = {destination['hello'].position},
				[503] = {destination['qwerty'].position}
			}
 
			local OPEN = {
				[1500] = {destination['temple'].position},
				[1501] = {destination['other'].position},
				[1502] = {destination['hello'].position},
				[1503] = {destination['qwerty'].position}
			}
 
			function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
				if(isInArray({1500,1501,1502,1503}, item.actionid)) then
					doTeleportThing(cid, OPEN[item.actionid][1])
					doSendMagicEffect(OPEN[item.actionid][1], 10)
				elseif(isInArray({500,501,502,503}, item.actionid)) then
					if((item.uid - getAccountIdByName(getCreatureName(cid))) == 10000) then
						doTeleportThing(cid, CLOSED[item.actionid][1])
						doSendMagicEffect(CLOSED[item.actionid][1], 10)
					else
						doPlayerSendCancel(cid, 'You can\'t go into the portal.')
						doTeleportThing(cid, lastPosition)
					end
				end
				return true
			end
		]]>
	</movement>
</mod>
 
As I said...

...tested...

...and it works.

Are you REALLY sure the player that wants to cast the portal has the required items/coins?
 
I see that I didn't good explain problem. <_<

So I don't have in mean that only one player can create teleport that player can't cast portal while another player is casting it. And is there any soultion to solve it but without porblem with changing (open/closed)??? :huh:
 
Back
Top