-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplayerAnnounce.lua
More file actions
62 lines (53 loc) · 1.63 KB
/
playerAnnounce.lua
File metadata and controls
62 lines (53 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
local MODULE_NAME = "Eluna playerAnnounce"
local MODULE_VERSION = '1.0.1'
local MODULE_AUTHOR = "Mpromptu Gaming"
print("["..MODULE_NAME.."]: Loaded, Version "..MODULE_VERSION.." Active")
local function getTeamColor(player)
if player:GetTeam() == 0 then
return "CFF00B4FF"
else
return "CFFFF9900"
end
end
local function getTeamName(player)
if player:GetTeam() == 0 then
return "Alliance"
else
return "Horde"
end
end
local function announce(player, action)
msg = getTeamName(player).." player "..player:GetName().." ("..player:GetAccountName()..") has "..action.."."
print("["..MODULE_NAME.."]: "..msg)
SendWorldMessage("|"..getTeamColor(player)..msg.."|r")
end
local function listPlayers(player)
player:SendBroadcastMessage("|CFF99E472Currently online:|r")
allPlayers = GetPlayersInWorld(2)
for k, v in pairs(allPlayers) do
player:SendBroadcastMessage("|"..
getTeamColor(v)..
v:GetName()..
" ("..v:GetAccountName()..") "..
"[Level "..v:GetLevel()..
" "..v:GetClassAsString().." - "..
getTeamName(v).." - "..
v:GetMap():GetName().."]|r")
end
end
local function onChatMessage(event, player, msg, _, lang)
if (msg:find('#who') == 1) then
listPlayers(player)
return false
end
end
local function onLogin(event, player)
announce(player, "logged in")
listPlayers(player)
end
local function onLogout(event, player)
announce(player, "logged out")
end
RegisterPlayerEvent(18, onChatMessage)
RegisterPlayerEvent(3, onLogin)
RegisterPlayerEvent(4, onLogout)