From a8964e3cb028ff8b2e06c1caadc3bb3bdf691d3d Mon Sep 17 00:00:00 2001 From: Dogan Date: Wed, 10 Jul 2019 22:55:35 +0200 Subject: [PATCH] ConnectAnnounceNewPlayers: improve personal message + block other chat messages for 10 seconds to make it possible for the newcomer to see the actual message --- .../scripting/ConnectAnnounceNewPlayers.sp | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/ConnectAnnounce/scripting/ConnectAnnounceNewPlayers.sp b/ConnectAnnounce/scripting/ConnectAnnounceNewPlayers.sp index 548bae6a..04214925 100644 --- a/ConnectAnnounce/scripting/ConnectAnnounceNewPlayers.sp +++ b/ConnectAnnounce/scripting/ConnectAnnounceNewPlayers.sp @@ -2,8 +2,10 @@ #include #include +#include bool g_bNewPlayer[MAXPLAYERS + 1] = { false, ... }; +bool g_bNewPlayerChatBlock[MAXPLAYERS + 1] = { false, ...}; ConVar g_cvServerType; char g_cServerMessage[128]; @@ -15,7 +17,7 @@ public Plugin myinfo = name = "ConnectAnnounceNewPlayers", author = "Dogan", description = "Connect Announcer for new Players", - version = "1.2.0", + version = "1.3.0", url = "" } @@ -161,7 +163,9 @@ public void SQL_OnQueryCompleted(Database db, DBResultSet results, const char[] } g_bNewPlayer[client] = true; + g_bNewPlayerChatBlock[client] = true; NewPlayerMessage(client); + CreateTimer(10.0, BlockChat, client, TIMER_FLAG_NO_MAPCHANGE); char sQuery[512]; Format(sQuery, sizeof(sQuery), "INSERT INTO connections (auth) VALUES ('%s')" , sAuthID); @@ -170,21 +174,40 @@ public void SQL_OnQueryCompleted(Database db, DBResultSet results, const char[] public Action NewPlayerMessage(int client) { - char sName[128]; - GetClientName(client, sName, sizeof(sName)); - - CPrintToChatAll("{cyan}Player {blueviolet}%s {cyan}has just connected to an UNLOZE Server for the first time! Welcome!", sName); + CPrintToChatAll("{cyan}Player {lightgreen}%N {cyan}has just connected to an UNLOZE Server for the first time! Welcome!", client); if(g_cvServerType.IntValue >= 1 && g_cvServerType.IntValue <= 3) { - CPrintToChat(client, "{cyan}Hi %s. Welcome to the {blueviolet}Unloze %s Server{cyan}! We hope you enjoy your stay here and add our server to your favorites. Make sure to check out our website at {blueviolet}www.unloze.com{cyan}.", sName, g_cServerMessage); + CPrintToChat(client, "{purple}****************************************************"); + CPrintToChat(client, "{purple}****************************************************"); + CPrintToChat(client, "{cyan}Hi {lightgreen}%N{cyan}. Welcome to the {blueviolet}Unloze %s Server{cyan}! We hope you enjoy your stay here and add our server to your favorites. Make sure to check out our website at {blueviolet}www.unloze.com{cyan}.", client, g_cServerMessage); + CPrintToChat(client, "{purple}****************************************************"); + CPrintToChat(client, "{purple}****************************************************"); } else { - CPrintToChat(client, "{cyan}Hi %s. Welcome to this {blueviolet}Unloze Server{cyan}! We hope you enjoy your stay here and add our server to your favorites. Make sure to check out our website at {blueviolet}www.unloze.com{cyan}.", sName); + CPrintToChat(client, "{purple}****************************************************"); + CPrintToChat(client, "{purple}****************************************************"); + CPrintToChat(client, "{cyan}Hi {lightgreen}%N. Welcome to this {blueviolet}Unloze Server{cyan}! We hope you enjoy your stay here and add our server to your favorites. Make sure to check out our website at {blueviolet}www.unloze.com{cyan}.", client); + CPrintToChat(client, "{purple}****************************************************"); + CPrintToChat(client, "{purple}****************************************************"); } } public void OnClientDisconnect(int client) { g_bNewPlayer[client] = false; + g_bNewPlayerChatBlock[client] = false; +} + +public Action BlockChat(Handle timer, int client) +{ + g_bNewPlayerChatBlock[client] = false; +} + +public Action CCC_OnChatMessage(int client, int author, const char[] message) +{ + if(g_bNewPlayerChatBlock[client]) + return Plugin_Handled; + + return Plugin_Continue; } \ No newline at end of file