• 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.
 
I dont understand a shit :p, if you want help please post what the script do, what is wrong in it, how you want it to work.

Script: :D
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 = {}
			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(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)
										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), 'Casting cancelled!', TEXTCOLOR_RED)
									doPlayerSendCancel(cid, 'You moved or gained infight. You have stopped 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
 
				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>

In script is one problem so when player1 creating portal (open) and player2 started casting (closed) 2sec after player1 then two portal will be CLOSED after cast. :(

And it happens inversely too. <_<

Can someone fix it??
 
Last edited:
Back
Top