Cod:
]#include <amxmodx>
#include <amxmisc>
#include <colorchat>
#define LAST_MAPS_SAVE 5
new gSaveFile[64];
new gLastMapName[LAST_MAPS_SAVE][32];
new gLastMapTime[LAST_MAPS_SAVE];
new gNumLastMaps;
public plugin_init() {
register_plugin("Ultimele 5 Harti", "1.0", "cs.eforienett.ro");
register_clcmd("say /harti", "CmdLastMaps");
get_datadir(gSaveFile, charsmax(gSaveFile));
add(gSaveFile, charsmax(gSaveFile), "/ultimeleharti.txt");
new f = fopen(gSaveFile, "rt");
if(f) {
new line[64], minutes[12];
while(!feof(f) && gNumLastMaps < LAST_MAPS_SAVE) {
fgets(f, line, charsmax(line));
trim(line);
if(line[0]) {
parse(line, gLastMapName[gNumLastMaps], charsmax(gLastMapName[]), minutes, charsmax(minutes));
gLastMapTime[gNumLastMaps++] = str_to_num(minutes);
}
}
fclose(f);
}
}
public plugin_end() {
new minutes = floatround(get_gametime() / 60.0, floatround_ceil);
new map[32];
get_mapname(map, charsmax(map));
new f = fopen(gSaveFile, "wt");
fprintf(f, "^"%s^" %d", map, minutes);
if(gNumLastMaps == LAST_MAPS_SAVE) {
gNumLastMaps--;
}
for(new i = 0; i < gNumLastMaps; i++) {
fprintf(f, "^n^"%s^" %d", gLastMapName, gLastMapTime);
}
fclose(f);
}
public CmdLastMaps(id) {
if(gNumLastMaps) {
ColorChat(id, NORMAL, "^4*^1 Ultimele harti jucate sunt:");
new maps[192], len;
for(new i = 0; i < gNumLastMaps; i++) {
if(i && !(i % 3)) {
ColorChat(id, NORMAL, "^4*^1 %s", maps);
len = 0;
}
len += formatex(maps[len], charsmax(maps) - len, "%s%s (^4%d min^1)", len ¿ ", " : "", gLastMapName, gLastMapTime);
}
if(len) {
ColorChat(id, NORMAL, "^4*^1 %s", maps);
}
} else {
client_print(id, print_chat, "* Scuze, nu exista harti jucate in loguri.");
}
}
stock chat_color(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, "!g", "^4")
replace_all(msg, 190, "!y", "^1")
replace_all(msg, 190, "!team", "^3")
replace_all(msg, 190, "!team2", "^0")
if (id) players[0] = id; else get_players(players, count, "ch")
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players)
write_byte(players);
write_string(msg);
message_end();
}
}
}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\ rtf1\ ansi\ deff0{\ fonttbl{\ f0\ fnil Tahoma;}}n\ viewkind4\ uc1\ pard\ lang1033\ f0\ fs16 n\ par }
*/
[/code]
colorchat.inc
Cod:
/* Fun functions
*
* by Numb
*
* This file is provided as is (no warranties).
*/
#if defined _colorchat_included
#endinput
#endif
#define _colorchat_included
enum Color
{
NORMAL = 1, // clients scr_concolor cvar color
GREEN, // Green Color
TEAM_COLOR, // Red, grey, blue
GREY, // grey
RED, // Red
BLUE, // Blue
}
new const TeamName[][] =
{
"",
"TERRORIST",
"CT",
"SPECTATOR"
}
ColorChat(id, Color:type, const msg[], any:...)
{
new message[256];
switch(type)
{
case NORMAL: // clients scr_concolor cvar color
{
message[0] = 0x01;
}
case GREEN: // Green
{
message[0] = 0x04;
}
default: // White, Red, Blue
{
message[0] = 0x03;
}
}
vformat(message[1], 251, msg, 4);
// Make sure message is not longer than 192 character. Will crash the server.
message[192] = '^0';
new team, ColorChange, index, MSG_Type;
if(id)
{
MSG_Type = MSG_ONE_UNRELIABLE;
index = id;
} else {
index = FindPlayer();
MSG_Type = MSG_BROADCAST;
}
team = get_user_team(index);
ColorChange = ColorSelection(index, MSG_Type, type);
ShowColorMessage(index, MSG_Type, message);
if(ColorChange)
{
Team_Info(index, MSG_Type, TeamName[team]);
}
}
ShowColorMessage(id, type, message[])
{
static msgSayText;
if(!msgSayText)
{
msgSayText = get_user_msgid("SayText");
}
message_begin(type, msgSayText, _, id);
write_byte(id)
write_string(message);
message_end();
}
Team_Info(id, type, team[])
{
static msgTeamInfo;
if(!msgTeamInfo)
{
msgTeamInfo = get_user_msgid("TeamInfo");
}
message_begin(type, msgTeamInfo, _, id);
write_byte(id);
write_string(team);
message_end();
return 1;
}
ColorSelection(index, type, Color:Type)
{
switch(Type)
{
case RED:
{
return Team_Info(index, type, TeamName[1]);
}
case BLUE:
{
return Team_Info(index, type, TeamName[2]);
}
case GREY:
{
return Team_Info(index, type, TeamName[0]);
}
}
return 0;
}
FindPlayer()
{
new i = -1;
while(i <= get_maxplayers())
{
if(is_user_connected(++i))
return i;
}
return -1;
}
Cod: ]#include <amxmodx> #include <amxmisc> #include <colorchat>
#define LAST_MAPS_SAVE 5
new gSaveFile[64]; new gLastMapName[LAST_MAPS_SAVE][32]; new gLastMapTime[LAST_MAPS_SAVE]; new gNumLastMaps;
public plugin_init() { register_plugin("Ultimele 5 Harti", "1.0", "cs.eforienett.ro"); register_clcmd("say /harti", "CmdLastMaps"); get_datadir(gSaveFile, charsmax(gSaveFile)); add(gSaveFile, charsmax(gSaveFile), "/ultimeleharti.txt"); new f = fopen(gSaveFile, "rt"); if(f) { new line[64], minutes[12]; while(!feof(f) && gNumLastMaps < LAST_MAPS_SAVE) { fgets(f, line, charsmax(line)); trim(line); if(line[0]) { parse(line, gLastMapName[gNumLastMaps], charsmax(gLastMapName[]), minutes, charsmax(minutes)); gLastMapTime[gNumLastMaps++] = str_to_num(minutes); } } fclose(f); } }
public plugin_end() { new minutes = floatround(get_gametime() / 60.0, floatround_ceil); new map[32]; get_mapname(map, charsmax(map)); new f = fopen(gSaveFile, "wt"); fprintf(f, "^"%s^" %d", map, minutes); if(gNumLastMaps == LAST_MAPS_SAVE) { gNumLastMaps--; } for(new i = 0; i < gNumLastMaps; i++) { fprintf(f, "^n^"%s^" %d", gLastMapName[i], gLastMapTime[i]); } fclose(f); }
public CmdLastMaps(id) { if(gNumLastMaps) { ColorChat(id, NORMAL, "^4*^1 Ultimele harti jucate sunt:"); new maps[192], len; for(new i = 0; i < gNumLastMaps; i++) { if(i && !(i % 3)) { ColorChat(id, NORMAL, "^4*^1 %s", maps); len = 0; } len += formatex(maps[len], charsmax(maps) - len, "%s%s (^4%d min^1)", len ¿ ", " : "", gLastMapName[i], gLastMapTime[i]); } if(len) { ColorChat(id, NORMAL, "^4*^1 %s", maps); } } else { client_print(id, print_chat, "* Scuze, nu exista harti jucate in loguri."); } }
stock chat_color(const id, const input[], any:...) { new count = 1, players[32] static msg[191] vformat(msg, 190, input, 3) replace_all(msg, 190, "!g", "^4") replace_all(msg, 190, "!y", "^1") replace_all(msg, 190, "!team", "^3") replace_all(msg, 190, "!team2", "^0") 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(); } } } }
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE *{\ rtf1\ ansi\ deff0{\ fonttbl{\ f0\ fnil Tahoma;}}n\ viewkind4\ uc1\ pard\ lang1033\ f0\ fs16 n\ par } */ [/code]
colorchat.inc
Cod: /* Fun functions * * by Numb * * This file is provided as is (no warranties). */
#if defined _colorchat_included #endinput #endif #define _colorchat_included
enum Color { NORMAL = 1, // clients scr_concolor cvar color GREEN, // Green Color TEAM_COLOR, // Red, grey, blue GREY, // grey RED, // Red BLUE, // Blue }
new const TeamName[][] = { "", "TERRORIST", "CT", "SPECTATOR" }
ColorChat(id, Color:type, const msg[], any:...) { new message[256];
switch(type) { case NORMAL: // clients scr_concolor cvar color { message[0] = 0x01; } case GREEN: // Green { message[0] = 0x04; } default: // White, Red, Blue { message[0] = 0x03; } }
vformat(message[1], 251, msg, 4);
// Make sure message is not longer than 192 character. Will crash the server. message[192] = '^0';
new team, ColorChange, index, MSG_Type; if(id) { MSG_Type = MSG_ONE_UNRELIABLE; index = id; } else { index = FindPlayer(); MSG_Type = MSG_BROADCAST; } team = get_user_team(index); ColorChange = ColorSelection(index, MSG_Type, type);
ShowColorMessage(index, MSG_Type, message); if(ColorChange) { Team_Info(index, MSG_Type, TeamName[team]); } }
ShowColorMessage(id, type, message[]) { static msgSayText; if(!msgSayText) { msgSayText = get_user_msgid("SayText"); } message_begin(type, msgSayText, _, id); write_byte(id) write_string(message); message_end(); }
Team_Info(id, type, team[]) { static msgTeamInfo; if(!msgTeamInfo) { msgTeamInfo = get_user_msgid("TeamInfo"); } message_begin(type, msgTeamInfo, _, id); write_byte(id); write_string(team); message_end();
return 1; }
ColorSelection(index, type, Color:Type) { switch(Type) { case RED: { return Team_Info(index, type, TeamName[1]); } case BLUE: { return Team_Info(index, type, TeamName[2]); } case GREY: { return Team_Info(index, type, TeamName[0]); } }
return 0; }
FindPlayer() { new i = -1;
while(i <= get_maxplayers()) { if(is_user_connected(++i)) return i; }
return -1; }
|