Tp with storage value and summons monster OTX 2.9

Discussion in 'Requests' started by arael, Jul 13, 2017.

  1. arael

    arael New Member

    Joined:
    Jun 11, 2014
    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Hello guys, I wanted an script of a teleport that moves the player to X , spawns a monster (that monster depends on a storage value with a table and deletes the storage value of the player) some steps foward the player, meanwhile that same tp dont let other players to get there.

    I leave you here a little example if you dont understand me
    -----------------------------------------------------------
    local Table:
    [1] storagevalue 1, 1 = "monster name" then -1 to storage value 1, 1
    [1] storagevalue 2, 1 = "monster name" then -1 to storage value 2, 1

    onstep move player to pos X then check storagevalue table and summoncreature inpos X if creature is summond block teleport for X time to other players
    -----------------------------------------------------------
    thx guys and sorry if my english is bad.
     
  2. Best Answer:
    Post #2 by GarQet, Jul 13, 2017
  3. GarQet

    GarQet Own3d!

    Joined:
    Feb 10, 2009
    Messages:
    1,356
    Likes Received:
    74
    Best Answers:
    12
    Best Answer
    For each STORAGE you have specified monster and the room. After 60 seconds room is again available, if player or monster still is in, will be teleported out or killed (monster). If someone is in the room or just died in, the room will available after 60 seconds, you no need to use "stone" option, cause teleport will not work till this time.
    in config:
    [storage] = {monster name, monster position, where player will tp, room from, room to}
    Code (Lua):
    1. --Script made by GarQet--
    2. function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    3.    local config = {
    4.        monsters = {
    5.            [11111] = {"Dragon", {x = 1000, y = 1000, z = 7}, {x = 1020, y = 1000, z = 7}, {x = 1030, y = 1030, z = 7}, {x = 900, y = 900, z = 7}},
    6.            [11112] = {"Cat", {x = 1010, y = 1000, z = 7}, {x = 1020, y = 1000, z = 7}, {x = 1030, y = 1030, z = 7}, {x = 900, y = 900, z = 7}},
    7.            [11113] = {"Dragon Lord", {x = 1020, y = 1000, z = 7}, {x = 1020, y = 1000, z = 7}, {x = 1030, y = 1030, z = 7}, {x = 900, y = 900, z = 7}}
    8.        },
    9.        duration = 60,
    10.        kick_pos = {x = 1010, y = 1000, z = 7}
    11.    }
    12.    for storage, info in pairs(config.monsters) do
    13.        if getPlayerStorageValue(cid, storage) >= 1 and (os.time() - getGlobalStorageValue(storage)) >= config.duration then
    14.            doTeleportThing(cid, info[3])
    15.            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    16.            doCreateMonster(info[1], info[2])
    17.            doSendMagicEffect(info[2], CONST_ME_TELEPORT)
    18.            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your enemy is ".. info[1] ..".")
    19.            setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage) - 1)
    20.            setGlobalStorageValue(storage, os.time())
    21.            addEvent(function()
    22.                local fromp, top = info[4], info[5]
    23.                for x = fromp.x, top.x do
    24.                    for y = fromp.y, top.y do
    25.                        for z = fromp.z, top.z do
    26.                            local creature = getThingFromPos(areapos).uid
    27.                            if isPlayer(creature) then
    28.                                doTeleportThing(creature, config.kick_pos)
    29.                                doSendMagicEffect(creature, CONST_ME_TELEPORT)
    30.                                doPlayerSendTextMessage(creature, MESSAGE_INFO_DESCR, "You have been kicked out, the time expired.")
    31.                            end
    32.                            if isMonster(creature) then
    33.                                doRemoveCreature(creature, true)
    34.                            end
    35.                        end
    36.                    end
    37.                end
    38.            end, 1000 * config.duration)
    39.        else
    40.            doPlayerSendCancel(cid, "Someone else is in the room.")
    41.            doTeleportThing(cid, fromPosition)
    42.            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
    43.            return true
    44.        end
    45.    end
    46.    doTeleportThing(cid, fromPosition)
    47.    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
    48.    return true
    49. end
     
    Last edited: Jul 13, 2017
    arael likes this.
  4. arael

    arael New Member

    Joined:
    Jun 11, 2014
    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    thank you!
     

Share This Page

Loading...