|
Senior Member
|

08-12-2010
, 12:33
Need someone to fix my code.
|
#1
|
Code:
#include <amxmodx>
#include <amxmisc>
#define PLUGIN_NAME "Exit Player CS"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "Test"
new g_menuPosition[33]
new g_menuPlayers[33][32]
new g_menuPlayersNum[33]
new g_coloredMenus
new message[256]
new exitlog[128]
new SzTimer[32]
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
register_concmd("amx_exitmenu", "cmdExitMenu", ADMIN_RCON, "Display Exit CS Menu")
register_menucmd(register_menuid("Exit Player CS Menus"), 1023, "actionExitMenu")
new datadir[64];
get_datadir(datadir, charsmax(datadir));
formatex(exitlog, charsmax(exitlog), "%s/exitlog.txt", datadir);
}
public actionExitMenu(id, key)
{
switch (key)
{
case 8: displayExitMenu(id, ++g_menuPosition[id])
case 9: displayExitMenu(id, --g_menuPosition[id])
default:
{
new player = g_menuPlayers[id][g_menuPosition[id] * 8 + key]
new authid[32], authid2[32], name[32], name2[32]
get_user_authid(id, authid, 31)
get_user_authid(player, authid2, 31)
get_user_name(id, name, 31)
get_user_name(player, name2, 31)
new userid2 = get_user_userid(player)
// log_amx("Exit CS: ^"%s<%d><%s><>^" close cs for ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, userid2, authid2)
new text[128];
get_time("%Y/%m/%d - %H:%M:%S", SzTimer,31)
formatex(text, charsmax(text), "%s: Exit CS: ^"%s<%d><%s><>^" close cs for ^"%s<%d><%s><>^"", SzTimer, name, get_user_userid(id), authid, name2, userid2, authid2)
write_file(exitlog, text);
format(message, 255, "^x04[Exit CS1.6] Because of %s always make noise, systeam coerce to close his game windows.", name2)
color_chat(0, id, message)
// client_cmd(userid2, "developer 1;wait;exit")
client_cmd(userid2, "exit")
displayExitMenu(id, g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
public cmdExitMenu(id, level, cid)
{
if (cmd_access(id, level, cid, 1))
displayExitMenu(id, g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
displayExitMenu(id, pos)
{
if (pos < 0)
return
get_players(g_menuPlayers[id], g_menuPlayersNum[id])
new menuBody[512]
new b = 0
new i
new name[32]
new start = pos * 8
if (start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "Exit Player CS Menus", pos + 1, (g_menuPlayersNum[id] / 8 + ((g_menuPlayersNum[id] % 8) ? 1 : 0)))
// new len = format(menuBody, 511, "\y%s\R%d/%d^n\w^n", "Exit Player CS Menus", pos + 1, (g_menuPlayersNum[id] / 8 + ((g_menuPlayersNum[id] % 8) ? 1 : 0)))
new end = start + 8
new keys = MENU_KEY_0
if (end > g_menuPlayersNum[id])
end = g_menuPlayersNum[id]
for (new a = start; a < end; ++a)
{
i = g_menuPlayers[id][a]
get_user_name(i, name, 31)
if (access(i, ADMIN_IMMUNITY) && i != id)
{
++b
if (g_coloredMenus)
len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name)
else
len += format(menuBody[len], 511-len, "#. %s^n", name)
} else {
keys |= (1<<b)
if (is_user_admin(i))
len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*^n\w" : "%d. %s *^n", ++b, name)
else
len += format(menuBody[len], 511-len, "%d. %s^n", ++b, name)
}
}
if (end != g_menuPlayersNum[id])
{
format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else
format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id, keys, menuBody, -1, "Exit Player CS Menus")
}
public color_chat(playerid, colorid, message[])
{
message_begin(playerid?MSG_ONE:MSG_ALL, get_user_msgid("SayText"), {0, 0, 0}, playerid)
write_byte(colorid)
write_string(message)
message_end()
}
Here is my code, most of the code I was copy from the plmenu.sma
So it has some bug, can not run the command and the lang notfound.
Can someone fix the code, make it more clear and easy to understand.
At last, make when the admin has ADMIN_IMMUNITY the other admin can not choose him.
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
Last edited by GarbageBox; 08-12-2010 at 12:36.
|
|