-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathChatTags2.sp
118 lines (98 loc) · 2.46 KB
/
ChatTags2.sp
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include <sourcemod>
#include <sdktools>
#include <chat-processor>
#include <colorvariables>
#include <admin>
#pragma semicolon 1
#pragma newdecls required
ArrayList list;
bool g_bHasTag[MAXPLAYERS + 1];
char g_sClientTag[MAXPLAYERS + 1][32];
char g_sClientColor[MAXPLAYERS + 1][32];
public Plugin myinfo =
{
name = "",
author = "AfricanSpaceJesus",
description = "",
version = "0.5",
url = "http://steamcommunity.com/id/swagattack835/"
};
public void OnMapStart()
{
if (list == null)
{
list = new ArrayList(256);
}
else
{
list.Clear();
}
loadArrayList();
}
public void OnClientPostAdminCheck(int client)
{
setClientTag(client);
}
public void OnClientConnected(int client)
{
ResetVars(client);
}
public void OnClientDisconnect(int client)
{
ResetVars(client);
}
void ResetVars(int client)
{
g_bHasTag[client] = false;
g_sClientColor[client] = "";
g_sClientTag[client] = "";
}
public Action CP_OnChatMessage(int & author, ArrayList recipients, char[] flagstring, char[] name, char[] message, bool & processcolors, bool & removecolors)
{
if (IsFakeClient(author))
return Plugin_Handled;
if (g_bHasTag[author])
{
Format(name, MAXLENGTH_NAME, "{%s}[%s] %s", g_sClientColor[author], g_sClientTag[author], name);
Format(message, MAXLENGTH_MESSAGE, "{default} %s", message);
processcolors = true;
removecolors = false;
}
return Plugin_Changed;
}
public void setClientTag(int client)
{
char line[256];
char temp[3][128];
int i = 0;
bool found = false;
while (i < list.Length && !found)
{
list.GetString(i, line, sizeof(line));
ExplodeString(line, " ", temp, sizeof(temp), sizeof(temp[]));
int flag = ReadFlagString(temp[0]);
if ((GetUserFlagBits(client) & flag) == flag)
{
strcopy(g_sClientTag[client], sizeof(g_sClientTag[]), temp[1]);
strcopy(g_sClientColor[client], sizeof(g_sClientColor[]), temp[2]);
found = true;
}
else
{
i++;
}
}
}
public void loadArrayList()
{
char path[128];
BuildPath(Path_SM, path, sizeof(path), "/configs/ChatTags.txt");
Handle file = OpenFile(path, "r", false);
char line[128];
int i = 0;
while (!IsEndOfFile(file) && ReadFileLine(file, line, sizeof(line)))
{
list.PushString(line);
i++;
}
}