|
Senior Member
|

12-30-2008
, 07:01
Optymalization code.
|
#1
|
PHP Code:
/* Start menu admin */
public actionTestMenu(id, key) { switch (key) { case 7: { ++g_menuOption[id] g_menuOption[id] %= ArraySize(g_Testsettings); g_menuSettings[id] = ArrayGetCell(g_Testsettings, g_menuOption[id]); displayTestMenu(id, g_menuPosition[id]); } case 8: { if(gr_menu2[id]){ return PLUGIN_HANDLED } displayTestMenu(id, ++g_menuPosition[id]) } case 9: { if(gr_menu2[id]){ return PLUGIN_HANDLED } displayTestMenu(id, --g_menuPosition[id]) } default: { new m_player = g_menuPlayers[id][g_menuPosition[id] * 7 + key] new m_name2[32] new m_authid[32], m_authid2[32], m_name[32] get_user_name(m_player, m_name2, 31)
if (!is_user_alive(m_player)) { client_print(id, print_chat, "dead?") displayTestMenu(id, g_menuPosition[id]) return PLUGIN_HANDLED }
get_user_authid(id, m_authid, 31) get_user_authid(m_player, m_authid2, 31) get_user_name(id, m_name, 31)
if (!g_menuOption[id]) { client_cmd(id,"slot10") m_plejer = m_player if(!is_user_alive(m_plejer )) return PLUGIN_HANDLED //do something? /*---------*/ return PLUGIN_HANDLED }
displayTestMenu(id, g_menuPosition[id]) } } return PLUGIN_HANDLED }
displayTestMenu(id, pos) { if (pos < 0) return
get_players(g_menuPlayers[id], g_menuPlayersNum[id])
new menuBody[1024] new b = 0 new i new name[32], team[4] new start = pos * 7
if (start >= g_menuPlayersNum[id]) start = pos = g_menuPosition[id] = 0
new len = format(menuBody, 1023, "\yTest Admin Menu %d/%d\w^n^n", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7)))) new end = start + 7 new keys = MENU_KEY_0|MENU_KEY_8
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 (g_cstrike) { if (cs_get_user_team(i) == CS_TEAM_T) { copy(team, 3, "TE") } else if (cs_get_user_team(i) == CS_TEAM_CT) { copy(team, 3, "CT") } else { get_user_team(i, team, 3) } } else { get_user_team(i, team, 3) }*/
if (is_user_alive(i)) { keys |= (1<<b) if (is_user_admin(i)) len += format(menuBody[len], 1023-len, "\r%d. \w%s \r* \w ^n", ++b, name) else len += format(menuBody[len], 1023-len, "\r%d. \w%s ^n", ++b, name) }else if(!is_user_alive(i)){
if (is_user_admin(i)) len += format(menuBody[len], 1023-len, "\d%d. %s \r* \w ^n\w", ++b, name) else len += format(menuBody[len], 1023-len, "\d%d. %s ^n\w", ++b, name) } }
if (end != g_menuPlayersNum[id]) { format(menuBody[len], 1023-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT") keys |= MENU_KEY_9 } else format(menuBody[len], 1023-len, "^n0. %L", id, pos ? "BACK" : "EXIT") //menu_setprop(menuBody[len], MPROP_PERPAGE, 7);
show_menu(id, keys, menuBody, -1, "Admin Menu") }
public cmdTestMenu(id, level, cid) { //if (!cmd_access(id, level, cid, 1)) //return PLUGIN_HANDLED
g_menuOption[id] = 0
// should never happen, but failsafe g_menuSettings[id] = 0 //menu_setprop(displayTestMenu, MPROP_PERPAGE, 7); displayTestMenu(id, g_menuPosition[id] = 0)
return PLUGIN_HANDLED }
Hi,
I have problem, I made code like this but is strange/dirty/unoptymized code can somebody help me to change it? I got this code from some plugin try to do something but you can see it is not good code.
__________________
Aaaaaa!
|
|