PDA

View Full Version : how to add colours without colorchat.inc


human_Torch
06-12-2010, 11:39
Well i want to add colour to this plugin but how :(

/* AMX Mod script
*
* (c) 2002-2003, DynAstY
* This file is provided as is (no warranties).
*
* Players with immunity won't be checked
*/

#include <amxmodx>

new HIGHPING_MAX = 200 // set maximal acceptable ping
new HIGHPING_TIME = 15 // set in seconds frequency of ping checking
new HIGHPING_TESTS = 8 // minimal number of checks before doing anything

new iNumTests[33]

public plugin_init() {
register_plugin("High Ping Kicker","1.2.0","DynAstY")
if (HIGHPING_TIME < 15) HIGHPING_TIME = 15
if (HIGHPING_TESTS < 4) HIGHPING_TESTS = 4
return PLUGIN_CONTINUE
}

public client_disconnect(id) {
remove_task(id)
return PLUGIN_CONTINUE
}

public client_putinserver(id) {
iNumTests[id] = 0
if (!is_user_bot(id)) {
new param[1]
param[0] = id
set_task(30.0, "showWarn", id, param, 1)
}
return PLUGIN_CONTINUE
}

kickPlayer(id) {
new name[32]
get_user_name(id, name, 31)
new uID = get_user_userid(id)
server_cmd("banid 1 #%d", uID)
client_cmd(id, "echo ^"[HPK] Sorry but you have high ping, try later...^"; disconnect")
client_print(0, print_chat, "[HPK] %s was disconnected due to high ping!", name)
return PLUGIN_CONTINUE
}

public checkPing(param[]) {
new id = param[0]
if ((get_user_flags(id) & ADMIN_IMMUNITY) || (get_user_flags(id) & ADMIN_RESERVATION)) {
remove_task(id)
client_print(id, print_chat, "[HPK] Ping checking disabled due to immunity...")
return PLUGIN_CONTINUE
}
new p, l
get_user_ping(id, p, l)
if (p > HIGHPING_MAX)
++iNumTests[id]
else
if (iNumTests[id] > 0) --iNumTests[id]
if (iNumTests[id] > HIGHPING_TESTS)
kickPlayer(id)
return PLUGIN_CONTINUE
}

public showWarn(param[]) {
client_print(param[0], print_chat, "[HPK] Players with ping higher than %dms will be kicked!", HIGHPING_MAX)
set_task(float(HIGHPING_TIME), "checkPing", param[0], param, 1, "b")
return PLUGIN_CONTINUE
}

replace this [HPK] Players with ping higher than %dms will be kicked! with this but with colurs
[ Rc DeathRun ] <-red colour Players with ping higher than %dms will be kicked!<-green colour

RedRobster
06-12-2010, 11:48
/* AMX Mod script
*
* (c) 2002-2003, DynAstY
* This file is provided as is (no warranties).
*
* Players with immunity won't be checked
*/

#include <amxmodx>

new HIGHPING_MAX = 200 // set maximal acceptable ping
new HIGHPING_TIME = 15 // set in seconds frequency of ping checking
new HIGHPING_TESTS = 8 // minimal number of checks before doing anything

new iNumTests[33]

new g_iMsgSayText //For ColorChat

public plugin_init() {
register_plugin("High Ping Kicker","1.2.0","DynAstY")
if (HIGHPING_TIME < 15) HIGHPING_TIME = 15
if (HIGHPING_TESTS < 4) HIGHPING_TESTS = 4
return PLUGIN_CONTINUE
}

public client_disconnect(id) {
remove_task(id)
return PLUGIN_CONTINUE
}

public client_putinserver(id) {
iNumTests[id] = 0
if (!is_user_bot(id)) {
new param[1]
param[0] = id
set_task(30.0, "showWarn", id, param, 1)
}
return PLUGIN_CONTINUE
}

kickPlayer(id) {
new name[32]
get_user_name(id, name, 31)
new uID = get_user_userid(id)
server_cmd("banid 1 #%d", uID)
client_cmd(id, "echo ^"[HPK] Sorry but you have high ping, try later...^"; disconnect")
ChatColor(0, "^3[Rc DeathRun] ^4%s was disconnected due to high ping!", name)
return PLUGIN_CONTINUE
}

public checkPing(param[]) {
new id = param[0]
if ((get_user_flags(id) & ADMIN_IMMUNITY) || (get_user_flags(id) & ADMIN_RESERVATION)) {
remove_task(id)
ChatColor(id, "^3[Rc DeathRun] ^4Ping checking disabled due to immunity...")
return PLUGIN_CONTINUE
}
new p, l
get_user_ping(id, p, l)
if (p > HIGHPING_MAX)
++iNumTests[id]
else
if (iNumTests[id] > 0) --iNumTests[id]
if (iNumTests[id] > HIGHPING_TESTS)
kickPlayer(id)
return PLUGIN_CONTINUE
}

public showWarn(param[]) {
ChatColor(param[0], "^3[Rc DeathRun] ^4Players with ping higher than %dms will be kicked!", HIGHPING_MAX)
set_task(float(HIGHPING_TIME), "checkPing", param[0], param, 1, "b")
return PLUGIN_CONTINUE
}

stock ChatColor(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)

replace_all(msg, 190, "!g", "^4") // Green Color
replace_all(msg, 190, "!y", "^1") // Default Color
replace_all(msg, 190, "!team", "^3") // Team Color


if (id) players[0] = id; else get_players(players, count, "ch")
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, g_iMsgSayText, _, players[i])
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}
I don't know how to make it only red without using the ColorChat plugin. So instead, I just made it so that the front bit will be the team color of the players, and the last part will be green. :)

human_Torch
06-12-2010, 11:57
ok,tnx..

so you add this at the bottom

stock ChatColor(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)

replace_all(msg, 190, "!g", "^4") // Green Color
replace_all(msg, 190, "!y", "^1") // Default Color
replace_all(msg, 190, "!team", "^3") // Team Color


if (id) players[0] = id; else get_players(players, count, "ch")
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, g_iMsgSayText, _, players[i])
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}

and change this line

ChatColor(param[0], "^3[Rc DeathRun] ^4Players with ping higher than %dms will be kicked!", HIGHPING_MAX)

and thats it :D

human_Torch
06-12-2010, 12:08
plugin that you gave me have run time errors :(

AfteR.
06-12-2010, 12:34
stock ColorChat(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[ 191 ]
vformat(msg, 190, input, 3)

replace_all(msg, 190, "^x01" , "^1")
replace_all(msg, 190, "^x03" , "^3")
replace_all(msg, 190, "^x04" , "^4")

if (id) players[0] = id; else get_players(players , count , "ch")
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE , get_user_msgid("SayText"), _, players[i])
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}

human_Torch
06-12-2010, 12:54
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

aaa.sma(48) : error 017: undefined symbol "ChatColor"
aaa.sma(56) : error 017: undefined symbol "ChatColor"
aaa.sma(71) : error 017: undefined symbol "ChatColor"
aaa.sma(72) : warning 217: loose indentation
aaa.sma(99) : warning 203: symbol is never used: "g_iMsgSayText"

3 Errors.
Could not locate output file aaa.amx (compile failed).


ERROR: Your plugin failed to compile, see above.

RedRobster
06-12-2010, 14:06
It compiles for me. What are you using to compile it?

This is the exact same thing that I posted up there^

human_Torch
06-12-2010, 22:54
It compiles for me. What are you using to compile it?

This is the exact same thing that I posted up there^
http://webcomp.ak-team.com/index.php this website