#include <amxmodx>
new g_szTestCode[] = "14974yg75r8";
new g_szFileDir[128];
public plugin_init()
{
register_clcmd("say /test", "test");
formatex(g_szFileDir[get_localinfo("amxx_configsdir", g_szFileDir, 127)], 127, "/kody.ini");
if(!file_exists(g_szFileDir))
{
write_file(g_szFileDir, "; Lista kodow", 0);
}
}
public test(id)
{
if(is_in_file(g_szTestCode))
{
client_print(id, print_chat, "Kod testowy ^"%s^" znajduje sie juz w pliku!", g_szTestCode);
}
else
{
client_print(id, print_chat, "Kodu testowego ^"%s^" nie ma w pliku!", g_szTestCode);
}
}
stock bool:is_in_file(szCode[])
{
new szSearchCode[35], iLen, i;
for(; read_file(g_szFileDir, i, szSearchCode, 34, iLen); i++)
{
if(!szSearchCode[0] || szSearchCode[0] == ';' || szSearchCode[0] == '/' && szSearchCode[1] == '/')
{
continue;
}
if(equal(szCode, szSearchCode))
{
return true;
}
}
return false;
}