#include <amxmodx>
#include <amxmisc>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Demon"
#define PREFIX "Prefix"
new online_time[33], connect_time[33], Ora[3][33], OraBlocked[33];
new const SZOVEG[][] = {
{ "\wSajA?t IdL‘d" },
{ "\wJA?tszot idL‘d a szerveren: " },
{ "\wA‰rd el a 100\dAlrA?t hogy jutalmat kaphass.^n\rJutalom:\w Kick jog" },
{ "^1Sikeresen megkaptad a jutalmad.^4 >^3 Kick jogt^1." },
{ "^1Sjanálom, túl kevés órád van!" },
{ "^1Te már meg kaptad a jutalmad." }
}
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
}
public IdoShowMenu(id) {
new szText[512]
calc_user_otime(id)
format(szText, charsmax(szText), "%s", SZOVEG[0])
new menu = menu_create(szText, "IdoShowMenuh")
format(szText, charsmax(szText), "%s^n\d%d\yAl\d %d\yp\d %d\ymp^n", SZOVEG[1], Ora[0][id], Ora[1][id], Ora[2][id])
menu_additem(menu, szText, "1")
format(szText, charsmax(szText), "%s", SZOVEG[2])
menu_additem(menu, szText, "2")
menu_display(id, menu)
}
public IdoShowMenuh(id, menu, item) {
if( item == MENU_EXIT ) {
menu_destroy(menu)
return PLUGIN_HANDLED
}
new data[6], szName[64], access, callback
menu_item_getinfo(menu, item, access, data,charsmax(data), szName,charsmax(szName), callback);
new key = str_to_num(data)
switch(key) {
case 1: IdoShowMenu(id)
case 2: {
if(OraBlocked[id] != 1) {
if(Ora[0][id] >= 100) {
set_user_flags(id, read_flags("c"))
print_color(id, "!g[%s] %s", PREFIX, SZOVEG[3])
OraBlocked[id] = 1
IdoShowMenu(id)
}
else {
print_color(id, "!g[%s] %s", PREFIX, SZOVEG[4])
IdoShowMenu(id)
}
}
else {
print_color(id, "!g[%s] %s", PREFIX, SZOVEG[5])
IdoShowMenu(id)
}
}
}
menu_destroy(menu)
return PLUGIN_HANDLED
}
public client_putinserver(id)
{
online_time[id] = connect_time[id] = OraBlocked[id] = 0;
if(!is_user_bot(id) && !is_user_hltv(id))
{
connect_time[id] = get_user_time(id, 1);
Load(id);
}
}
public client_disconnect(id)
{
if(!is_user_bot(id) && !is_user_hltv(id))
Save(id);
}
public calc_user_otime(id)
{
online_time[id] += (get_user_time(id, 1) - connect_time[id]);
Ora[0][id] = online_time[id]/3600;
Ora[1][id] = (online_time[id]/60)%60;
Ora[2][id] = online_time[id]%60;
}
public Save(id)
{
new file[200], Name[32];
get_configsdir(file, 199);
get_user_name(id, Name, 31)
format(file, 199, "%s/Mentes", file);
if(!dir_exists(file)) mkdir(file);
format(file, 199, "%s/%s.ini", file, Name);
if(file_exists(file))
delete_file(file);
new pFile = fopen(file, "wt");
if(pFile)
{
new linetoadd[128];
formatex(linetoadd, 127, "^"%d^" ^"%d^" ^"%d^"", Ora[0][id], Ora[1][id], Ora[2][id]);
write_file(file, linetoadd);
fclose(pFile);
}
return PLUGIN_HANDLED;
}
public Load(id)
{
new file[200], Name[32];
get_configsdir(file, 199);
get_user_name(id, Name, 31)
format(file, 199, "%s/Mentes/%s.ini", file, Name);
if (!file_exists(file))
return PLUGIN_HANDLED;
new pFile = fopen(file, "rt");
if(pFile)
{
new Line[192], data[3][8];
fgets(pFile, Line, 191);
if(Line[0] == ';' || strlen(Line) < 10)
{
fclose(pFile);
return PLUGIN_HANDLED;
}
parse(Line, data[0], 7, data[1], 7, data[2], 7);
online_time[id] = ((str_to_num(data[0])*3600) + (str_to_num(data[1])*60) + str_to_num(data[2]));
fclose(pFile);
}
return PLUGIN_HANDLED;
}
stock print_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, "!t", "^3");
replace_all(msg, 190, "á", "A?");
replace_all(msg, 190, "é", "A©");
replace_all(msg, 190, "í", "A");
replace_all(msg, 190, "ó", "Al");
replace_all(msg, 190, "ö", "A¶");
replace_all(msg, 190, "o", "L‘");
replace_all(msg, 190, "ú", "As");
replace_all(msg, 190, "ü", "AL");
replace_all(msg, 190, "u", "L±");
replace_all(msg, 255, "Á", "A-");
replace_all(msg, 190, "É", "A‰");
replace_all(msg, 190, "Í", "AT");
replace_all(msg, 190, "Ó", "A“");
replace_all(msg, 190, "Ö", "A–");
replace_all(msg, 190, "O", "L");
replace_all(msg, 190, "Ú", "Aš");
replace_all(msg, 190, "Ü", "As");
replace_all(msg, 190, "U", "L°");
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();
}
}
}
return PLUGIN_HANDLED;
}