Welcome to Ac-Web AC-Web

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?

Ask a Question

Ask Questions and Get Answers from Our Community

Ac-Web Official Repacks !

Here you will find all our official repacks

Contact Us

Contact a Staff member if needed

Lua L.M.S

WiFiHaxR

Veteran
Veteran
joined: Oct 29, 2013
messages: 732
Reaction score: 19
Points: 30
Credits: 140
This event will teleport all participating players to a designated arena. The players will then fight each other, and the last player alive wins the event. Once the event is over, all participating players will be teleported back to their original locations.


Code:
local EVENT_NPC_ENTRY = 658
local ARENA_MAP_ID = 530
local ARENA_LOCATION = {x = -2485, y = 6562, z = 16}
local EVENT_DURATION = 300 -- 5 minutes in seconds
local JOIN_DURATION = 60 -- 1 minute in seconds
local eventActive = false
local players = {}

local function LastManStandingOnGossipHello(event, player, object)
    if not eventActive then
        player:GossipMenuAddItem(0, "Join the Last Man Standing event", 0, 1)
        player:GossipSendMenu(1, object)
    else
        player:SendBroadcastMessage("The event is currently in progress. Please wait for the next round.")
    end
end

local function LastManStandingOnGossipSelect(event, player, object, sender, intid, code, menuid)
    if intid == 1 then
        table.insert(players, {player = player, originalLocation = player:GetLocation()})
        player:Teleport(ARENA_MAP_ID, ARENA_LOCATION.x, ARENA_LOCATION.y, ARENA_LOCATION.z, player:GetO())
        player:SendBroadcastMessage("You have joined the Last Man Standing event!")
        player:GossipComplete()
    end
end

RegisterCreatureGossipEvent(EVENT_NPC_ENTRY, 1, LastManStandingOnGossipHello)
RegisterCreatureGossipEvent(EVENT_NPC_ENTRY, 2, LastManStandingOnGossipSelect)

local function LastManStandingEnd()
    local lastPlayer = nil
    for _, data in ipairs(players) do
        local player = data.player
        if player:IsAlive() and player:GetMapId() == ARENA_MAP_ID then
            lastPlayer = player
            player:Teleport(unpack(data.originalLocation))
        end
    end

    if lastPlayer then
        lastPlayer:SendBroadcastMessage("Congratulations! You are the Last Man Standing!")
    end

    players = {}
    eventActive = false
end

local function LastManStandingBegin()
    eventActive = true
    CreateLuaEvent(LastManStandingEnd, EVENT_DURATION * 1000, 1)
end

local function LastManStandingSchedule(eventId, delay, repeats)
    if not eventActive then
        LastManStandingBegin()
    end
    CreateLuaEvent(LastManStandingSchedule, JOIN_DURATION * 1000, 1)
end

CreateLuaEvent(LastManStandingSchedule, JOIN_DURATION * 1000, 1)
 
Back
Top