TFS 1.0 Last Man Standing By Nevix

Discussion in 'GlobalEvents, Spells & CreatureEvents' started by nevix, Sep 20, 2014.

  1. nevix

    nevix Tunzodus.net

    Joined:
    Mar 31, 2010
    Messages:
    356
    Hello, as i'm saw here is a lot of last man stading events, anyway I will share my last man standing.
    Probably it is my first thing what I create good and working perfect :)

    * Starts every xxx minutes as you want.
    * Simple install.
    * Reward premium points, of course you can edit code by yourself.
    * Lets starts


    - Check every 10 seconds whats happening in fight area.
    ^ If here left 1 player he won event.

    I'm not good programmer but I tested it and it working 100% good. Anyway of cource printer LMS maybe stabile and better. But anyway guys it working good :)

    Photos:
    Waiting.....
    [​IMG]

    Here is event teleport into the room :)
    [​IMG]

    Waiting event in waiting room. :)
    [​IMG]

    After counter down all players who is in waiting room going into fight area!
    [​IMG]

    After one player left in event area:

    [​IMG]

    I'm adding global events files

    5 minutes you need change by yourself eg:
    2 hours: 2*60*60*1000
    rezult: 7200000
    Code:
    <globalevent name="Last Man Standing" interval="300000" script="my scripts/lms.lua"/>
    
    Movements:
    Code:
    <movevent event="StepIn" actionid="25001" script="my scripts/lmsjoin.lua"/>
    <movevent event="StepIn" actionid="25002" script="my scripts/lmsleave.lua"/>
    
    Waiting area should be PZ protection and anti logout.
    Fighting area should be PVP area and anti logout.

    tfs.lua put into globalevents.
    lmsjoin and lmsleave put into movements.

    Anyway you can edit code as you want :)
    Enjoy guys.

    Credit: Nevix
     

    Attached Files:

    Last edited: Sep 20, 2014
  2. ricotje1

    ricotje1 Member

    Joined:
    Nov 8, 2012
    Messages:
    234
    Nice :D I add the random spawn.
     
    Last edited: Oct 6, 2014
  3. Alek

    Alek ᵀᴴᴱ ᴼᴿᴵᴳᴵᴻᴬᴸs

    Joined:
    Feb 15, 2008
    Messages:
    697
    Nice (Y)
     
  4. matti450

    matti450 Active Member

    Joined:
    Apr 13, 2008
    Messages:
    508
    wont work :&

    Code:
    [08/02/2015 03:40:15] [Error - LuaScriptInterface::loadFile] cannot open data/globalevents/scripts/scripts/lms.lua: No such file or directory
    [08/02/2015 03:40:15] [Warning - Event::loadScript] Cannot load script (data/globalevents/scripts/scripts/lms.lua)
    [08/02/2015 03:40:15] cannot open data/globalevents/scripts/scripts/lms.lua: No such file or directory
    i get that error :/ what is it for version?
     
    Last edited by a moderator: Feb 12, 2015
  5. StreamSide

    StreamSide Joseluis Gonzalez

    Joined:
    Aug 31, 2007
    Messages:
    2,517
    post globalevents.xml
     
  6. matti450

    matti450 Active Member

    Joined:
    Apr 13, 2008
    Messages:
    508
    managed to fix the error and all worked but the problem was when that thing did created in t.e.x temple it was without teleport :/

    the teleport wont show up :/!!!!!!!!!!!!
     
    Last edited by a moderator: Feb 12, 2015
  7. StreamSide

    StreamSide Joseluis Gonzalez

    Joined:
    Aug 31, 2007
    Messages:
    2,517
    copy console errors and creatureevents.xml
     
  8. matti450

    matti450 Active Member

    Joined:
    Apr 13, 2008
    Messages:
    508
    dude i got no errors ffs, the only thing is that damn teleport do not spawns out only that pink items....
     
  9. nevix

    nevix Tunzodus.net

    Joined:
    Mar 31, 2010
    Messages:
    356
    TFS V.1.0.1 Everything working perfect because i'm using it.
     
  10. televolt

    televolt Member

    Joined:
    Jun 21, 2010
    Messages:
    153
    pink item = teleport
    check your moveevent
     
  11. gurden

    gurden i need support for my server, good scripter!

    Joined:
    May 19, 2009
    Messages:
    518
    problem with this is that if you are 1 vs 1 and someone walks away from the other. Both or 1 wins and get teleported out.
     
  12. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,425
    @nevix does it work on 1.1?
     
  13. nevix

    nevix Tunzodus.net

    Joined:
    Mar 31, 2010
    Messages:
    356
  14. Andreselos

    Andreselos Member

    Joined:
    Feb 9, 2015
    Messages:
    36
    i have this problem too, how to solve this?
     
  15. gurden

    gurden i need support for my server, good scripter!

    Joined:
    May 19, 2009
    Messages:
    518
    I dident solve this, its fucked this system.
     
  16. StreamSide

    StreamSide Joseluis Gonzalez

    Joined:
    Aug 31, 2007
    Messages:
    2,517
    what you mean, can you reproduce it again?
     
  17. yogiikke

    yogiikke :D

    Joined:
    Mar 24, 2013
    Messages:
    59
    @nevix

    would be nice if you also explained that we have to change. :)

    Code:
        portalwhere = {x= 32349, y=32222, z=7}
        local portal = doCreateItem(11796,1,portalwhere)
      doSetItemActionId(portal, 25001)
      doSendMagicEffect(portalwhere, CONST_ME_TELEPORT)
    
    
        iteminfo = {x= 32348, y=32222, z=7}
        local item = doCreateItem(1431,1,iteminfo)
      doSetItemActionId(item, 25002)
      doSendMagicEffect(iteminfo, CONST_ME_TELEPORT)
    works fine here except for the reward TFS 1.1 but i only used a perfect square as arena and waiting room maybe thats why they had that error/problem.

     
    Last edited: May 23, 2015
    nevix likes this.
  18. nevix

    nevix Tunzodus.net

    Joined:
    Mar 31, 2010
    Messages:
    356
    local spectators = getSpectators(waitingplace, 10, 10, false)

    10,10 -- means 10 squares from to center.

    you can change it depends how many squares you would like to put.
    small eg:

    [​IMG]

    It is local spectators = getSpectators(waitingplace, 2, 2, false) -- area
    you can increase it by yourself

    edited code improved:
    Just change
    local area_increase = 10 --

    Code:
    local centeroffight = {x = 32396, y = 32194, z = 7}
    local waitingplace = {x = 32245, y = 32206, z = 7}
    local depotcenter = {x = 32345, y = 32223, z = 7}
    local MinimumPlayers = 10
    local rewardpoints = 2
    local area_increase = 10
    
    
    
    
    local function lmsclosed1()
        broadcastMessage("Last Man Standing event will start in 1 minutes. Portal is opened in depot", MESSAGE_STATUS_WARNING)
    end
    
    
    local function lmsclosed()
    
    count = 0
            local spectators = getSpectators(waitingplace, area_increase, area_increase, false)
            if spectators ~= nil then
                    for _, spectator in ipairs(spectators) do
                            if isPlayer(spectator) then   
                             count = count + 1
                          
                            end
                    end
            end
           
           
           
    if (count >= MinimumPlayers) then
    
    broadcastMessage("Last Man Standing event portal closed and event started!", MESSAGE_STATUS_WARNING)
    
    for _, pid in ipairs(getOnlinePlayers()) do
        if getPlayerStorageValue(pid, 25001) == 1 then
    local playerids = getPlayerByName(pid)
    doTeleportThing(playerids,centeroffight)
    doSendMagicEffect(center, CONST_ME_TELEPORT)
        end
          
    end
    
    else
    
    broadcastMessage("Not enough players to start Last man Standing event! Minimum: "..MinimumPlayers.." players. We have "..count.."!", MESSAGE_STATUS_WARNING)
    setGlobalStorageValue(25002, 0)
    
    for _, pid in ipairs(getOnlinePlayers()) do
        if getPlayerStorageValue(pid, 25001) == 1 then
    local playerids = getPlayerByName(pid)
    doTeleportThing(playerids,depotcenter)
    doSendMagicEffect(depotcenter, CONST_ME_TELEPORT)
    setPlayerStorageValue(pid, 25001, 0)
    
        end
    end
    
    end
    
    
    return true
    end
    
    
    
    
    
    local function lmscheck()
    
    
    count = 0
            local spectators = getSpectators(centeroffight, area_increase, area_increase, false)
            if spectators ~= nil then
                    for _, spectator in ipairs(spectators) do
                            if isPlayer(spectator) then   
                             count = count + 1
                          
                            end
                    end
            end
    
    if count == 1 then
    
    
    for _, pid in ipairs(getOnlinePlayers()) do
        if getPlayerStorageValue(pid, 25001) == 1 then
    local playerids = getPlayerByName(pid)
    setPlayerStorageValue(playerids, 25001, 0)
        end
    end
    
            local spectators = getSpectators(centeroffight, area_increase, area_increase, false)
            if spectators ~= nil then
                    for _, spectator in ipairs(spectators) do
                            if isPlayer(spectator) then 
    
               
               
    doTeleportThing(spectator,depotcenter)
    doSendMagicEffect(depotcenter, CONST_ME_TELEPORT)
    broadcastMessage("LMS ended winner is: "..getPlayerName(spectator)..", reward is 2 premium points.", MESSAGE_STATUS_WARNING)
      
    local accid = Player(spectator):getAccountId()
    local points = rewardpoints
    db.query("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. accid)
                         end
                    end
            end
           
    
    
    for _, pid in ipairs(getOnlinePlayers()) do
        if getPlayerStorageValue(pid, 25001) == 1 then
    local playerids = getPlayerByName(pid)
    setPlayerStorageValue(pid, 25001, 0)
    end
    end
    
    stopEvent(lmscheck)
    
    else
    addEvent(lmscheck, 10*1000)
    end
    end
    
    
    
    local function lms()
        broadcastMessage("Last Man Standing event will start in 2 minutes. Portal is opened in depot", MESSAGE_STATUS_WARNING)
    
        portalwhere = {x= 32349, y=32222, z=7}
        local portal = doCreateItem(11796,1,portalwhere)
      doSetItemActionId(portal, 25001)
      doSendMagicEffect(portalwhere, CONST_ME_TELEPORT)
    
    
        iteminfo = {x= 32348, y=32222, z=7}
        local item = doCreateItem(1431,1,iteminfo)
      doSetItemActionId(item, 25002)
      doSendMagicEffect(iteminfo, CONST_ME_TELEPORT)
     
    addEvent(function() doRemoveItem(getTileItemById(portalwhere, 11796).uid) end, 120 * 1000)
    addEvent(function() doSendMagicEffect(portalwhere, CONST_ME_TELEPORT) end, 120 * 1000)
    
    addEvent(function() doRemoveItem(getTileItemById(iteminfo, 1431).uid) end, 120 * 1000)
    addEvent(function() doSendMagicEffect(iteminfo, CONST_ME_TELEPORT) end, 120 * 1000)
    
    addEvent(lmsclosed, 2*60*1000)
    addEvent(lmsclosed1, 1*60*1000)
    addEvent(lmscheck, 130*1000)
    
    return true
    end
    
    
    
    function onThink(interval)
    
        broadcastMessage("Last Man Standing event will start in 3 minutes.", MESSAGE_STATUS_WARNING)
        addEvent(lms, 60*1000)
    
    
    
    for _, pid in ipairs(getOnlinePlayers()) do
        if getPlayerStorageValue(pid, 25001) == 1 then
    local playerids = getPlayerByName(pid)
    doTeleportThing(playerids,depotcenter)
    doSendMagicEffect(depotcenter, CONST_ME_TELEPORT)
    setPlayerStorageValue(pid, 25001, 0)
    
        end
    end
    
    
    return true
    end
     
    yogiikke likes this.
  19. yogiikke

    yogiikke :D

    Joined:
    Mar 24, 2013
    Messages:
    59
    @nevix

    can you make it that reward is an item or random from 5 items that is configurable? like itemid chance 500 and second itemid chance 1000 or something?
     
  20. nevix

    nevix Tunzodus.net

    Joined:
    Mar 31, 2010
    Messages:
    356
    I know how to do it, but if I'm gonna do it everything for you, you will never learn lua language.

    random number 1,5
    itemchance like 1,10

    if random number == 1 && itemchance == 1 then
    you got this item
    elseif random number == 2 && itemchance == 1 then
    you got this item

    you can configure it by yourself very easily
     

Share This Page