HLMOD.HU Forrás Megtekintés
- www.hlmod.hu/*** --[Memo IPs Plugin]--
Magyarositota:Servercfg
Weboldal:versus.cjb.hu
***/
#include <amxmodx>
#include <amxmisc>
new PLUGIN[] = "AmxModX Memo"
new VERSION[] = "0.0.1"
new AUTHOR[] = "Kenvelo"
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_concmd("amx_memo_who", "amx_memo_who", ADMIN_IMMUNITY, "<name> - check the registered name of user")
register_concmd("amx_memo_listall", "amx_memo_listall", ADMIN_IMMUNITY, " - list all registered entries")
register_concmd("amx_memo_rename", "amx_memo_rename", ADMIN_IMMUNITY, "<listname> <newlistname> - renames a registered entry")
register_concmd("amx_memo_whosip", "amx_memo_whosip", ADMIN_IMMUNITY, "<ip> - looks up the owner of the given ip")
register_concmd("amx_memo_add", "amx_memo_add", ADMIN_IMMUNITY, "<name> <listname> - adds a new entry to the registry")
register_concmd("amx_memo_list", "amx_memo_list", ADMIN_IMMUNITY, " - performs who on all players")
register_concmd("amx_memo_ban", "amx_memo_ban", ADMIN_IMMUNITY, "<listname> - bans the user's ip")
register_concmd("amx_memo_unban", "amx_memo_unban", ADMIN_IMMUNITY, "<listname> - unbans the user's ip")
return PLUGIN_CONTINUE
}
public amx_memo_who(id, level, cid)
{
// check access
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
// get parameter
new param[32]
read_argv(1, param, 31)
// find user
new player = cmd_target(id, param, 2|8)
if (!player)
{
console_print(id, "Player not found")
return PLUGIN_HANDLED
}
// get ip and full name
new name[32]
new ip[32]
get_user_name(player, name, 31)
get_user_ip(player, ip, 31, 1)
// scan the file
new entry[64]
new entryip[32]
new entryname[32]
new line = 0
new chcount
do {
read_file("memo.txt", line, entry, 63, chcount)
strtok(entry, entryip, 31, entryname, 31, ':')
if (equal(ip, entryip))
{
// write scan result
console_print(id, "%s van voltakeppen %s [%s]", name, entryname, entryip)
return PLUGIN_HANDLED
}
line++
} while (!equal(entry, "*"))
// no entry found
console_print(id, "%s nem vagy a listan", name)
return PLUGIN_HANDLED
}
public amx_memo_listall(id, level, cid)
{
new line = 0
new entry[64]
new entryname[32]
new entryip[32]
new chcount
// get all records
do {
read_file("memo.txt", line, entry, 63, chcount)
if (!equal(entry, "*"))
{
// tokenize
strtok(entry, entryip, 31, entryname, 31, ':')
// print entry
console_print(id, "%s >>>> %s", entryip, entryname)
}
line++
} while (!equal(entry, "*"))
return PLUGIN_HANDLED
}
public amx_memo_rename(id, level, cid)
{
// check access
if (!cmd_access(id, level, cid, 3))
return PLUGIN_HANDLED
// get parameters
new oldname[32]
new newname[32]
read_argv(1, oldname, 31)
read_argv(2, newname, 31)
new line = 0
new entry[64]
new entryip[32]
new entryname[32]
new chcount
// scan the file for the entry
do {
read_file("memo.txt", line, entry, 63, chcount)
strtok(entry, entryip, 31, entryname, 31, ':')
// are we there yet?
if (equal(entryname, oldname))
{
// create new entry
entry = ""
strcat(entry, entryip, 63)
strcat(entry, ":", 63)
strcat(entry, newname, 63)
write_file("memo.txt", entry, line)
// write new entry
console_print(id, "%s [%s] atkereszteltek %s [%s]", oldname, entryip, newname, entryip)
return PLUGIN_HANDLED
}
line++
} while (!equal(entry, "*"))
// entry not found
console_print(id, "%s nem vagy a listan", oldname)
return PLUGIN_HANDLED
}
public amx_memo_whosip(id, level, cid)
{
// check access
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
// get parameters
new ip[32]
read_argv(1, ip, 31)
new entry[64]
new entryip[32]
new entryname[32]
new line = 0
new chcount
do {
read_file("memo.txt", line, entry, 63, chcount)
strtok(entry, entryip, 31, entryname, 31, ':')
if (equal(ip, entryip))
{
console_print(id, "A cim %s tartozik %s", entryip, entryname)
break
}
line++
} while (!equal(entry, "*"))
if (equal(entry, "*"))
{
console_print(id, "Cim %s nincs a listan", ip)
}
return PLUGIN_HANDLED
}
public amx_memo_add(id, level, cid)
{
// check access
if (!cmd_access(id, level, cid, 3))
return PLUGIN_HANDLED
// get parameters
new name[32]
new regname[32]
read_argv(1, name, 31)
read_argv(2, regname, 31)
// find user
new player = cmd_target(id, name, 2|8)
if (!player)
{
console_print(id, "Jatekos nem talalhato")
return PLUGIN_HANDLED
}
// get the full name
new fullname[32]
new ip[32]
get_user_name(player, fullname, 31)
get_user_ip(player, ip, 31, 1)
// add the user to the registry
new entry[64]
new entryip[32]
new entryname[32]
new line = 0
new chcount
do {
read_file("memo.txt", line, entry, 63, chcount)
strtok(entry, entryip, 31, entryname, 31, ':')
if (equal(entryip, ip))
{
console_print(id, "Nev %s mar a listan van %s [%s]", fullname, entryname, entryip)
return PLUGIN_HANDLED
}
line++
} while (!equal(entry,"*"))
entry = ""
strcat(entry, ip, 63)
strcat(entry, ":", 63)
strcat(entry, regname, 63)
write_file("memo.txt", entry, line-1)
write_file("memo.txt", "*", line)
console_print(id, "%s bovitette az ismert felhasznalokat dol %s [%s]", fullname, regname, ip)
return PLUGIN_HANDLED
}
public amx_memo_list(id, level, cid)
{
// check access
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
// get the player ids
new players[32]
new nrplayers
new player
get_players(players, nrplayers, "c")
// run through all ids
new i
for (i = 0; i < nrplayers; i++)
{
player = players[i]
// get ip and full name
new name[32]
new ip[32]
get_user_name(player, name, 31)
get_user_ip(player, ip, 31, 1)
// scan the file
new entry[64]
new entryip[32]
new entryname[32]
new line = 0
new chcount
do {
read_file("memo.txt", line, entry, 63, chcount)
strtok(entry, entryip, 31, entryname, 31, ':')
if (equal(ip, entryip))
{
// write scan result
console_print(id, "%s >>>> %s [%s]", name, entryname, entryip)
break
}
line++
} while (!equal(entry, "*"))
if (equal(entry, "*"))
{
// no entry found
console_print(id, "%s >>>> ..... [%s]", name, ip)
}
}
return PLUGIN_HANDLED
}
public amx_memo_ban(id, level, cid)
{
// check access
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
// get parameter
new name[32]
read_argv(1, name, 31)
// check if minutes were specified
new minutes[16] = "0"
if (read_argc() > 2)
read_argv(2, minutes, 15)
// find the ip from the registry
new entry[64]
new entryip[32]
new entryname[32]
new line = 0
new chcount
do {
read_file("memo.txt", line, entry, 63, chcount)
strtok(entry, entryip, 31, entryname, 31, ':')
if (equal(name, entryname))
{
server_cmd("addip ^"%s^" ^"%s^";wait;writeip", minutes, entryip)
if (equal (minutes, "0"))
console_print(id, "%s [%s] banolvan orokre", name, entryip)
else
console_print(id, "%s [%s] banolvna %s percre", name, entryip, minutes)
return PLUGIN_HANDLED
}
line++
} while (!equal(entry, "*"))
console_print(id, "%s nincs a listan", name);
return PLUGIN_HANDLED
}
public amx_memo_unban(id, level, cid)
{
// check access
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
// get parameter
new name[32]
read_argv(1, name, 31)
// find the ip from the registry
new entry[64]
new entryip[32]
new entryname[32]
new line = 0
new chcount
do {
read_file("memo.txt", line, entry, 63, chcount)
strtok(entry, entryip, 31, entryname, 31, ':')
if (equal(name, entryname))
{
server_cmd("iptorlese ^"%s^";writeip", entryip)
console_print(id, "%s [%s] Tiltasfeloldasa", name, entryip)
return PLUGIN_HANDLED
}
line++
} while (!equal(entry, "*"))
console_print(id, "%s nincs a listan", name);
return PLUGIN_HANDLED
}