[INC] CromChat - a better ColorChat!
Публикувано на: 28 Яну 2018, 02:36
Успях да го направя , прилагам снимка на ефекта .
Код за потвърждение: Избери целия код
/* Formatright © 2009, ConnorMcLeod
Info Rank 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.
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 Info Rank; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/* Configuration */
#define ENABLED_BY_DEFAULT 1
#define NVAULT_MAX_DAYS_SAVE 30
/* DON'T CHANGE ANYTHING BELOW */
#include <amxmodx>
#include <csx>
#include <nvault>
#include <chatcolor>
#define VERSION "0.4.1"
#define MAX_PLAYERS 32
#define A_DAY_IN_SECONDS 86400 // 60 * 60 * 24
new g_iOldRank[MAX_PLAYERS+1]
new playerbitStatsEnabled
#define EnablePlayerStats(%0) playerbitStatsEnabled |= 1<<(%0&31)
#define DisablePlayerStats(%0) playerbitStatsEnabled &= ~(1<<(%0&31))
#define ArePlayerStatsEnabled(%0) playerbitStatsEnabled & 1<<(%0&31)
#define TogglePlayerStats(%0) playerbitStatsEnabled ^= 1<<(%0&31)
new playerbitDisplayStats
//#define DisplayStatsOnNextResetHUDEvent(%0) playerbitDisplayStats |= 1<<(%0&31)
#define DontDisplayStatsOnNextResetHUDEvent(%0) playerbitDisplayStats &= ~(1<<(%0&31))
#define ShouldDisplayStatsOnNextResetHUDEvent(%0) playerbitDisplayStats & 1<<(%0&31)
new g_iEnabledByDefault = ENABLED_BY_DEFAULT
new g_iNvault
new g_pCvarInfoRank
public plugin_init()
{
register_plugin("Info Rank", VERSION, "ConnorMcLeod")
register_dictionary("inforank.txt")
g_pCvarInfoRank = register_cvar("amx_inforank", "1")
register_event("HLTV", "Event_HLTV_New_Round", "a", "1=0", "2=0")
register_event("ResetHUD", "Event_ResetHUD", "b")
register_clcmd("say /inforank", "ClientCommand_InfoRank", 0, "- enable/disable info rank messages")
register_clcmd("say_team /inforank", "ClientCommand_InfoRank", 0, "- enable/disable info rank messages")
g_iNvault = nvault_open("inforank")
nvault_prune(g_iNvault, 0, get_systime(-(A_DAY_IN_SECONDS * NVAULT_MAX_DAYS_SAVE)) )
}
public client_authorized(id)
{
new szSteamId[32]
get_user_authid(id, szSteamId, charsmax(szSteamId))
if( szSteamId[0] == 'S' ) // skip bots
{
new mOsef[8]
g_iOldRank[id] = get_user_stats(id, mOsef, mOsef)
new szPlayerSettings[2]
nvault_get(g_iNvault,szSteamId, szPlayerSettings, charsmax(szPlayerSettings))
switch( szPlayerSettings[0] )
{
case '0':
{
DisablePlayerStats(id)
}
case '1':
{
EnablePlayerStats(id)
}
default:
{
if( g_iEnabledByDefault )
{
EnablePlayerStats(id)
}
else
{
DisablePlayerStats(id)
}
}
}
}
else
{
DisablePlayerStats(id)
}
}
public plugin_end()
{
nvault_close(g_iNvault)
}
public Event_HLTV_New_Round()
{
if( get_pcvar_num(g_pCvarInfoRank) )
{
playerbitDisplayStats = 0xFFFFFFFF // set everyone enabled
}
}
public Event_ResetHUD(id)
{
if( ShouldDisplayStatsOnNextResetHUDEvent(id) && ArePlayerStatsEnabled(id) )
{
DontDisplayStatsOnNextResetHUDEvent(id)
set_task(0.3, "DisplayStats", id)
}
}
public DisplayStats(id)
{
if( is_user_connected(id) )
{
new mOsef[8], iRank, iOldRank
iRank = get_user_stats(id, mOsef, mOsef)
iOldRank = g_iOldRank[id]
if( !iOldRank ) // First Spawn
{
iOldRank = iRank
}
g_iOldRank[id] = iRank
new iDiff = iOldRank - iRank
if(iDiff > 0)
{
client_print_color(id, id, "^4%L", id, "IR_GOOD", iDiff)
}
else if(iDiff < 0)
{
client_print_color(id, Red, "^3%L", id, "IR_BAD", iDiff)
}
client_print_color(id, Grey, "^3%L", id, "IR_RANK", iRank, get_statsnum())
}
}
public ClientCommand_InfoRank(id)
{
if( get_pcvar_num(g_pCvarInfoRank) )
{
new szSteamId[32]
get_user_authid(id, szSteamId, charsmax(szSteamId))
TogglePlayerStats(id)
if( ArePlayerStatsEnabled(id) )
{
nvault_set(g_iNvault, szSteamId, "1")
client_print_color(id, id, "^4%L", id, "IR_ENABLE")
}
else
{
nvault_set(g_iNvault, szSteamId, "0")
client_print_color(id, Red, "^3%L", id, "IR_DISABLE")
}
}
return PLUGIN_CONTINUE
}
Код за потвърждение: Избери целия код
CC_SendMessage(id, id, "^4%L", id, "IR_GOOD", iDiff)
CC_SendMessage(id, Red, "^3%L", id, "IR_BAD", iDiff)
CC_SendMessage(id, Grey, "^3%L", id, "IR_RANK", iRank, get_statsnum())
CC_SendMessage(id, id, "^4%L", id, "IR_ENABLE")
CC_SendMessage(id, Red, "^3%L", id, "IR_DISABLE")
Код за потвърждение: Избери целия код
CC_SendMessage(id, "%L", id, "IR_GOOD", iDiff)
CC_SendMessage(id, "%L", id, "IR_BAD", iDiff)
CC_SendMessage(id, "%L", id, "IR_RANK", iRank, get_statsnum())
CC_SendMessage(id, "%L", id, "IR_ENABLE")
CC_SendMessage(id, "%L", id, "IR_DISABLE")