This repository has been archived by the owner on Jul 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcountrynick.sp
145 lines (117 loc) · 4.1 KB
/
countrynick.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
SourceMod Country Nick Plugin
Add country of the player near his nick
Country Nick Plugin (C)2009-2010 A-L. All rights reserved.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
$Id: countrynick.sp 29 2009-02-23 23:45:22Z aen0 $
*/
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <geoip>
#define VERSION "1.0.0"
new Handle:hTagSize, iTagSize,
Handle:hMsg, bool:bMsg;
public Plugin:myinfo =
{
name = "[INS] Country Nick Plugin",
author = "Neko- (Antoine LIBERT aka AeN0, Grey83)",
description = "Add country of the player near his nick",
version = VERSION
};
public OnPluginStart()
{
LoadTranslations("countrynick.phrases");
CreateConVar("countrynick_version", VERSION, "Country Nick Version", FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED|FCVAR_SPONLY|FCVAR_DONTRECORD);
hTagSize = CreateConVar("sm_countrynick_tagsize", "3", "Size of the country tag (2 or 3 letters)", FCVAR_NONE, true, 2.0, true, 3.0);
hMsg = CreateConVar("sm_countrynick_msg", "0", "1/0 - Switch On/Off announcement connecting of a players (and error logging)", FCVAR_NONE, true, 0.0, true, 1.0);
iTagSize = GetConVarInt(hTagSize);
bMsg = GetConVarBool(hMsg);
HookConVarChange(hTagSize, OnConVarChange);
HookConVarChange(hMsg, OnConVarChange);
HookEvent("player_changename", Event_PlayerChangename, EventHookMode_Pre);
AutoExecConfig(true, "countrynick");
}
public OnConVarChange(Handle:hCVar, const String:oldValue[], const String:newValue[])
{
if (hCVar == hTagSize) iTagSize = StringToInt(newValue);
else if (hCVar == hMsg) bMsg = bool:StringToInt(newValue);
}
public OnClientPostAdminCheck(client)
{
decl String:ip[16];
decl String:country[46];
decl String:sName[65];
if(1 <= client <= MaxClients && !IsFakeClient(client))
{
GetClientName(client, sName, sizeof(sName));
SetNewName(client, sName);
if(bMsg)
{
GetClientIP(client, ip, 16);
if(GeoipCountry(ip, country, 45))
PrintToChatAll("\x03%T", "Announcer country found", LANG_SERVER, client, country);
else
{
PrintToChatAll("\x03%T", "Announcer country not found", LANG_SERVER, client);
LogError("[Country Nick] Warning : %N uses %s that is not listed in GEOIP database", client, ip);
}
}
}
}
public Action:Event_PlayerChangename(Handle:event, const String:name[], bool:dontBroadcast)
{
decl String:sName[65];
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if(!IsFakeClient(client))
{
GetEventString(event, "newname", sName, 65);
SetNewName(client, sName);
return Plugin_Handled; // avoid printing the change to the chat
}
return Plugin_Continue;
}
SetNewName(client, String:sName[])
{
decl String:ip[16];
decl String:code[3];
new bool:found;
decl String:flag[6];
GetClientIP(client, ip, 16);
new AdminId:admin = GetUserAdmin(client);
if(iTagSize == 2)
{
found = GeoipCode2(ip, code);
if(found) Format(flag, 5, "[%2s]", code);
else Format(flag, 5, "[--]");
if((admin != INVALID_ADMIN_ID) && (GetAdminFlag(admin, Admin_Root, Access_Effective)))
{
Format(flag, 5, "[IQ]");
}
}
else
{
found = GeoipCode3(ip, code);
if(found) Format(flag, 6, "[%3s]", code);
else Format(flag, 6, "[-?-]");
if((admin != INVALID_ADMIN_ID) && (GetAdminFlag(admin, Admin_Root, Access_Effective)))
{
Format(flag, 6, "[IRQ]");
}
}
if(!(StrContains(sName, flag, false) == 0))
{
Format(sName, 69, "%s %s", flag, sName);
//SetClientInfo(client, "name", sName);
SetClientName(client, sName);
}
}