• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

PvP Token System

Salja

Respected Member
Thanks to Rochet to CleanUp my Script =)

PvP Token System wehn kill a other Player give a Item or Gold or both‏, when the bags are full send a mail with the item.

Tested on last MaNGOSOne TBC with Eluna



Settings
Code:
-- Settings
local ItemOrGold = 0                     -- 0 = Gold and Item, 1 = Only Item, 2 = Only Gold
local WorldAnnounce = true               -- Sends a World Announce false = Off, true = On
local GoldCount = 10000                  -- Reward in copper
local ItemEntry = 20558                  -- Warsong Gulch Mark of Honor
local ItemCount = 1                      -- Count of the Item

Version 1
Code:
-- -- -- -- -- -- -- -- -- -- -- -- --
-- -- PvP Token System by Salja. -- --
-- -- -- -- -- -- -- -- -- -- -- -- --

-- Settings
local ItemOrGold = 0                     -- 0 = Gold and Item, 1 = Only Item, 2 = Only Gold
local WorldAnnounce = true               -- Sends a World Announce false = Off, true = On
local GoldCount = 10000                  -- Reward in copper
local ItemEntry = 20558                  -- Warsong Gulch Mark of Honor
local ItemCount = 1                      -- Count of the Item
local ItemName = GetItemLink(ItemEntry)


local function PvPTokenSystem(event, killer, killed)
    local receiver = killer:GetGUIDLow()

    if (WorldAnnounce == 1) then
        SendWorldMessage("[PVP] |Hplayer:"..killer:GetName().."|h["..killer:GetName().."]|h killed |Hplayer:"..killed:GetName().."|h["..killed:GetName().."]|h")
    end

    if (ItemOrGold ~= 2) then
        if (killer:AddItem(ItemEntry, ItemCount)) then
            if (ItemCount == 1) then
                killer:SendBroadcastMessage("|CFF20C000 You get: "..ItemName.."|CFF20C000.|r")
            else
                killer:SendBroadcastMessage("|CFF20C000 You get: "..ItemName.."|CFF20C000 x"..ItemCount..".|r")
            end
        else
            killer:SendBroadcastMessage("|cffff0000 Your bags are full, we will send it by mail.|r")
            SendMail("PvP Token System", "Your Bags are full we send via Mail", receiver, nil, 41, nil, ItemEntry, ItemCount)
        end
    end

    if (ItemOrGold ~= 1) then
        killer:ModifyMoney(GoldCount)
        killer:SendBroadcastMessage("|CFF20C000 You get: "..GoldCount.."|CFF20C000 Copper.|r")
    end
end

RegisterPlayerEvent(6, PvPTokenSystem)

Version 2 (with cooldown) thanks to Foereaper for the function

New Setting option
Code:
local KillCooldown = 180                 -- Wehn you kill the same player in this time you become not gold or item (set to 0 for disable)
Code:
-- -- -- -- -- -- -- -- -- -- -- -- --
-- -- PvP Token System by Salja. -- --
-- -- -- -- -- -- -- -- -- -- -- -- --

-- Settings
local ItemOrGold = 0                     -- 0 = Gold and Item, 1 = Only Item, 2 = Only Gold
local WorldAnnounce = true               -- Sends a World Announce false = Off, true = On
local GoldCount = 10000                  -- Reward in copper
local ItemEntry = 20558                  -- Warsong Gulch Mark of Honor
local ItemCount = 1                      -- Count of the Item
local ItemName = GetItemLink(ItemEntry)
local KillCooldown = 180                 -- Wehn you kill the same player in this time you become not gold or item (set to 0 for disable)


local function PvPTokenSystem(event, killer, killed)
    local receiver = killer:GetGUIDLow()

    if (WorldAnnounce == 1) then
        SendWorldMessage("[PVP] |Hplayer:"..killer:GetName().."|h["..killer:GetName().."]|h killed |Hplayer:"..killed:GetName().."|h["..killed:GetName().."]|h")
    end

    if (ItemOrGold ~= 2) then
	if killed:GetLuaCooldown() == 0 then
            if (killer:AddItem(ItemEntry, ItemCount)) then
                if (ItemCount == 1) then
                    killer:SendBroadcastMessage("|CFF20C000 You get: "..ItemName.."|CFF20C000.|r")
                    killed:SetLuaCooldown(KillCooldown)
                else
                    killer:SendBroadcastMessage("|CFF20C000 You get: "..ItemName.."|CFF20C000 x"..ItemCount..".|r")
                    killed:SetLuaCooldown(KillCooldown)
                end
            else
                killer:SendBroadcastMessage("|cffff0000 Your bags are full, we will send it by mail.|r")
                SendMail("PvP Token System", "Your Bags are full we send via Mail", receiver, nil, 41, nil, ItemEntry, ItemCount)
                killed:SetLuaCooldown(KillCooldown)
            end
        else
            killer:SendBroadcastMessage(string.format("Set Cooldown for "..killed:GetName()..", to %s seconds for next token kill", math.ceil(killed:GetLuaCooldown())))
            killed:SendBroadcastMessage(string.format("Set YOUR Cooldown, to %s seconds for next token kill", math.ceil(killed:GetLuaCooldown())))
        end
    end

    if (ItemOrGold ~= 1) then
        if killed:GetLuaCooldown() == 0 then
            killer:ModifyMoney(GoldCount)
            killer:SendBroadcastMessage("|CFF20C000 You get: "..GoldCount.."|CFF20C000 Copper.|r")
            killed:SetLuaCooldown(KillCooldown)
        else
            killer:SendBroadcastMessage(string.format("Set Cooldown for "..killed:GetName()..", to %s seconds for next token kill", math.ceil(killed:GetLuaCooldown())))
            killed:SendBroadcastMessage(string.format("Set YOUR Cooldown, to %s seconds for next token kill", math.ceil(killed:GetLuaCooldown())))
        end
    end
end

RegisterPlayerEvent(6, PvPTokenSystem)


local cooldowns = {};
 
function Player:SetLuaCooldown(seconds)
        assert(type(self) == "userdata");
        seconds = assert(tonumber(seconds));
        local guid, source = self:GetGUIDLow(), debug.getinfo(2, 'S').short_src;
 
        if (not cooldowns[guid]) then
                cooldowns[guid] = {};
        end
 
        cooldowns[guid][source] = os.clock() + seconds;
end
 
function Player:GetLuaCooldown()
        assert(type(self) == "userdata");
        local guid, source = self:GetGUIDLow(), debug.getinfo(2, 'S').short_src;
 
        if (not cooldowns[guid]) then
                cooldowns[guid] = {};
        end
 
        local cd = cooldowns[guid][source];
        if (not cd or cd < os.clock()) then
                cooldowns[guid][source] = 0
                return 0;
        else
                return cooldowns[guid][source] - os.clock();
        end
end
 
Last edited:

Mahado

Epic Member
Good job. :) Isn't this exploitable though? ;P Have your pal stand and you keep killing him/her.
 

Tommy

Founder
Good job. :) Isn't this exploitable though? ;P Have your pal stand and you keep killing him/her.

Basically, yeah. Last time I wrote something like this I added a timer so you couldn't do that. Couldn't kill the same person for 5 minutes. Perhaps that should be added to this when someone gets a chance. :p
 

Salja

Respected Member
Updatet Version with Cooldowns, my english is very bad so my texts in the file is not good i hope a ppl here can update for me =)

Big Thanks to "Foereaper" for the cooldown function

Code:
-- -- -- -- -- -- -- -- -- -- -- -- --
-- -- PvP Token System by Salja. -- --
-- -- -- -- -- -- -- -- -- -- -- -- --

-- Settings
local ItemOrGold = 0                     -- 0 = Gold and Item, 1 = Only Item, 2 = Only Gold
local WorldAnnounce = true               -- Sends a World Announce false = Off, true = On
local GoldCount = 10000                  -- Reward in copper
local ItemEntry = 20558                  -- Warsong Gulch Mark of Honor
local ItemCount = 1                      -- Count of the Item
local ItemName = GetItemLink(ItemEntry)
local KillCooldown = 180                 -- Wehn you kill the same player in this time you become not gold or item (set to 0 for disable)


local function PvPTokenSystem(event, killer, killed)
    local receiver = killer:GetGUIDLow()

    if (WorldAnnounce == 1) then
        SendWorldMessage("[PVP] |Hplayer:"..killer:GetName().."|h["..killer:GetName().."]|h killed |Hplayer:"..killed:GetName().."|h["..killed:GetName().."]|h")
    end

    if (ItemOrGold ~= 2) then
        if killed:GetLuaCooldown() == 0 then
            if (killer:AddItem(ItemEntry, ItemCount)) then
                if (ItemCount == 1) then
                    killer:SendBroadcastMessage("|CFF20C000 You get: "..ItemName.."|CFF20C000.|r")
                    killed:SetLuaCooldown(KillCooldown)
                else
                    killer:SendBroadcastMessage("|CFF20C000 You get: "..ItemName.."|CFF20C000 x"..ItemCount..".|r")
                    killed:SetLuaCooldown(KillCooldown)
                end
            else
                killer:SendBroadcastMessage("|cffff0000 Your bags are full, we will send it by mail.|r")
                SendMail("PvP Token System", "Your Bags are full we send via Mail", receiver, nil, 41, nil, ItemEntry, ItemCount)
                killed:SetLuaCooldown(KillCooldown)
            end
        else
            killer:SendBroadcastMessage(string.format("Set Cooldown for "..killed:GetName()..", to %s seconds for next token kill", math.ceil(killed:GetLuaCooldown())))
            killed:SendBroadcastMessage(string.format("Set YOUR Cooldown, to %s seconds for next token kill", math.ceil(killed:GetLuaCooldown())))
        end
    end

    if (ItemOrGold ~= 1) then
        if killed:GetLuaCooldown() == 0 then
            killer:ModifyMoney(GoldCount)
            killer:SendBroadcastMessage("|CFF20C000 You get: "..GoldCount.."|CFF20C000 Copper.|r")
            killed:SetLuaCooldown(KillCooldown)
        else
            killer:SendBroadcastMessage(string.format("Set Cooldown for "..killed:GetName()..", to %s seconds for next token kill", math.ceil(killed:GetLuaCooldown())))
            killed:SendBroadcastMessage(string.format("Set YOUR Cooldown, to %s seconds for next token kill", math.ceil(killed:GetLuaCooldown())))
        end
    end
end

RegisterPlayerEvent(6, PvPTokenSystem)


local cooldowns = {};
 
function Player:SetLuaCooldown(seconds)
        assert(type(self) == "userdata");
        seconds = assert(tonumber(seconds));
        local guid, source = self:GetGUIDLow(), debug.getinfo(2, 'S').short_src;
 
        if (not cooldowns[guid]) then
                cooldowns[guid] = {};
        end
 
        cooldowns[guid][source] = os.clock() + seconds;
end
 
function Player:GetLuaCooldown()
        assert(type(self) == "userdata");
        local guid, source = self:GetGUIDLow(), debug.getinfo(2, 'S').short_src;
 
        if (not cooldowns[guid]) then
                cooldowns[guid] = {};
        end
 
        local cd = cooldowns[guid][source];
        if (not cd or cd < os.clock()) then
                cooldowns[guid][source] = 0
                return 0;
        else
                return cooldowns[guid][source] - os.clock();
        end
end
 
Last edited:
Top