Pedrook
Advanced OT User
- Joined
- May 24, 2009
- Messages
- 457
- Solutions
- 3
- Reaction score
- 194
- Location
- Brazil
- GitHub
- pedrogiampietro
Code:
-- Tasksystem based TP Room system made by Zbizu for Otland.net
function onStepIn(cid, item, position, fromPosition)
rankStorage = 32150
-- list of ranks to display
rankList = {
[0] = "Beginner",
[1] = "Huntsman",
[2] = "Ranger",
[3] = "Big Game Hunter",
[4] = "Trophy Hunter",
[5] = "Elite Hunter"
}
-- failtiers, positions to drop when failed
failPos = {
[1] = {
[1] = {x=297, y=339, z=7},
[2] = {x=251, y=301, z=8},
[3] = {x=207, y=375, z=7}
},
[2] = {
[1] = {x=355, y=297, z=7},
[2] = {x=358, y=197, z=7},
[3] = {x=415, y=345, z=8}
},
[3] = {
[1] = {x=305, y=388, z=8},
[2] = {x=276, y=304, z=13},
[3] = {x=236, y=294, z=8}
},
[4] = {
[1] = {x = 746, y = 642, z = 7},
[2] = {x = 708, y = 642, z = 5},
[3] = {x = 676, y = 585, z = 7}
}
}
-- usage: [uid] = {destination x, y, z, rank required, cost, place name, positions in failPos table to drop player if teleportation fails. Failtier 0 means 100% chance to successful teleportation}
uid = {
[8000] = {x=311, y=394, z=11, rank = 0, pearlscost = 0, name = "Spectral Hunters Guild", failtier = 0, effect = CONST_ME_PURPLEENERGY},
[8001] = {x=233, y=365, z=6, rank = 0, pearlscost = 2, name = "Enigma Dragon Lair", failtier = 0, effect = CONST_ME_TELEPORT},
[8002] = {x=260, y=309, z=8, rank = 0, pearlscost = 1, name = "Forbidden Mine", failtier = 0, effect = CONST_ME_TELEPORT},
[8003] = {x=313, y=298, z=7, rank = 0, pearlscost = 1, name = "Trollish Sector", failtier = 0, effect = CONST_ME_TELEPORT},
[8004] = {x=345, y=307, z=7, rank = 0, pearlscost = 1, name = "Cave of the Giants", failtier = 0, effect = CONST_ME_TELEPORT},
[8005] = {x=501, y=149, z=8, rank = 0, pearlscost = 5, name = "Jungle Temple Tunnels", failtier = 0, effect = CONST_ME_POISONAREA},
[8006] = {x=439, y=209, z=7, rank = 0, pearlscost = 5, name = "Hill of Green Nightmares", failtier = 0, effect = CONST_ME_POISONAREA},
[8007] = {x=355, y=296, z=8, rank = 0, pearlscost = 3, name = "Swampy Subregion", failtier = 0, effect = CONST_ME_POISONAREA},
[8008] = {x=679, y=331, z=5, rank = 0, pearlscost = 5, name = "Thurin Dragon Lair: Caves", failtier = 0, effect = CONST_ME_HITBYFIRE},
[8009] = {x=440, y=262, z=14, rank = 0, pearlscost = 5, name = "Demonic Residence", failtier = 0, effect = CONST_ME_HITBYFIRE},
[8010] = {x=43, y=479, z=7, rank = 0, pearlscost = 5, name = "Frohin", failtier = 0, effect = CONST_ME_TELEPORT},
[8011] = {x=396, y=184, z=6, rank = 0, pearlscost = 3, name = "destroyed part of jungle", failtier = 0, effect = CONST_ME_MORTAREA},
[8012] = {x=152, y=140, z=11, rank = 0, pearlscost = 5, name = "Abandoned Mines", failtier = 0, effect = CONST_ME_MORTAREA},
[8013] = {x=736, y=698, z=7, rank = 0, pearlscost = 5, name = "Gray Shore", failtier = 0, effect = CONST_ME_TELEPORT},
[8014] = {x=690, y=578, z=4, rank = 0, pearlscost = 5, name = "Purple Cliff", failtier = 0, effect = CONST_ME_PURPLEENERGY},
[8015] = {x=822, y=422, z=3, rank = 0, pearlscost = 5, name = "North Mines: East Wing", failtier = 0, effect = CONST_ME_MORTAREA},
[8016] = {x=204, y=375, z=7, rank = 0, pearlscost = 2, name = "Enigma Cemetery", failtier = 0, effect = CONST_ME_MORTAREA},
[8017] = {x=567, y=391, z=7, rank = 0, pearlscost = 5, name = "Thurin Dragon Lair", failtier = 0, effect = CONST_ME_HITBYFIRE},
[8018] = {x=693, y=565, z=6, rank = 0, pearlscost = 5, name = "Purple Cliff: Caves", failtier = 0, effect = CONST_ME_POISONAREA},
[8019] = {x=461, y=1155, z=7, rank = 0, pearlscost = 5, name = "Frozen Dragon Lair", failtier = 0, effect = CONST_ME_ICEAREA},
[8020] = {x=232, y=362, z=7, rank = 0, pearlscost = 2, name = "South Enigma", failtier = 0, effect = CONST_ME_TELEPORT},
[8021] = {x=328, y=320, z=11, rank = 0, pearlscost = 3, name = "Cave of The Giants: Lower Floor", failtier = 0, effect = CONST_ME_GROUNDSHAKER},
[8022] = {x=601, y=303, z=4, rank = 0, pearlscost = 5, name = "Thurin Plains", failtier = 0, effect = CONST_ME_GROUNDSHAKER},
[8023] = {x=378, y=351, z=7, rank = 0, pearlscost = 2, name = "Swampy Subregion", failtier = 0, effect = CONST_ME_POISONAREA},
[8024] = {x=884, y=87, z=6, rank = 0, pearlscost = 5, name = "Eastern Hills", failtier = 0, effect = CONST_ME_GROUNDSHAKER},
[8025] = {x=800, y=514, z=5, rank = 0, pearlscost = 4, name = "Thurin: South Mines", failtier = 0, effect = CONST_ME_GROUNDSHAKER},
[8026] = {x=797, y=203, z=5, rank = 0, pearlscost = 5, name = "Thurin: Eastern Plains", failtier = 0, effect = CONST_ME_GROUNDSHAKER},
[8027] = {x=366, y=38, z=7, rank = 0, pearlscost = 5, name = "Calassa", failtier = 0, effect = CONST_ME_TELEPORT},
[8028] = {x=833, y=674, z=7, rank = 0, pearlscost = 5, name = "Nargor", failtier = 0, effect = CONST_ME_TELEPORT},
[8029] = {x=465, y=274, z=7, rank = 0, pearlscost = 3, name = "Ancient Lizard Village", failtier = 0, effect = CONST_ME_TELEPORT},
[8030] = {x=127, y=1096, z=7, rank = 0, pearlscost = 4, name = "Frost Mansion", failtier = 0, effect = CONST_ME_ICEAREA},
[8031] = {x=434, y=997, z=6, rank = 0, pearlscost = 4, name = "Frost Mountains", failtier = 0, effect = CONST_ME_ICEAREA},
[8032] = {x=538, y=1013, z=7, rank = 0, pearlscost = 4, name = "Frost Mountains: Caves", failtier = 0, effect = CONST_ME_ICEAREA},
[8033] = {x=311, y=394, z=11, rank = 0, pearlscost = 0, name = "Spectral Hunters Guild", failtier = 0, effect = CONST_ME_PURPLEENERGY},
[8034] = {x=1105, y=1326, z=15, rank = 0, pearlscost = 5, name = "Grindstone Lair", failtier = 0, effect = CONST_ME_HITBYFIRE},
}
entry = uid[item.uid]
pos = {x=entry.x, y=entry.y, z=entry.z}
deny = {x=311, y=392, z=9} -- player will be teleported there if he is not allowed to use the teleporter
if isPlayer(cid) then
rankGet = getCreatureStorage(cid, rankStorage)
-- Tasksystem ranks from rankList
-- I 0-4
-- II 5-9
-- III 10-19
-- IV 20-29
-- V 30-49
-- VI 50+
if (rankGet > 4 and rankGet < 10) then
rank = 1
elseif (rankGet > 9 and rankGet < 20) then
rank = 2
elseif (rankGet > 19 and rankGet < 30) then
rank = 3
elseif (rankGet > 29 and rankGet < 50) then
rank = 4
elseif (rankGet > 49) then
rank = 5
else
rank = 0
end
if rank >= entry.rank then
if doPlayerTakeItem(cid, 5022, entry.pearlscost) then
fail = math.random(1, 10)
if fail > 1 then
doTeleportThing(cid,pos)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[TP Room]: Teleportation to " .. entry.name .. " successful. Charged " .. entry.pearlscost .. " pearls.")
if item.uid == 8000 or item.uid == 8033 then
if getPlayerStorageValue(cid, 14515) < 1 then
doSendMagicEffect({x = 316, y = 391, z = 11}, CONST_ME_TUTORIALARROW, cid)
addEvent(doSendMagicEffect, 10, {x = 316, y = 391, z = 11}, CONST_ME_TUTORIALSQUARE, cid)
end
doCreatureSay(cid, "TP ROOM\nup", TALKTYPE_ORANGE_1, true, cid, {x = 311, y = 392, z = 11})
doCreatureSay(cid, "PEARLS", TALKTYPE_ORANGE_1, true, cid, {x = 317, y = 390, z = 11})
doCreatureSay(cid, "EXIT", TALKTYPE_ORANGE_1, true, cid, {x = 318, y = 394, z = 11})
return true
end
doCreatureSay(cid, "Entering the " .. entry.name .. ".", TALKTYPE_ORANGE_1, true, cid)
else
if entry.failtier <= 0 then
doTeleportThing(cid,pos)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[TP Room]: Teleportation to " .. entry.name .. " successful. Charged " .. entry.pearlscost .. " pearls.")
if item.uid == 8000 or item.uid == 8033 then
if getPlayerStorageValue(cid, 14515) < 1 then
doSendMagicEffect({x = 316, y = 391, z = 11}, CONST_ME_TUTORIALARROW, cid)
addEvent(doSendMagicEffect, 10, {x = 316, y = 391, z = 11}, CONST_ME_TUTORIALSQUARE, cid)
end
doCreatureSay(cid, "TP ROOM\nup", TALKTYPE_ORANGE_1, true, cid, {x = 311, y = 392, z = 11})
doCreatureSay(cid, "PEARLS", TALKTYPE_ORANGE_1, true, cid, {x = 317, y = 390, z = 11})
doCreatureSay(cid, "EXIT", TALKTYPE_ORANGE_1, true, cid, {x = 318, y = 394, z = 11})
return true
end
doCreatureSay(cid, "Entering the " .. entry.name .. ".", TALKTYPE_ORANGE_1, true, cid)
else
doTeleportThing(cid,failPos[entry.failtier][math.random(1, #failPos[entry.failtier])])
doCreatureSay(cid, "Network failure. Dropping to nearest available location.", TALKTYPE_ORANGE_1, true, cid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[TP Room]: Teleportation to " .. entry.name .. " failed. " .. entry.pearlscost .. " pearls used, dropped to nearest available location.")
end
end
else
doTeleportThing(cid,deny)
doCreatureSay(cid, "You need " .. entry.pearlscost .. " pearls to enter the " .. entry.name .. ".", TALKTYPE_ORANGE_1, true, cid)
return true
end
else
doTeleportThing(cid,deny)
doCreatureSay(cid, "Area unavailable for players under " .. rankList[entry.rank] .. " rank.", TALKTYPE_ORANGE_1, true, cid)
return true
end
doSendMagicEffect(position, entry.effect)
doSendMagicEffect(getThingPos(cid), CONST_ME_FIREAREA)
doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
else
return true
end
return true
end