<?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>