-
Notifications
You must be signed in to change notification settings - Fork 0
/
xtense_welcome.sp
76 lines (61 loc) · 2.83 KB
/
xtense_welcome.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
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#define COLOR_PREFIX "\x01 \x0B[\x01Xtense\x0B]\x01"
#define COLOR_NORMAL "\x01"
#define COLOR_HIGHLIGHT "\x0B"
// Global arrays to track client cooldowns for connect and disconnect messages
bool gClientCooldownC[MAXPLAYERS+1] = false;
bool gClientCooldownD[MAXPLAYERS+1] = false;
// Global timer arrays to track client cooldown timers for connect and disconnect messages
Handle gTimer_CooldownC[MAXPLAYERS+1];
Handle gTimer_CooldownD[MAXPLAYERS+1];
public Plugin myinfo = {
name = "Xtense :: Welcome",
author = "dnhen",
description = "Display SteamID for joining and leaving players",
version = "0.4",
url = "http://www.sourcemod.net/"
};
public void OnClientPostAdminCheck(int client)
{
char cName[64], steamID[128];
if(GetClientName(client, cName, sizeof(cName)) && GetClientAuthId(client, AuthId_Steam2, steamID, sizeof(steamID)) && !gClientCooldownC[client]){ // If we can get the clients username and steamID and cooldown isnt on
PrintToChatAll("%s %s[%s%s%s] %s%s %sis joining the game.", COLOR_PREFIX, COLOR_HIGHLIGHT, COLOR_NORMAL, steamID, COLOR_HIGHLIGHT, COLOR_HIGHLIGHT, cName, COLOR_NORMAL);
PrintToServer("[%s] %s is joining the game.", steamID, cName);
// Enable the cooldown for connect messages, and start the timer to disable the cooldown
gClientCooldownC[client] = true;
gTimer_CooldownC[client] = CreateTimer(30.0, Timer_ClientCooldownC, client);
}
}
public void OnClientDisconnect(int client)
{
char cName[64], steamID[128];
if(GetClientName(client, cName, sizeof(cName)) && GetClientAuthId(client, AuthId_Steam2, steamID, sizeof(steamID)) && !gClientCooldownD[client]){ // If we can get the clients username and steamID and cooldown isnt on
PrintToChatAll("%s %s[%s%s%s] %s%s %s has left the game.", COLOR_PREFIX, COLOR_HIGHLIGHT, COLOR_NORMAL, steamID, COLOR_HIGHLIGHT, COLOR_HIGHLIGHT, cName, COLOR_NORMAL);
PrintToServer("[%s] %s has left the game.", steamID, cName);
// Enable the cooldown for disconnect messages, and start the timer to disable the cooldown
gClientCooldownD[client] = true;
gTimer_CooldownD[client] = CreateTimer(30.0, Timer_ClientCooldownD, client);
}
}
// --------------------
// Connect and disconnect cooldown timers
// --------------------
public Action Timer_ClientCooldownC(Handle timer, int client){
gClientCooldownC[client] = false;
}
public Action Timer_ClientCooldownD(Handle timer, int client){
gClientCooldownD[client] = false;
}
// --------------------
// Reset all timers
// --------------------
public void OnMapEnd(){
for(int i = 1; i <= MaxClients; i++){
gClientCooldownC[i] = false;
gClientCooldownD[i] = false;
KillTimer(gTimer_CooldownC[i]);
KillTimer(gTimer_CooldownD[i]);
}
}