[Eluna] Automatic Bounty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
-- Script Name : Auto Bounty On Login | |
-- Made By : PrivateDonut | |
-- Idea By : Dandi | |
]] -- | |
-- General Settings | |
local autoBounty = true -- Enable/Disable entire script | |
local setFFA = true -- Enable/Disable FFA on bounty place | |
local rngMinNumber = 1 -- Minimum random number | |
local rngMaxNumber = 25 -- Maximum random number | |
local rngMatch = 1 -- Random number to match | |
local itemOrgold = "item" -- Set to "gold" or "item" to determine if the bounty is placed in gold or an item | |
local goldBounty = 100 -- Gold bounty amount | |
local itemBounty = 5 -- Item bounty amount | |
local itemID = 20880 -- Item ID used to place bounties | |
-- Bounty Checks | |
local isFirstLogin = true -- Check if player has first login flag | |
local isGM = false -- Check if player is a GM | |
-- Do not edit below this line unless you know what you're doing. | |
if autoBounty == true then | |
bounty = {} | |
local function autoBounty(event, player) | |
-- If player has First Login flag return false. | |
if isFirstLogin == true and player:HasAtLoginFlag(32) then | |
return | |
end | |
if isGM == true and player:GetGMRank() > 0 then | |
return | |
end | |
local rng = math.random(rngMinNumber, rngMaxNumber) | |
if rng == rngMatch then | |
if itemOrgold == "gold" then | |
SendWorldMessage("|cFFFF0000[Auto Bounty]|r |cFF00FF00" .. player:GetName() .. "|r has randomly been selected and placed on |cFF00FF00" .. goldBounty .. "|r gold bounty!") | |
-- Set players flag to FFA if selected for bounty | |
if setFFA == true then | |
player:SetFFA(true) | |
end | |
-- store information to check later if player has bounty | |
bounty[player:GetGUIDLow()] = goldBounty | |
bounty[player:GetName()] = player:GetName() -- store player name | |
elseif itemOrgold == "item" then | |
SendWorldMessage("|cFFFF0000[Auto Bounty]|r |cFF00FF00" .. player:GetName() .."|r has randomly been selected and placed on a |cFF00FF00" .. itemBounty .. "|r " .. GetItemLink(itemID) .. " bounty!") | |
-- Set players flag to FFA if selected for bounty | |
if setFFA == true then | |
player:SetFFA(true) | |
end | |
-- store information to check later if player has bounty | |
bounty[player:GetGUIDLow()] = itemBounty | |
bounty[player:GetName()] = player:GetName() -- store player name | |
end | |
return | |
end | |
end | |
local function onPvPKill(event, killer, killed) | |
-- reward gold upon player death | |
if itemOrgold == "gold" then | |
if bounty[killed:GetGUIDLow()] then | |
local gold = bounty[killed:GetGUIDLow()] * 10000 | |
killer:ModifyMoney(gold) | |
SendWorldMessage("|cFFFF0000[Auto Bounty]|r |cFF00FF00" .. killer:GetName() .. "|r has claimed the |cFF00FF00" .. bounty[killed:GetGUIDLow()] .. "|r gold bounty on |cFF00FF00" .. killed:GetName() .. "|r!") | |
bounty[killed:GetGUIDLow()] = nil | |
bounty[killed:GetName()] = nil | |
end | |
end | |
-- reward item upon player death | |
if itemOrgold == "item" then | |
if bounty[killed:GetGUIDLow()] then | |
-- reward item and item count to killer | |
killer:AddItem(itemID, bounty[killed:GetGUIDLow()]) | |
SendWorldMessage("|cFFFF0000[Auto Bounty]|r |cFF00FF00" .. killer:GetName() .. "|r has claimed the |cFF00FF00" .. bounty[killed:GetGUIDLow()] .. "|r " .. GetItemLink(itemID) .. " bounty on |cFF00FF00" .. killed:GetName() .. "|r!") | |
bounty[killed:GetGUIDLow()] = nil | |
bounty[killed:GetName()] = nil | |
end | |
end | |
end | |
local function OnPlayerLogout(event, player) | |
-- remove bounty on logout. | |
-- Remove all bounties on logout, might update in the future to include a timer. | |
if bounty[player:GetGUIDLow()] then | |
SendWorldMessage("|cFFFF0000[Auto Bounty]|r |cFF00FF00" .. player:GetName() .."|r has logged out and the bounty has been removed!") | |
bounty[player:GetGUIDLow()] = nil | |
bounty[player:GetName()] = nil | |
end | |
end | |
RegisterPlayerEvent(3, autoBounty) | |
RegisterPlayerEvent(6, onPvPKill) | |
RegisterPlayerEvent(4, OnPlayerLogout) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment