AlexeWarr
Epic Member
Hello, made this script so when ever a player dies it will send a world message <[pvp] "map name" is in fighting!>
But something aint working right, if I kill my self in eastern kingdoms will show that message
but if I kill my self on another map It will show the map name from another index in the table.. idk how tables are working really, im still noobish with them.. if anyone can help me with this..
But something aint working right, if I kill my self in eastern kingdoms will show that message
but if I kill my self on another map It will show the map name from another index in the table.. idk how tables are working really, im still noobish with them.. if anyone can help me with this..
Code:
local delay_message = 60 -- in seconds
local ZA_TM = -- Zone attack triggered maps
{
{0, "Eastern Kingdoms"}, -- map: id, name
{1, "Kalimdor"}, -- map: id, name
{560, "Durnholde"}, -- map: id, name
}
local ZAD_Prefix, ZAD_Subfix = "|cFFffcc00[PVP] ", " is in fighting!|r"
local ZAD_M = {} -- Zone attack delay maps
local function OnTriggerZoneAttack(killer, killed)
-- if suicide then stop doing anything
if (not killer:GetGUIDLow() == killed:GetGUIDLow()) then return end
-- if map is not registered in a table, we create one
if (not ZAD_M[killer:GetMapId()]) then
ZAD_M[killer:GetMapId()] = {}
-- if map is registered already, skip everything
elseif ( ZAD_M[killer:GetMapId()] and (os.time()-ZAD_M[killer:GetMapId()] < delay_message) ) then return end
-- seconds remain untill next message is available = os.time()-ZAD_M[killer:GetMapId()]
-- if just registered now, add delay
ZAD_M[killer:GetMapId()] = nil -- clean before adding current game time
ZAD_M[killer:GetMapId()] = os.time()
-- if delay given after map just registered send zone attack message
for _,v in pairs(ZA_TM) do
if ( string.find(killer:GetMapId(), v[1]) ) then
SendWorldMessage(ZAD_Prefix..v[2]..ZAD_Subfix)
return end
end
end
function OnPVPTrigger(event, killer, killed)
OnTriggerZoneAttack(killer, killed)
end
function OnPVETrigger(event, killer, killed)
OnTriggerZoneAttack(killer, killed)
end
RegisterServerHook(6, OnPVPTrigger)
RegisterServerHook(7, OnPVETrigger)