From 0a4cd13622093f17f09cd1084898032af830a215 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Wed, 8 Oct 2014 21:49:00 +0200 Subject: [PATCH] Plmenu: replace len hardcoded content by charsmax --- plugins/dod/plmenu.sma | 160 ++++++++++++++++++++--------------------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/plugins/dod/plmenu.sma b/plugins/dod/plmenu.sma index 1bd3f420..0ac8cca5 100755 --- a/plugins/dod/plmenu.sma +++ b/plugins/dod/plmenu.sma @@ -59,8 +59,8 @@ public plugin_init() g_coloredMenus = colored_menus() new clcmds_ini_file[64] - get_configsdir(clcmds_ini_file, 63) - format(clcmds_ini_file, 63, "%s/clcmds.ini", clcmds_ini_file) + get_configsdir(clcmds_ini_file, charsmax(clcmds_ini_file)) + format(clcmds_ini_file, charsmax(clcmds_ini_file), "%s/clcmds.ini", clcmds_ini_file) load_settings(clcmds_ini_file) } @@ -117,10 +117,10 @@ public actionBanMenu(id, key) new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key] new name[MAX_NAME_LENGTH], name2[MAX_NAME_LENGTH], authid[32], authid2[32] - get_user_name(player, name2, 31) - get_user_authid(id, authid, 31) - get_user_authid(player, authid2, 31) - get_user_name(id, name, 31) + get_user_name(player, name2, charsmax(name2)) + get_user_authid(id, authid, charsmax(authid)) + get_user_authid(player, authid2, charsmax(authid2)) + get_user_name(id, name, charsmax(name)) new userid2 = get_user_userid(player) log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%d^")", name, get_user_userid(id), authid, name2, userid2, authid2, g_menuSettings[id]) @@ -136,7 +136,7 @@ public actionBanMenu(id, key) else { new tempTime[32]; - formatex(tempTime,sizeof(tempTime)-1,"%d",g_menuSettings[id]); + formatex(tempTime,charsmax(tempTime),"%d",g_menuSettings[id]); client_print(0, print_chat, "%L %s: %L %s %L", LANG_PLAYER, "ADMIN", name, LANG_PLAYER, "BAN", name2, LANG_PLAYER, "FOR_MIN", tempTime); } } @@ -149,7 +149,7 @@ public actionBanMenu(id, key) else { new tempTime[32]; - formatex(tempTime,sizeof(tempTime)-1,"%d",g_menuSettings[id]); + formatex(tempTime,charsmax(tempTime),"%d",g_menuSettings[id]); client_print(0, print_chat, "%L: %L %s %L", LANG_PLAYER, "ADMIN", LANG_PLAYER, "BAN", name2, LANG_PLAYER, "FOR_MIN", tempTime); } } @@ -158,7 +158,7 @@ public actionBanMenu(id, key) if (equal("4294967295", authid2)) { new ipa[32] - get_user_ip(player, ipa, 31, 1) + get_user_ip(player, ipa, charsmax(ipa), 1) server_cmd("addip %d %s;writeip", g_menuSettings[id], ipa) if( g_tempBans ) { @@ -199,7 +199,7 @@ displayBanMenu(id,pos) 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, "BAN_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0 ))) + new len = format(menuBody,charsmax(menuBody), g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "BAN_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0 ))) new end = start + 7 new keys = MENU_KEY_0|MENU_KEY_8 @@ -210,38 +210,38 @@ displayBanMenu(id,pos) for (new a = start; a < end; ++a) { i = g_menuPlayers[id][a] - get_user_name(i, name, 31) + get_user_name(i, name, charsmax(name)) if (is_user_bot(i) || access(i, ADMIN_IMMUNITY)) { ++b if (g_coloredMenus) - len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name) + len += format(menuBody[len], charsmax(menuBody)-len, "\d%d. %s^n\w", b, name) else - len += format(menuBody[len], 511-len, "#. %s^n", name) + len += format(menuBody[len], charsmax(menuBody)-len, "#. %s^n", name) } else { keys |= (1<<%s><>^" slap with %d damage ^"%s<%d><%s><>^"", @@ -337,7 +337,7 @@ displaySlapMenu(id,pos) 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, "SLAP_SLAY_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0 ))) + new len = format(menuBody, charsmax(menuBody), g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "SLAP_SLAY_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0 ))) new end = start + 7 new keys = MENU_KEY_0|MENU_KEY_8 @@ -347,38 +347,38 @@ displaySlapMenu(id,pos) for (new a = start; a < end; ++a) { i = g_menuPlayers[id][a] - get_user_name(i,name,31) - get_user_team(i,team,7) + get_user_name(i,name,charsmax(name)) + get_user_team(i,team,charsmax(team)) if (!is_user_alive(i) || access(i, ADMIN_IMMUNITY)) { ++b if (g_coloredMenus) - len += format(menuBody[len], 511-len, "\d%d. %s\R%s^n\w", b, name, team) + len += format(menuBody[len], charsmax(menuBody)-len, "\d%d. %s\R%s^n\w", b, name, team) else - len += format(menuBody[len], 511-len, "#. %s %s^n", name, team) + len += format(menuBody[len], charsmax(menuBody)-len, "#. %s %s^n", name, team) } else { keys |= (1<<%s><>^" kick ^"%s<%d><%s><>^"", @@ -446,7 +446,7 @@ displayKickMenu(id, pos) 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, "KICK_MENU", pos + 1, (g_menuPlayersNum[id] / 8 + ((g_menuPlayersNum[id] % 8) ? 1 : 0 ))) + new len = format(menuBody, charsmax(menuBody), g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "KICK_MENU", pos + 1, (g_menuPlayersNum[id] / 8 + ((g_menuPlayersNum[id] % 8) ? 1 : 0 ))) new end = start + 8 new keys = MENU_KEY_0 @@ -457,33 +457,33 @@ displayKickMenu(id, pos) for (new a = start; a < end; ++a) { i = g_menuPlayers[id][a] - get_user_name(i, name, 31) + get_user_name(i, name, charsmax(name)) if (access(i, ADMIN_IMMUNITY)) { ++b if (g_coloredMenus) - len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name) + len += format(menuBody[len], charsmax(menuBody)-len, "\d%d. %s^n\w", b, name) else - len += format(menuBody[len], 511-len, "#. %s^n", name) + len += format(menuBody[len], charsmax(menuBody)-len, "#. %s^n", name) } else { keys |= (1<<%s><>^" transfer ^"%s<%d><%s><>^" (team ^"%s^")", name,get_user_userid(id),authid, name2,get_user_userid(player),authid2, g_menuOption[id] ? "Allies" : "Axis" ) @@ -547,7 +547,7 @@ displayTeamMenu(id, pos) 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, "TEAM_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0 ))) + new len = format(menuBody, charsmax(menuBody), g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "TEAM_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0 ))) new end = start + 7 new keys = MENU_KEY_0|MENU_KEY_8 @@ -558,36 +558,36 @@ displayTeamMenu(id, pos) for (new a = start; a < end; ++a) { i = g_menuPlayers[id][a] - get_user_name(i, name, 31) - iteam = get_user_team(i, team, 7) + get_user_name(i, name, charsmax(name)) + iteam = get_user_team(i, team, charsmax(team)) if ((iteam == (g_menuOption[id] ? 1 : 2)) || access(i, ADMIN_IMMUNITY)) { ++b if (g_coloredMenus) - len += format(menuBody[len], 511-len, "\d%d. %s\R%s^n\w", b, name, team) + len += format(menuBody[len], charsmax(menuBody)-len, "\d%d. %s\R%s^n\w", b, name, team) else - len += format(menuBody[len], 511-len, "#. %s %s^n", name, team) + len += format(menuBody[len], charsmax(menuBody)-len, "#. %s %s^n", name, team) } else { keys |= (1<= 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, "CL_CMD_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0 ))) + new len = format(menuBody, charsmax(menuBody), g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "CL_CMD_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0 ))) new end = start + 7 new keys = MENU_KEY_0|MENU_KEY_8 @@ -669,38 +669,38 @@ displayClcmdMenu(id, pos) for (new a = start; a < end; ++a) { i = g_menuPlayers[id][a] - get_user_name(i, name, 31) + get_user_name(i, name, charsmax(name)) if (!g_menuSelectNum[id] || access(i, ADMIN_IMMUNITY)) { ++b if (g_coloredMenus) - len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name) + len += format(menuBody[len], charsmax(menuBody)-len, "\d%d. %s^n\w", b, name) else - len += format(menuBody[len], 511-len, "#. %s^n", name) + len += format(menuBody[len], charsmax(menuBody)-len, "#. %s^n", name) } else { keys |= (1< 3) + if (parse(text, g_clcmdName[g_clcmdNum], charsmax(g_clcmdName), g_clcmdCmd[g_clcmdNum], charsmax(g_clcmdCmd), szFlags, charsmax(szFlags), szAccess, charsmax(szAccess)) > 3) { - while (replace(g_clcmdCmd[g_clcmdNum], 63, "\'", "^"")) + while (replace(g_clcmdCmd[g_clcmdNum], charsmax(g_clcmdCmd), "\'", "^"")) { // do nothing }