<?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}}
dest = {["temple"] = {x = 95, y = 120, z = 7},
["other"] = {x = 96, y = 125, z = 7},
["hello"] = {x = 96, y = 125, z = 7}}
actiid = 500
unquid = 20000
]]></config>
<talkaction words="!portal" event="script"><![CDATA[
domodlib("Portal_config")
local countdownEvent = {}
function onSay(cid, words, param)
param = param.explode(param, ',')
local voc = setup[getPlayerVocation(cid)]
if (param[1] == "info") 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)
doCreatureSay(cid, words .. ' ' .. param[1], TALKTYPE_ORANGE_1)
elseif (param[1] ~= nil and param[2] ~= nil) then
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 should to have: '.. voc.money ..' golds')
return false
end
if (getPlayerSoul(cid) >= voc.souls) then
doPlayerAddSoul(cid, - voc.souls)
else
doPlayerSendCancel(cid, 'You don\'t have enough mana to create portal! You should to have: '.. 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 teleport.')
teleport = doCreateTeleport(1387, dest[param[1]], playerPos)
doSendMagicEffect(playerPos, voc.effectType)
doCreatureSetStorage(cid, voc.storage, 1)
function deleteTeleport()
local teleport = getTileItemById(playerPos, 1387).uid
if(teleport > 0) then
doRemoveItem(teleport)
doCreatureSetStorage(cid, voc.storage, -1)
doPlayerSendTextMessage(cid, 19, 'Your teleport have outed of energy and colapsed.')
doSendMagicEffect(playerPos, CONST_ME_POFF)
end
end
if (param[2] == 'closed') then
doItemSetAttribute(teleport, 'description', 'Go into to this portal only can '.. getCreatureName(cid) ..'.')
doItemSetAttribute(teleport, 'aid', 1500)
else
doItemSetAttribute(teleport, 'description', 'The portal may enter '.. param[2] ..' people left.')
doItemSetAttribute(teleport, 'aid', actiid + param[2])
end
addEvent(deleteTeleport, voc.portalTime * 1000)
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 start fight. 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 teleport.')
return true
end
doCreatureSay(cid, words .. ' ' .. param[1] .. ', ' .. param[2], TALKTYPE_ORANGE_1)
else
doPlayerSendCancel(cid, 'You must set param!')
end
return true
end
]]></talkaction>
<movement type="StepIn" itemid="1387" event="script"><![CDATA[
domodlib("Portal_config")
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
--[[if (item.actionid > actiid) then
doItemSetAttribute(item.uid, 'description', 'The portal may enter '.. (item.actionid - actiid - 1) ..' people left.')
doItemSetAttribute(item.uid, 'aid', item.actionid - 1)
if ((item.actionid - actiid) == 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 == 1500 and getCreatureStorage(cid, 20044) < 0) then
doTeleportThing(cid, fromPosition)
doPlayerSendCancel(cid,'You can\'t enter here with a mount.')
end
return true
end
]]></movement>
</mod>