• 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!

Lua (Mod) Help on Remove Tp on event close

Aldo Axel

New Member
Joined
Jul 14, 2014
Messages
70
Reaction score
4
Greetings, my issue is on the Classic MOD of CTF Event ( Capture The Flag)
in this part where when the event ends, the teleport is still open, and in my case i want the teleport to be removed...
(MOD, ) CTF.xml:
Capture The Flag Event.xml

Essential part:
Code:
Tp_Place = {x=824,y=1018,z=7} -- Place where tp happens

<movevent type="StepIn" actionid="3435" event="script"><![CDATA[
    domodlib('toto')
    domodlib('CTF-lib')
    function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
            if getStorage(Event_Tile_Close) > 0 then
                    if getPlayerLevel(cid) < Min_Join_Level then
                       doTeleportThing(cid,fromPosition,false)
                            doSendMagicEffect(fromPosition,10)
                            doPlayerSendTextMessage(cid,21,"Only players of level "..Min_Join_Level.." are allowed to pass.")
                    else
                            doTeleportThing(cid,Wait_Place,false)
                            doSendMagicEffect(Wait_Place,10)
                    end
            else
                    doTeleportThing(cid,fromPosition,false)
                    doSendMagicEffect(fromPosition,10)
                    doPlayerSendTextMessage(cid,21,"Back later the event is closed...")
            end
    return true
    end

    ]]></movevent>
 
this part for tp the player for event place the part for remove the tp u will get it in function doRemoveTeleport(pos)
 
  1. Code:
    Tp_Place = {x=824,y=1018,z=7} -- Place where tp happens
    [*]
    
    [*]<movevent type="StepIn" actionid="3435" event="script"><![CDATA[
    [*]    domodlib('toto')
    [*]    domodlib('CTF-lib')
    [*]    function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    [*]            if getStorage(Event_Tile_Close) > 0 then
    [*]                    if getPlayerLevel(cid) < Min_Join_Level then
    [*]                       doRemoveTeleport(pos)
    [*]                       doTeleportThing(cid,fromPosition,false)
    [*]                            doSendMagicEffect(fromPosition,10)
    [*]                            doPlayerSendTextMessage(cid,21,"Only players of level "..Min_Join_Level.." are allowed to pass.")
    [*]                    else
    [*]                            doTeleportThing(cid,Wait_Place,false)
    [*]                            doSendMagicEffect(Wait_Place,10)
    [*]                    end
    [*]            else
    [*]                    doTeleportThing(cid,fromPosition,false)
    [*]                    doSendMagicEffect(fromPosition,10)
    [*]                    doPlayerSendTextMessage(cid,21,"Back later the event is closed...")
    [*]            end
    [*]    return true
    [*]    end
    [*]
    
    [*]    ]]></movevent>
???
 
search on function doRemoveTeleport in mob u will get doRemoveItem(getTileItemById(Tp_Place, 1387).uid, 1) edite this by teleport id and place or post full mod and i will make for u
 
After line 571 in the function eventEnd() is where you want to remove the teleport. This is where the team that won is broadcasted and all the players storage values are reset and teleported to the player's temple.
Lua:
function eventEnd()
    if getGlobalStorageValue(Event_Start) > 0 and getGlobalStorageValue(Event_timeend) > 0 then
        if getRedScore() > getBlueScore() then
            doBroadcastMessage('CTF-Event : The '.. TEAM2_NAME..' team won and recieved their reward.')
            for _,cid in ipairs(getPlayersOnline()) do
                if isTeamTwo(cid) then
                    doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
                    doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
                    doRemoveConditions(cid,false)
                    resetTheTeams(cid)
                    doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid)) - getCreatureSpeed(cid))
                    giveReward(cid)
                elseif isTeamOne(cid) then
                    doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
                    doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
                    doRemoveConditions(cid,false)
                    doPlayerSendTextMessage(cid,22,'Your team have lost.')
                    resetTheTeams(cid)
                    doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid)) - getCreatureSpeed(cid))
                end
            end
        elseif getRedScore() < getBlueScore() then
            doBroadcastMessage('CTF-Event : The '.. TEAM1_NAME..' team won and recieved their reward.')
            for _,cid in ipairs(getPlayersOnline()) do
                if isTeamOne(cid) then
                    doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
                    doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
                    doRemoveConditions(cid,false)
                    resetTheTeams(cid)
                    doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid)) - getCreatureSpeed(cid))
                    giveReward(cid)
                elseif isTeamTwo(cid) then
                    doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
                    doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
                    doRemoveConditions(cid,false)
                    doPlayerSendTextMessage(cid,22,'Your team have lost.')
                    resetTheTeams(cid)
                    doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid)) - getCreatureSpeed(cid))
                end
            end
        elseif getRedScore() == getBlueScore() then
            doBroadcastMessage('CTF-Event : The Event ended with a draw between both teams.')
            for _,cid in ipairs(getPlayersOnline()) do
                if isTeamTwo(cid) or isTeamOne(cid) then
                    doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
                    doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
                    doRemoveConditions(cid,false)
                    doPlayerSendTextMessage(cid,22,'It was a draw between both teams.')
                    resetTheTeams(cid)
                    doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid)) - getCreatureSpeed(cid))
                end
            end

        end
        addEvent(resetTheStorage,1000)
        -- remove the teleporter if its exist
        if getTileItemById(Tp_Place, 1387).uid > 0 then
            doRemoveItem(getTileItemById(Tp_Place, 1387).uid, 1)
        end
    end
end
 
@OT World error runtime on console in:
  1. -- remove the teleporter if its exist
  2. if getTileItemById(Tp_Place, 1387).uid > 0 then
  3. doRemoveItem(getTileItemById(Tp_Place, 1387).uid, 1)

@heba the teleport removed when the player enter into the teleport
 
Look for function eventEnd() on your script and add doRemoveItem(getTileItemById(Tp_Place, 1387).uid, 1) on each case if one team won or was draw. Look on the script i added 3 times doRemove~:
Lua:
function eventEnd()
        if getGlobalStorageValue(Event_Start) > 0 and getGlobalStorageValue(Event_timeend) > 0 then
                if getRedScore() > getBlueScore() then
                        doBroadcastMessage('CTF-Event : The '.. TEAM2_NAME..' team won and recieved their reward.')
                                for _,cid in ipairs(getPlayersOnline()) do
                                        if isTeamTwo(cid) then
                                                doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
                                                doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
                                                doRemoveConditions(cid,false)
                                                resetTheTeams(cid)
                                                doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid)) - getCreatureSpeed(cid))
                                                giveReward(cid)
                                               doRemoveItem(getTileItemById(Tp_Place, 1387).uid, 1)  -------- Remove the TP
                                        elseif isTeamOne(cid) then
                                                doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
                                                doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
                                                doRemoveConditions(cid,false)
                                                doPlayerSendTextMessage(cid,22,'Your team have lost.')
                                                resetTheTeams(cid)
                                                doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid)) - getCreatureSpeed(cid))
                                        end
                                end

                elseif getRedScore() < getBlueScore() then
                        doBroadcastMessage('CTF-Event : The '.. TEAM1_NAME..' team won and recieved their reward.')
                                for _,cid in ipairs(getPlayersOnline()) do
                                        if isTeamOne(cid) then
                                                doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
                                                doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
                                                doRemoveConditions(cid,false)
                                                resetTheTeams(cid)
                                                doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid)) - getCreatureSpeed(cid))
                                                giveReward(cid)
                                               doRemoveItem(getTileItemById(Tp_Place, 1387).uid, 1)  -------- Remove the TP
                                        elseif isTeamTwo(cid) then
                                                doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
                                                doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
                                                doRemoveConditions(cid,false)
                                                doPlayerSendTextMessage(cid,22,'Your team have lost.')
                                                resetTheTeams(cid)
                                                doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid)) - getCreatureSpeed(cid))                                            
                                        end
                                end
                elseif getRedScore() == getBlueScore() then
                        doBroadcastMessage('CTF-Event : The Event ended with a draw between both teams.')
                                for _,cid in ipairs(getPlayersOnline()) do
                                        if isTeamTwo(cid) or isTeamOne(cid) then
                                                doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
                                                doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
                                                doRemoveConditions(cid,false)
                                                doPlayerSendTextMessage(cid,22,'It was a draw between both teams.')
                                                resetTheTeams(cid)
                                                doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid)) - getCreatureSpeed(cid))
                                                 doRemoveItem(getTileItemById(Tp_Place, 1387).uid, 1)  -------- Remove the TP
                                        end
                                end

                end
                addEvent(resetTheStorage,1000)
        end
end
 
Last edited:
Look for function eventEnd() on your script and add doRemoveItem(getTileItemById(Tp_Place, 1387).uid, 1) on each case if one team won or was draw. Look on the script i added 3 times doRemove~:
Code:
function eventEnd()
        if getGlobalStorageValue(Event_Start) > 0 and getGlobalStorageValue(Event_timeend) > 0 then
                if getRedScore() > getBlueScore() then
                        doBroadcastMessage('CTF-Event : The '.. TEAM2_NAME..' team won and recieved their reward.')
                                for _,cid in ipairs(getPlayersOnline()) do
                                        if isTeamTwo(cid) then
                                                doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
                                                doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
                                                doRemoveConditions(cid,false)
                                                resetTheTeams(cid)
                                                doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid)) - getCreatureSpeed(cid))
                                                giveReward(cid)
                                               doRemoveItem(getTileItemById(Tp_Place, 1387).uid, 1)  -------- Remove the TP
                                        elseif isTeamOne(cid) then
                                                doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
                                                doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
                                                doRemoveConditions(cid,false)
                                                doPlayerSendTextMessage(cid,22,'Your team have lost.')
                                                resetTheTeams(cid)
                                                doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid)) - getCreatureSpeed(cid))
                                        end
                                end

                elseif getRedScore() < getBlueScore() then
                        doBroadcastMessage('CTF-Event : The '.. TEAM1_NAME..' team won and recieved their reward.')
                                for _,cid in ipairs(getPlayersOnline()) do
                                        if isTeamOne(cid) then
                                                doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
                                                doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
                                                doRemoveConditions(cid,false)
                                                resetTheTeams(cid)
                                                doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid)) - getCreatureSpeed(cid))
                                                giveReward(cid)
                                               doRemoveItem(getTileItemById(Tp_Place, 1387).uid, 1)  -------- Remove the TP
                                        elseif isTeamTwo(cid) then
                                                doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
                                                doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
                                                doRemoveConditions(cid,false)
                                                doPlayerSendTextMessage(cid,22,'Your team have lost.')
                                                resetTheTeams(cid)
                                                doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid)) - getCreatureSpeed(cid))                                          
                                        end
                                end
                elseif getRedScore() == getBlueScore() then
                        doBroadcastMessage('CTF-Event : The Event ended with a draw between both teams.')
                                for _,cid in ipairs(getPlayersOnline()) do
                                        if isTeamTwo(cid) or isTeamOne(cid) then
                                                doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
                                                doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
                                                doRemoveConditions(cid,false)
                                                doPlayerSendTextMessage(cid,22,'It was a draw between both teams.')
                                                resetTheTeams(cid)
                                                doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid)) - getCreatureSpeed(cid))
                                                 doRemoveItem(getTileItemById(Tp_Place, 1387).uid, 1)  -------- Remove the TP
                                        end
                                end

                end
                addEvent(resetTheStorage,1000)
        end
end
I already provided you with an explanation of what the issue could be and a possible solution. All you needed to do was copy and paste the code I provided nothing more. I see that you aren't the original OP, however if you have an issue with the solution please say so because I can't tell the difference between you asking a question or making a statement.

If you are providing your own solution then there is no reason to add the removal of the teleporter more than 1 time.
 
Last edited:
I already provided you with an explanation of what the issue could be and a possible solution. All you needed to do was copy and paste the code I provided nothing more. I see that you aren't the original OP, however if you have an issue with the solution please say so because I can't tell the difference between you asking a question or making a statement.

If you are providing your own solution then there is no reason to add the removal of the teleporter more than 1 time.
I didnt see your post and the guy tell you than your script doesnt work. I prefer add 3 times on the script because it will solve the problem. And look ir script :
  • if getTileItemById(Tp_Place, 1387).uid > 0 then -------> where is the ( )??
  • doRemoveItem(getTileItemById(Tp_Place, 1387).uid, 1)
 
I didnt see your post and the guy tell you than your script doesnt work. I prefer add 3 times on the script because it will solve the problem. And look ir script :
  • if getTileItemById(Tp_Place, 1387).uid > 0 then -------> where is the ( )??
  • doRemoveItem(getTileItemById(Tp_Place, 1387).uid, 1)
You don't always need to encapsulate code inside of parentheses, that requirement is language independent. If the code doesn't work then we move on to something which does.
 
ngP3gfz
 
Back
Top