Сompiler blacklist by rk

Статус
В этой теме нельзя размещать новые ответы.

Shadowless

Пользователь
Регистрация
24 Фев 2019
Сообщения
237
Симпатии
4
Пол
Мужской
Amx Mod X
ReAMXX 1.8.3
Ошибка
Код:
blacklist.sma(405) : error 029: invalid expression, assumed zero
blacklist.sma(405) : error 035: argument type mismatch (argument 3)
blacklist.sma(456) : error 017: undefined symbol "szTemp"
blacklist.sma(456) : warning 215: expression has no effect
blacklist.sma(456) : error 001: expected token: ";", but found "]"
blacklist.sma(456) : error 029: invalid expression, assumed zero
blacklist.sma(456) : fatal error 107: too many error messages on one line

Compilation aborted.
Исходник
Код:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "blacklist"
#define VERSION "1.0"
#define AUTHOR "rk"

#define PREFIX "AMXX"
#define DEF_TIME 60
#define REMOVE_TASK 89794

#define MINUTE 1
#define HOUR 60
#define DAY 1440
#define MONTH 43200
#define YEAR 518400

new const szFile[] = "addons/amxmodx/data/blacklist.txt";

enum _: EInfo
{
szSID[32],
szLastName[32],
szLastOnline[32],

g_iBanTime
}

new g_iTime[33], g_iLooking[33];
new Array: g_iArray;

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /blacklist", "cmdBlackList");
register_clcmd("choose_time", "cmdChooseTime");

g_iArray = ArrayCreate(EInfo);

cmdLoad();

new minimal = getMinimal();

if(minimal!=-1)
{
new szTemp[EInfo], szP[3];

szP[0] = minimal;
ArrayGetArray(g_iArray, minimal, szTemp);

set_task(float(szTemp[g_iBanTime] - get_systime()), "cmdRemoveMinimal",REMOVE_TASK, szP, charsmax(szP));
}
}

public plugin_end()
{
cmdSave();

ArrayDestroy(g_iArray);
}

public plugin_natives()
{
register_native("isBanned", "native_isBanned");
}

public native_isBanned(params)
{
if(params < 1)
{
return PLUGIN_CONTINUE;
}

new id = get_param(1);

if(isExists(getSID(id)))
return 1;

return 0;
}

public client_disconnect(id)
{
new k = isExists(getSID(id));

if(k != -1)
{
new szTemp[EInfo];
ArrayGetArray(g_iArray, k, szTemp);

formatex(szTemp[szLastName], 31, "%s", getName(id));
ArraySetArray(g_iArray, k, szTemp);
}

}

public cmdRemoveMinimal(szParm[])
{
new key = szParm[0], szTemp[EInfo];

ArrayGetArray(g_iArray, key, szTemp);

new k = isOnline(szTemp[szSID]);

if(k==-1)
client_print(0, print_chat, "%s's ban is over", szTemp[szLastName]);
else
client_print(0, print_chat, "%s's ban is over", getName(k));

ArrayDeleteItem(g_iArray, key);


new minimal = getMinimal();
if(minimal!=-1)
{
new szTemp1[EInfo], szP[3];

szP[0] = minimal;
ArrayGetArray(g_iArray, minimal, szTemp1);

set_task(float(szTemp1[g_iBanTime] - get_systime()), "cmdRemoveMinimal",REMOVE_TASK, szP, charsmax(szP));
}
}

public cmdChooseTime(id)
{
if(!(get_user_flags(id) & ADMIN_BAN))
{
client_print(id, print_chat, "you have no access to this menu");
return PLUGIN_HANDLED;
}

static szMessage[32];
read_argv(1, szMessage, charsmax(szMessage));

g_iTime[id] = str_to_num(szMessage);

cmdAddInfo(id, g_iLooking[id]);

return PLUGIN_HANDLED;
}

public cmdBlackList(id)
{

if(!(get_user_flags(id) & ADMIN_BAN))
{
client_print(id, print_chat, "you have no access to this menu");
return PLUGIN_HANDLED;
}

g_iLooking[id] = -1;

new szText[256];
formatex(szText, charsmax(szText), "\r[%s]\w Black List - main menu", PREFIX);

new menu = menu_create(szText, "cmdBlackListHandler");

menu_additem(menu, "\wAdd a person");

formatex(szText, charsmax(szText), "\wRemove a person \y[%i]", ArraySize(g_iArray));
menu_additem(menu, szText);

menu_display(id, menu);

return PLUGIN_HANDLED;
}

public cmdBlackListHandler(id, menu, item)
{
menu_destroy(menu);

if(item == MENU_EXIT)
{
return PLUGIN_HANDLED;
}

switch(item)
{
case 0: cmdAdd(id);
case 1:
{
cmdRemove(id);
}
}

return PLUGIN_HANDLED;
}

public cmdAdd(id)
{
g_iLooking[id] = -1;

new szText[256], players[32], len, szParm[3];
formatex(szText, charsmax(szText), "\r[%s]\w Black List - add menu", PREFIX);

new menu = menu_create(szText, "cmdAddHandler");

getPlayersID(players, len);

if(!len)
{
cmdBlackList(id);
return PLUGIN_HANDLED;
}

for(new i=0; i<sizeof(players); i++)
{
if(!is_user_connected(players))
continue;

num_to_str(players, szParm, charsmax(szParm));

formatex(szText, charsmax(szText), "%s", getName(players));
menu_additem(menu, szText, szParm);
}

menu_display(id, menu);

return PLUGIN_HANDLED;
}

public cmdAddHandler(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu);

cmdBlackList(id);
return PLUGIN_HANDLED;
}

new key = MenuKey(menu, item);
g_iTime[id] = DEF_TIME;

if(isExists(getSID(key)) == -1)
cmdAddInfo(id, key);
else
client_print(id, print_chat, "this player is already banned.");

return PLUGIN_HANDLED;
}

public cmdAddInfo(id, player)
{
g_iLooking[id] = player;

new szText[256], szParm[3];
formatex(szText, charsmax(szText), "\r[%s]\w Black List - adding %s", PREFIX, getName(player));

new menu = menu_create(szText, "cmdAddInfoHandler");
new cb = menu_makecallback("disabled");

formatex(szText, charsmax(szText), "\wName: %s", getName(player));
menu_additem(menu, szText, .callback = cb);

formatex(szText, charsmax(szText), "\wTime: %s", GenerateTime(g_iTime[id]));
menu_additem(menu, szText);

num_to_str(player, szParm, charsmax(szParm));

menu_additem(menu, "\rAdd!", szParm);

menu_display(id, menu);
return PLUGIN_HANDLED;
}

public cmdAddInfoHandler(id, menu, item)
{
if(item == MENU_EXIT)
{
g_iTime[id] = DEF_TIME;
g_iLooking[id] = -1;

cmdAdd(id);
return PLUGIN_HANDLED;
}

switch(item)
{
case 1:
{

client_cmd(id, "messagemode choose_time");
}

case 2:
{
new key = MenuKey(menu, 2);
cmdFinalAdd(id, key, g_iTime[id]);
}
}


menu_destroy(menu);
return PLUGIN_HANDLED;
}

public cmdRemove(id)
{
new szText[256];

new size = ArraySize(g_iArray);

if(size == 0)
{
cmdBlackList(id);
return PLUGIN_HANDLED;
}


formatex(szText, charsmax(szText), "\r[%s]\w Black List - remove menu (%i total bans)", PREFIX, size);
new menu = menu_create(szText, "cmdRemoveHandler");

for(new i=0; i<size; i++)
{
new szTemp[EInfo];
ArrayGetArray(g_iArray, i, szTemp);

formatex(szText, charsmax(szText), "%s", szTemp[szLastName]);

new k = isOnline(szTemp[szSID]);

if(k != -1)
formatex(szText, charsmax(szText), "%s", getName(k));

menu_additem(menu, szText);
}

menu_display(id, menu, 0);

return PLUGIN_HANDLED;
}

public cmdRemoveHandler(id, menu, item)
{
if(item == MENU_EXIT)
{
cmdBlackList(id);
return PLUGIN_HANDLED;
}

cmdRemoveInfo(id, item);

return PLUGIN_HANDLED;
}

public cmdRemoveInfo(id, player)
{
new szTemp[EInfo];
ArrayGetArray(g_iArray, player, szTemp);

new szText[256], Name[32], szParm[3];
new k = isOnline(szTemp[szSID]);

formatex(Name, charsmax(Name), "%s", szTemp[szLastName]);

if(k != -1)
formatex(Name, charsmax(Name), "%s", getName(k));

formatex(szText, charsmax(szText), "\r[%s]\w Black List - info %s", PREFIX, Name);

new menu = menu_create(szText, "cmdRemoveInfoHandler");
new cb = menu_makecallback("disabled");

formatex(szText, charsmax(szText), "\wName: %s", Name);
menu_additem(menu, szText, .callback = cb);

if(k == -1)
formatex(szText, charsmax(szText), "\wLast Online: %s", szTemp[szLastOnline]);
else
formatex(szText, charsmax(szText), "\wLast Online: \yONLINE");

menu_additem(menu, szText, .callback = cb);

new temp = (szTemp[g_iBanTime] - get_systime()) / 60;

if(!temp)
temp = 1;

formatex(szText, charsmax(szText), "\wExpired Time: %s^n", GenerateTime(temp));
menu_additem(menu, szText, .callback = cb);

num_to_str(player, szParm, charsmax(szParm));

menu_additem(menu, "\rRemove!", szParm);

menu_display(id, menu);
return PLUGIN_HANDLED;
}

public cmdRemoveInfoHandler(id, menu, item)
{
if(item == MENU_EXIT)
{
cmdRemove(id);
return PLUGIN_HANDLED;
}

if(item == 3)
{
new key = MenuKey(menu, 2);
cmdFinalRemove(id, key, );
}

return PLUGIN_HANDLED;
}

public cmdFinalAdd(id, player, Time)
{
if(isExists(getSID(player)) != -1)
{
client_print(id, print_chat, "this player is already banned.");
return PLUGIN_HANDLED;
}

new szTemp[EInfo];

formatex(szTemp[szLastName], 31, "%s", getName(player));
formatex(szTemp[szSID], 31, "%s", getSID(player));
get_time("%m/%d/%Y-%H:%M:%S", szTemp[szLastOnline], charsmax(szTemp[szLastOnline]));

szTemp[g_iBanTime] = Time*60 + get_systime();

ArrayPushArray(g_iArray, szTemp);

client_print(0, print_chat, "%s added %s to blacklist (time: %i)", getName(id), getName(player), Time);

remove_task(REMOVE_TASK);

new minimal = getMinimal();

if(minimal != -1)
{
new szTemp1[EInfo], szP[3];

szP[0] = minimal;
ArrayGetArray(g_iArray, minimal, szTemp1);

set_task(float(szTemp1[g_iBanTime] - get_systime()), "cmdRemoveMinimal",REMOVE_TASK, szP, charsmax(szP));
}


g_iTime[id] = DEF_TIME;
g_iLooking[id] = -1;

cmdBlackList(id);

return PLUGIN_HANDLED;
}

public cmdFinalRemove(id, key, S[])
{
if(isExists(szTemp[szSID]) == -1)
{
client_print(id, print_chat, "this player is no longer banned.");
return PLUGIN_HANDLED;
}

new szTemp[EInfo];
ArrayGetArray(g_iArray, key, szTemp);


new k = isOnline(szTemp[szSID]);

if(k==-1)
client_print(0, print_chat, "%s removed %s's ban", getName(id), szTemp[szLastName]);
else
client_print(0, print_chat, "%s removed %s's ban", getName(id), getName(k));

ArrayDeleteItem(g_iArray, key);

cmdBlackList(id);

return PLUGIN_HANDLED;
}


public disabled(id, menu, item)
{
return ITEM_DISABLED;
}

public getPlayersID(players[], &l)
{
new p[32], num= 0, temp = 0;
get_players(p, num);

for(new i=0; i<num; i++)
{
if(isExists(getSID(p)) == -1 && is_user_connected(p))
{
players[temp++] = p;
}
}

l = temp
}

public GenerateTime(t)
{
new szText[256], szTemp[100];

new year, month, day, hour, minute;

year = t/YEAR;
t-=year*YEAR;

month = t/MONTH;
t-=month*MONTH;

day = t/DAY;
t-=day*DAY;

hour = t/HOUR;
t-=hour*HOUR;

minute = t/MINUTE;

if(year)
{
formatex(szTemp, charsmax(szTemp), "%i Year%s", year, year>1? "s" : "");
format(szText, charsmax(szText), "%s %s ", szText, szTemp);
}

if(month)
{
formatex(szTemp, charsmax(szTemp), "%i Month%s", month, month>1? "s" : "");
format(szText, charsmax(szText), "%s %s ", szText, szTemp);
}

if(day)
{
formatex(szTemp, charsmax(szTemp), "%i Day%s", day, day>1? "s" : "");
format(szText, charsmax(szText), "%s %s ", szText, szTemp);
}

if(hour)
{
formatex(szTemp, charsmax(szTemp), "%i Hour%s", hour, hour>1? "s" : "");
format(szText, charsmax(szText), "%s %s ", szText, szTemp);
}

if(minute)
{
formatex(szTemp, charsmax(szTemp), "%i Minute%s", minute, minute>1? "s" : "");
format(szText, charsmax(szText), "%s %s", szText, szTemp);
}

return szText;
}

public cmdLoad()
{
new f = fopen(szFile, "rt");

new szData[500];

while(fgets(f, szData, charsmax(szData)))
{
new szTemp[EInfo], steam[32], name[32], online[32], t[32];

parse(szData, steam, 31, name, 31, online,31, t,31);

formatex(szTemp[szSID], 31, "%s", steam);
formatex(szTemp[szLastName], 31, "%s", name);
formatex(szTemp[szLastOnline], 31, "%s", online);

szTemp[g_iBanTime] = str_to_num(t);

ArrayPushArray(g_iArray, szTemp);
}

fclose(f);
}

public cmdSave()
{
new f = fopen(szFile, "wt");

new szData[500];

while(ArraySize(g_iArray) > 0)
{
new szTemp[EInfo];
ArrayGetArray(g_iArray, 0 , szTemp);

formatex(szData, charsmax(szData), "^"%s^" ^"%s^" ^"%s^" ^"%i^"", szTemp[szSID], szTemp[szLastName], szTemp[szLastOnline], szTemp[g_iBanTime]);

fputs(f, szData);

ArrayDeleteItem(g_iArray, 0);
}

fclose(f);
}

public getMinimal()
{
new minimalTime = -1, minimalKey = -1, size = ArraySize(g_iArray);

for(new i=0; i<size; i++)
{
new szTemp[EInfo];

ArrayGetArray(g_iArray, i, szTemp);

if(minimalTime == -1 || szTemp[g_iBanTime] < minimalTime)
{
minimalTime = szTemp[g_iBanTime];
minimalKey = i;
}
}

return minimalKey;
}

stock MenuKey(menu, item)
{
new szData[10];
new access, callback;

menu_item_getinfo(menu, item, access, szData, charsmax(szData), _, _, callback);

return str_to_num(szData);
}


stock isExists(SID[])
{
new size = ArraySize(g_iArray);

for(new i=0; i<size; i++)
{
new szTemp[EInfo];

ArrayGetArray(g_iArray, i, szTemp);

if(equali(szTemp[szSID], SID))
return i;
}

return -1;
}

stock isOnline(SID[])
{
new players[32], num;
get_players(players, num);

for(new i=0; i<num; i++)
{
if(equali(getSID(players), SID))
return players;
}

return -1;
}

stock getName(id)
{
new szName[32];
get_user_name(id, szName, charsmax(szName));

return szName;
}

stock getSID(id)
{
new szS[32];
get_user_authid(id, szS, charsmax(szS));

return szS;
}

NeTvoyKenji

Пользователь
Регистрация
27 Мар 2019
Сообщения
423
Симпатии
47
Забудь про ReAMXX 1.8.3, он уже не актуален.
 

NeTvoyKenji

Пользователь
Регистрация
27 Мар 2019
Сообщения
423
Симпатии
47
issue is that plugin does not want to be compiled
Плагин и у меня на 1.9.0 не компилируется, поверь.1558379975416.png
i can`t hoster does not allow other amxx
Смени хостера, раз такие ограничения.
А лучше вообще взять VDS.[DOUBLEPOST=1558380054][/DOUBLEPOST]На 1.8.2 похожая ситуация1558380050863.png
 

Вложения

Shadowless

Пользователь
Регистрация
24 Фев 2019
Сообщения
237
Симпатии
4
Пол
Мужской
i doubt i need scripter :( seems problem is in scripting :(
 

georgeml

Скриптер
Постоялец
Регистрация
12 Сен 2017
Сообщения
595
Симпатии
314
C++:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "blacklist"
#define VERSION "1.0"
#define AUTHOR "rk"

#define PREFIX "AMXX"
#define DEF_TIME 60
#define REMOVE_TASK 89794

#define MINUTE 1
#define HOUR 60
#define DAY 1440
#define MONTH 43200
#define YEAR 518400

new const szFile[] = "addons/amxmodx/data/blacklist.txt";

enum _: EInfo
{
szSID[32],
szLastName[32],
szLastOnline[32],

g_iBanTime
}

new g_iTime[33], g_iLooking[33];
new Array: g_iArray;

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /blacklist", "cmdBlackList");
register_clcmd("choose_time", "cmdChooseTime");

g_iArray = ArrayCreate(EInfo);

cmdLoad();

new minimal = getMinimal();

if(minimal!=-1)
{
new szTemp[EInfo], szP[3];

szP[0] = minimal;
ArrayGetArray(g_iArray, minimal, szTemp);

set_task(float(szTemp[g_iBanTime] - get_systime()), "cmdRemoveMinimal",REMOVE_TASK, szP, charsmax(szP));
}
}

public plugin_end()
{
cmdSave();

ArrayDestroy(g_iArray);
}

public plugin_natives()
{
register_native("isBanned", "native_isBanned");
}

public native_isBanned(params)
{
if(params < 1)
{
return PLUGIN_CONTINUE;
}

new id = get_param(1);

if(isExists(getSID(id)))
return 1;

return 0;
}

public client_disconnected(id)
{
new k = isExists(getSID(id));

if(k != -1)
{
new szTemp[EInfo];
ArrayGetArray(g_iArray, k, szTemp);

formatex(szTemp[szLastName], 31, "%s", getName(id));
ArraySetArray(g_iArray, k, szTemp);
}

}

public cmdRemoveMinimal(szParm[])
{
new key = szParm[0], szTemp[EInfo];

ArrayGetArray(g_iArray, key, szTemp);

new k = isOnline(szTemp[szSID][0]);

if(k==-1)
client_print(0, print_chat, "%s's ban is over", szTemp[szLastName]);
else
client_print(0, print_chat, "%s's ban is over", getName(k));

ArrayDeleteItem(g_iArray, key);


new minimal = getMinimal();
if(minimal!=-1)
{
new szTemp1[EInfo], szP[3];

szP[0] = minimal;
ArrayGetArray(g_iArray, minimal, szTemp1);

set_task(float(szTemp1[g_iBanTime] - get_systime()), "cmdRemoveMinimal",REMOVE_TASK, szP, charsmax(szP));
}
}

public cmdChooseTime(id)
{
if(!(get_user_flags(id) & ADMIN_BAN))
{
client_print(id, print_chat, "you have no access to this menu");
return PLUGIN_HANDLED;
}

static szMessage[32];
read_argv(1, szMessage, charsmax(szMessage));

g_iTime[id] = str_to_num(szMessage);

cmdAddInfo(id, g_iLooking[id]);

return PLUGIN_HANDLED;
}

public cmdBlackList(id)
{

if(!(get_user_flags(id) & ADMIN_BAN))
{
client_print(id, print_chat, "you have no access to this menu");
return PLUGIN_HANDLED;
}

g_iLooking[id] = -1;

new szText[256];
formatex(szText, charsmax(szText), "\r[%s]\w Black List - main menu", PREFIX);

new menu = menu_create(szText, "cmdBlackListHandler");

menu_additem(menu, "\wAdd a person");

formatex(szText, charsmax(szText), "\wRemove a person \y[%i]", ArraySize(g_iArray));
menu_additem(menu, szText);

menu_display(id, menu);

return PLUGIN_HANDLED;
}

public cmdBlackListHandler(id, menu, item)
{
menu_destroy(menu);

if(item == MENU_EXIT)
{
return PLUGIN_HANDLED;
}

switch(item)
{
case 0: cmdAdd(id);
case 1:
{
cmdRemove(id);
}
}

return PLUGIN_HANDLED;
}

public cmdAdd(id)
{
g_iLooking[id] = -1;

new szText[256], players[32], len, szParm[3];
formatex(szText, charsmax(szText), "\r[%s]\w Black List - add menu", PREFIX);

new menu = menu_create(szText, "cmdAddHandler");

getPlayersID(players, len);

if(!len)
{
cmdBlackList(id);
return PLUGIN_HANDLED;
}

for(new i=0; i<sizeof(players); i++)
{
if(!is_user_connected(players[i]))
continue;

num_to_str(players[i], szParm, charsmax(szParm));

formatex(szText, charsmax(szText), "%s", getName(players[i]));
menu_additem(menu, szText, szParm);
}

menu_display(id, menu);

return PLUGIN_HANDLED;
}

public cmdAddHandler(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu);

cmdBlackList(id);
return PLUGIN_HANDLED;
}

new key = MenuKey(menu, item);
g_iTime[id] = DEF_TIME;

if(isExists(getSID(key)) == -1)
cmdAddInfo(id, key);
else
client_print(id, print_chat, "this player is already banned.");

return PLUGIN_HANDLED;
}

public cmdAddInfo(id, player)
{
g_iLooking[id] = player;

new szText[256], szParm[3];
formatex(szText, charsmax(szText), "\r[%s]\w Black List - adding %s", PREFIX, getName(player));

new menu = menu_create(szText, "cmdAddInfoHandler");
new cb = menu_makecallback("disabled");

formatex(szText, charsmax(szText), "\wName: %s", getName(player));
menu_additem(menu, szText, .callback = cb);

formatex(szText, charsmax(szText), "\wTime: %s", GenerateTime(g_iTime[id]));
menu_additem(menu, szText);

num_to_str(player, szParm, charsmax(szParm));

menu_additem(menu, "\rAdd!", szParm);

menu_display(id, menu);
return PLUGIN_HANDLED;
}

public cmdAddInfoHandler(id, menu, item)
{
if(item == MENU_EXIT)
{
g_iTime[id] = DEF_TIME;
g_iLooking[id] = -1;

cmdAdd(id);
return PLUGIN_HANDLED;
}

switch(item)
{
case 1:
{

client_cmd(id, "messagemode choose_time");
}

case 2:
{
new key = MenuKey(menu, 2);
cmdFinalAdd(id, key, g_iTime[id]);
}
}


menu_destroy(menu);
return PLUGIN_HANDLED;
}

public cmdRemove(id)
{
new szText[256];

new size = ArraySize(g_iArray);

if(size == 0)
{
cmdBlackList(id);
return PLUGIN_HANDLED;
}


formatex(szText, charsmax(szText), "\r[%s]\w Black List - remove menu (%i total bans)", PREFIX, size);
new menu = menu_create(szText, "cmdRemoveHandler");

for(new i=0; i<size; i++)
{
new szTemp[EInfo];
ArrayGetArray(g_iArray, i, szTemp);

formatex(szText, charsmax(szText), "%s", szTemp[szLastName]);

new k = isOnline(szTemp[szSID][0]);

if(k != -1)
formatex(szText, charsmax(szText), "%s", getName(k));

menu_additem(menu, szText);
}

menu_display(id, menu, 0);

return PLUGIN_HANDLED;
}

public cmdRemoveHandler(id, menu, item)
{
if(item == MENU_EXIT)
{
cmdBlackList(id);
return PLUGIN_HANDLED;
}

cmdRemoveInfo(id, item);

return PLUGIN_HANDLED;
}

public cmdRemoveInfo(id, player)
{
new szTemp[EInfo];
ArrayGetArray(g_iArray, player, szTemp);

new szText[256], Name[32], szParm[3];
new k = isOnline(szTemp[szSID][0]);

formatex(Name, charsmax(Name), "%s", szTemp[szLastName]);

if(k != -1)
formatex(Name, charsmax(Name), "%s", getName(k));

formatex(szText, charsmax(szText), "\r[%s]\w Black List - info %s", PREFIX, Name);

new menu = menu_create(szText, "cmdRemoveInfoHandler");
new cb = menu_makecallback("disabled");

formatex(szText, charsmax(szText), "\wName: %s", Name);
menu_additem(menu, szText, .callback = cb);

if(k == -1)
formatex(szText, charsmax(szText), "\wLast Online: %s", szTemp[szLastOnline]);
else
formatex(szText, charsmax(szText), "\wLast Online: \yONLINE");

menu_additem(menu, szText, .callback = cb);

new temp = (szTemp[g_iBanTime] - get_systime()) / 60;

if(!temp)
temp = 1;

formatex(szText, charsmax(szText), "\wExpired Time: %s^n", GenerateTime(temp));
menu_additem(menu, szText, .callback = cb);

num_to_str(player, szParm, charsmax(szParm));

menu_additem(menu, "\rRemove!", szParm);

menu_display(id, menu);
return PLUGIN_HANDLED;
}

public cmdRemoveInfoHandler(id, menu, item)
{
if(item == MENU_EXIT)
{
cmdRemove(id);
return PLUGIN_HANDLED;
}

if(item == 3)
{
new key = MenuKey(menu, 2);
cmdFinalRemove(id, key);
}

return PLUGIN_HANDLED;
}

public cmdFinalAdd(id, player, Time)
{
if(isExists(getSID(player)) != -1)
{
client_print(id, print_chat, "this player is already banned.");
return PLUGIN_HANDLED;
}

new szTemp[EInfo];

formatex(szTemp[szLastName], 31, "%s", getName(player));
formatex(szTemp[szSID], 31, "%s", getSID(player));
get_time("%m/%d/%Y-%H:%M:%S", szTemp[szLastOnline], charsmax(szTemp[szLastOnline]));

szTemp[g_iBanTime] = Time*60 + get_systime();

ArrayPushArray(g_iArray, szTemp);

client_print(0, print_chat, "%s added %s to blacklist (time: %i)", getName(id), getName(player), Time);

remove_task(REMOVE_TASK);

new minimal = getMinimal();

if(minimal != -1)
{
new szTemp1[EInfo], szP[3];

szP[0] = minimal;
ArrayGetArray(g_iArray, minimal, szTemp1);

set_task(float(szTemp1[g_iBanTime] - get_systime()), "cmdRemoveMinimal",REMOVE_TASK, szP, charsmax(szP));
}


g_iTime[id] = DEF_TIME;
g_iLooking[id] = -1;

cmdBlackList(id);

return PLUGIN_HANDLED;
}

public cmdFinalRemove(id, key)
{
new szTemp[EInfo];
ArrayGetArray(g_iArray, key, szTemp);  
if(isExists(szTemp[szSID]) == -1)
{
client_print(id, print_chat, "this player is no longer banned.");
return PLUGIN_HANDLED;
}




new k = isOnline(szTemp[szSID][0]);

if(k==-1)
client_print(0, print_chat, "%s removed %s's ban", getName(id), szTemp[szLastName]);
else
client_print(0, print_chat, "%s removed %s's ban", getName(id), getName(k));

ArrayDeleteItem(g_iArray, key);

cmdBlackList(id);

return PLUGIN_HANDLED;
}


public disabled(id, menu, item)
{
return ITEM_DISABLED;
}

public getPlayersID(players[], &l)
{
new p[32], num= 0, temp = 0;
get_players(p, num);

for(new i=0; i<num; i++)
{
if(isExists(getSID(p[i])) == -1 && is_user_connected(p[i]))
{
players[temp++] = p[i];
}
}

l = temp
}

public GenerateTime(t)
{
new szText[256], szTemp[100];

new year, month, day, hour, minute;

year = t/YEAR;
t-=year*YEAR;

month = t/MONTH;
t-=month*MONTH;

day = t/DAY;
t-=day*DAY;

hour = t/HOUR;
t-=hour*HOUR;

minute = t/MINUTE;

if(year)
{
formatex(szTemp, charsmax(szTemp), "%i Year%s", year, year>1? "s" : "");
format(szText, charsmax(szText), "%s %s ", szText, szTemp);
}

if(month)
{
formatex(szTemp, charsmax(szTemp), "%i Month%s", month, month>1? "s" : "");
format(szText, charsmax(szText), "%s %s ", szText, szTemp);
}

if(day)
{
formatex(szTemp, charsmax(szTemp), "%i Day%s", day, day>1? "s" : "");
format(szText, charsmax(szText), "%s %s ", szText, szTemp);
}

if(hour)
{
formatex(szTemp, charsmax(szTemp), "%i Hour%s", hour, hour>1? "s" : "");
format(szText, charsmax(szText), "%s %s ", szText, szTemp);
}

if(minute)
{
formatex(szTemp, charsmax(szTemp), "%i Minute%s", minute, minute>1? "s" : "");
format(szText, charsmax(szText), "%s %s", szText, szTemp);
}

return szText;
}

public cmdLoad()
{
new f = fopen(szFile, "rt");

new szData[500];

while(fgets(f, szData, charsmax(szData)))
{
new szTemp[EInfo], steam[32], name[32], online[32], t[32];

parse(szData, steam, 31, name, 31, online,31, t,31);

formatex(szTemp[szSID], 31, "%s", steam);
formatex(szTemp[szLastName], 31, "%s", name);
formatex(szTemp[szLastOnline], 31, "%s", online);

szTemp[g_iBanTime] = str_to_num(t);

ArrayPushArray(g_iArray, szTemp);
}

fclose(f);
}

public cmdSave()
{
new f = fopen(szFile, "wt");

new szData[500];

while(ArraySize(g_iArray) > 0)
{
new szTemp[EInfo];
ArrayGetArray(g_iArray, 0 , szTemp);

formatex(szData, charsmax(szData), "^"%s^" ^"%s^" ^"%s^" ^"%i^"", szTemp[szSID], szTemp[szLastName], szTemp[szLastOnline], szTemp[g_iBanTime]);

fputs(f, szData);

ArrayDeleteItem(g_iArray, 0);
}

fclose(f);
}

public getMinimal()
{
new minimalTime = -1, minimalKey = -1, size = ArraySize(g_iArray);

for(new i=0; i<size; i++)
{
new szTemp[EInfo];

ArrayGetArray(g_iArray, i, szTemp);

if(minimalTime == -1 || szTemp[g_iBanTime] < minimalTime)
{
minimalTime = szTemp[g_iBanTime];
minimalKey = i;
}
}

return minimalKey;
}

stock MenuKey(menu, item)
{
new szData[10];
new access, callback;

menu_item_getinfo(menu, item, access, szData, charsmax(szData), _, _, callback);

return str_to_num(szData);
}


stock isExists(SID[])
{
new size = ArraySize(g_iArray);

for(new i=0; i<size; i++)
{
new szTemp[EInfo];

ArrayGetArray(g_iArray, i, szTemp);

if(equali(szTemp[szSID], SID))
return i;
}

return -1;
}

stock isOnline(SID[])
{
new players[32], num;
get_players(players, num);

for(new i=0; i<num; i++)
{
if(equali(getSID(players[i]), SID))
return i;
}

return -1;
}

stock getName(id)
{
new szName[32];
get_user_name(id, szName, charsmax(szName));

return szName;
}

stock getSID(id)
{
new szS[32];
get_user_authid(id, szS, charsmax(szS));

return szS;
}
Сомневаюсь, что это чудо работает. Логика кода нарушена во многих местах. Что заметил, поправил. Остальное- ну его..)
 

Shadowless

Пользователь
Регистрация
24 Фев 2019
Сообщения
237
Симпатии
4
Пол
Мужской
yes yes yes yes yes... its compiled... lets test now <3<3<3<3<3<3
 

Shadowless

Пользователь
Регистрация
24 Фев 2019
Сообщения
237
Симпатии
4
Пол
Мужской
does not work :(
on selecting player adding other player in list
no changes in blacklist.txt,
but added player in list is shown is remove list
there is no debug logs also:(

too problematic plugin
 

Shadowless

Пользователь
Регистрация
24 Фев 2019
Сообщения
237
Симпатии
4
Пол
Мужской
please close the topic
 
Статус
В этой теме нельзя размещать новые ответы.
Сверху Снизу