From d2f909981a09e98f22956c0390622734744b4c8e Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sun, 18 May 2014 15:23:40 +0200 Subject: [PATCH 01/13] Telemenu: Use of float version of origin natives instead of integer version --- plugins/telemenu.sma | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/plugins/telemenu.sma b/plugins/telemenu.sma index d2d0b7a9..7c2874a8 100755 --- a/plugins/telemenu.sma +++ b/plugins/telemenu.sma @@ -34,13 +34,14 @@ #include #include -#include +#include -new g_menuPosition[33] -new g_menuPlayers[33][32] -new g_menuPlayersNum[33] -new g_menuOption[33] = {-1, ...} -new g_menuOrgin[33][3] +#define MAX_PLAYERS 32 + 1 +new g_menuPosition[MAX_PLAYERS] +new g_menuPlayers[MAX_PLAYERS][32] +new g_menuPlayersNum[MAX_PLAYERS] +new g_menuOption[MAX_PLAYERS] = {-1, ...} +new Float:g_menuOrigin[MAX_PLAYERS][3] new g_coloredMenus public plugin_init() @@ -67,8 +68,8 @@ public actionTelMenu(id, key) { if (g_menuOption[id] < 0) /* unlocking position for the first time */ g_menuOption[id] = 0 - - get_user_origin(id, g_menuOrgin[id]) + + pev(id, pev_origin, g_menuOrigin[id]) displayTelMenu(id, g_menuPosition[id]) } case 8: displayTelMenu(id, ++g_menuPosition[id]) @@ -77,7 +78,7 @@ public actionTelMenu(id, key) { new player = g_menuPlayers[id][g_menuPosition[id] * 6 + key] new name2[32] - + get_user_name(player, name2, 31) if (!is_user_alive(player)) @@ -89,12 +90,12 @@ public actionTelMenu(id, key) if (g_menuOption[id] > 0) { - set_user_origin(player, g_menuOrgin[id]) + engfunc(EngFunc_SetOrigin, player, g_menuOrigin[id]) } else { - new origin[3] - - get_user_origin(id, origin) - set_user_origin(player, origin) + new Float:f_origin[3] + + pev(id, pev_origin, f_origin) + engfunc(EngFunc_SetOrigin, player, f_origin) } new authid[32], authid2[32], name[32] @@ -105,17 +106,17 @@ public actionTelMenu(id, key) log_amx("Cmd: ^"%s<%d><%s><>^" teleport ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2) - show_activity_key("ADMIN_TELEPORT_1", "ADMIN_TELEPORT_2", name, name2); + show_activity_key("ADMIN_TELEPORT_1", "ADMIN_TELEPORT_2", name, name2) displayTelMenu(id, g_menuPosition[id]) } } - + return PLUGIN_HANDLED } displayTelMenu(id, pos) -{ +{ if (pos < 0) return @@ -146,14 +147,14 @@ displayTelMenu(id, pos) if (blockMenu || !is_user_alive(i) || (id != i && get_user_flags(i) & ADMIN_IMMUNITY)) { ++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< 0) // 1 { keys |= MENU_KEY_7 - len += format(menuBody[len], 511-len, "^n7. To location: %d %d %d^n", g_menuOrgin[id][0], g_menuOrgin[id][1], g_menuOrgin[id][2]) + len += format(menuBody[len], 511-len, "^n7. To location: %.0f %.0f %.0f^n", g_menuOrigin[id][0], g_menuOrigin[id][1], g_menuOrigin[id][2]) } else if (g_menuOption[id]) // -1 { From 9c93cd1283af54ea997a75c3ee17377b5f527666 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sun, 18 May 2014 15:32:45 +0200 Subject: [PATCH 02/13] Telemenu: Add the ability to teleport in crouched areas --- plugins/telemenu.sma | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/telemenu.sma b/plugins/telemenu.sma index 7c2874a8..bbdd69e6 100755 --- a/plugins/telemenu.sma +++ b/plugins/telemenu.sma @@ -90,11 +90,13 @@ public actionTelMenu(id, key) if (g_menuOption[id] > 0) { + set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) engfunc(EngFunc_SetOrigin, player, g_menuOrigin[id]) } else { new Float:f_origin[3] pev(id, pev_origin, f_origin) + set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) engfunc(EngFunc_SetOrigin, player, f_origin) } From 70071051504c3669b6de91b4f40219a1aab9be33 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sun, 18 May 2014 15:58:53 +0200 Subject: [PATCH 03/13] Telemenu: Add the ability to save the view and use it during teleportation --- plugins/telemenu.sma | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/telemenu.sma b/plugins/telemenu.sma index bbdd69e6..8ef68f72 100755 --- a/plugins/telemenu.sma +++ b/plugins/telemenu.sma @@ -42,6 +42,7 @@ new g_menuPlayers[MAX_PLAYERS][32] new g_menuPlayersNum[MAX_PLAYERS] new g_menuOption[MAX_PLAYERS] = {-1, ...} new Float:g_menuOrigin[MAX_PLAYERS][3] +new Float:g_menuVAngle[MAX_PLAYERS][3] new g_coloredMenus public plugin_init() @@ -70,6 +71,7 @@ public actionTelMenu(id, key) g_menuOption[id] = 0 pev(id, pev_origin, g_menuOrigin[id]) + pev(id, pev_v_angle, g_menuVAngle[id]) displayTelMenu(id, g_menuPosition[id]) } case 8: displayTelMenu(id, ++g_menuPosition[id]) @@ -92,12 +94,17 @@ public actionTelMenu(id, key) { set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) engfunc(EngFunc_SetOrigin, player, g_menuOrigin[id]) + set_pev(player, pev_angles, g_menuVAngle[id]) + set_pev(player, pev_fixangle, 1) } else { - new Float:f_origin[3] + new Float:f_origin[3], Float:f_vangle[3] pev(id, pev_origin, f_origin) + pev(id, pev_v_angle, f_vangle) set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) engfunc(EngFunc_SetOrigin, player, f_origin) + set_pev(player, pev_angles, f_vangle) + set_pev(player, pev_fixangle, 1) } new authid[32], authid2[32], name[32] From a6e3b57848114e18754d1f1509305edb87eed44b Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sun, 18 May 2014 16:11:13 +0200 Subject: [PATCH 04/13] Telemenu: Add charsmax in place of hardcoded buffer lengths --- plugins/telemenu.sma | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/plugins/telemenu.sma b/plugins/telemenu.sma index 8ef68f72..a3fd1aa4 100755 --- a/plugins/telemenu.sma +++ b/plugins/telemenu.sma @@ -81,7 +81,7 @@ public actionTelMenu(id, key) new player = g_menuPlayers[id][g_menuPosition[id] * 6 + key] new name2[32] - get_user_name(player, name2, 31) + get_user_name(player, name2, charsmax(name2)) if (!is_user_alive(player)) { @@ -109,9 +109,9 @@ public actionTelMenu(id, key) new authid[32], authid2[32], name[32] - get_user_authid(id, authid, 31) - get_user_authid(player, authid2, 31) - get_user_name(id, name, 31) + get_user_authid(id, authid, charsmax(authid)) + get_user_authid(player, authid2, charsmax(authid2)) + get_user_name(id, name, charsmax(name)) log_amx("Cmd: ^"%s<%d><%s><>^" teleport ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2) @@ -141,7 +141,7 @@ displayTelMenu(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, "TELE_MENU", pos + 1, (g_menuPlayersNum[id] / 6 + ((g_menuPlayersNum[id] % 6) ? 1 : 0))) + new len = format(menuBody, charsmax(menuBody), g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "TELE_MENU", pos + 1, (g_menuPlayersNum[id] / 6 + ((g_menuPlayersNum[id] % 6) ? 1 : 0))) new end = start + 6 new keys = MENU_KEY_0|MENU_KEY_8 @@ -151,51 +151,51 @@ displayTelMenu(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 (blockMenu || !is_user_alive(i) || (id != i && get_user_flags(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< 0) // 1 { keys |= MENU_KEY_7 - len += format(menuBody[len], 511-len, "^n7. To location: %.0f %.0f %.0f^n", g_menuOrigin[id][0], g_menuOrigin[id][1], g_menuOrigin[id][2]) + len += format(menuBody[len], charsmax(menuBody)-len, "^n7. To location: %.0f %.0f %.0f^n", g_menuOrigin[id][0], g_menuOrigin[id][1], g_menuOrigin[id][2]) } else if (g_menuOption[id]) // -1 { if (g_coloredMenus) - len += format(menuBody[len], 511-len, "^n\d7. %L^n\w", id, "CUR_LOC") + len += format(menuBody[len], charsmax(menuBody)-len, "^n\d7. %L^n\w", id, "CUR_LOC") else - len += format(menuBody[len], 511-len, "^n#. %L^n", id, "CUR_LOC") + len += format(menuBody[len], charsmax(menuBody)-len, "^n#. %L^n", id, "CUR_LOC") } else { // 0 keys |= MENU_KEY_7 - len += format(menuBody[len], 511-len, "^n7. %L^n", id, "CUR_LOC") + len += format(menuBody[len], charsmax(menuBody)-len, "^n7. %L^n", id, "CUR_LOC") } - len += format(menuBody[len], 511-len, "8. %L^n", id, "SAVE_LOC") + len += format(menuBody[len], charsmax(menuBody)-len, "8. %L^n", id, "SAVE_LOC") if (end != g_menuPlayersNum[id]) { - format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT") + format(menuBody[len], charsmax(menuBody)-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") + format(menuBody[len], charsmax(menuBody)-len, "^n0. %L", id, pos ? "BACK" : "EXIT") show_menu(id, keys, menuBody, -1, "Teleport Menu") } From b3d1b49faba8795855baf21bc95d0c394076e9aa Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sun, 18 May 2014 16:20:40 +0200 Subject: [PATCH 05/13] Telemenu: Switch format to formatex --- plugins/telemenu.sma | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/plugins/telemenu.sma b/plugins/telemenu.sma index a3fd1aa4..6c34a5bd 100755 --- a/plugins/telemenu.sma +++ b/plugins/telemenu.sma @@ -141,7 +141,7 @@ displayTelMenu(id, pos) if (start >= g_menuPlayersNum[id]) start = pos = g_menuPosition[id] = 0 - new len = format(menuBody, charsmax(menuBody), g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "TELE_MENU", pos + 1, (g_menuPlayersNum[id] / 6 + ((g_menuPlayersNum[id] % 6) ? 1 : 0))) + new len = formatex(menuBody, charsmax(menuBody), g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "TELE_MENU", pos + 1, (g_menuPlayersNum[id] / 6 + ((g_menuPlayersNum[id] % 6) ? 1 : 0))) new end = start + 6 new keys = MENU_KEY_0|MENU_KEY_8 @@ -158,44 +158,44 @@ displayTelMenu(id, pos) ++b if (g_coloredMenus) - len += format(menuBody[len], charsmax(menuBody)-len, "\d%d. %s^n\w", b, name) + len += formatex(menuBody[len], charsmax(menuBody)-len, "\d%d. %s^n\w", b, name) else - len += format(menuBody[len], charsmax(menuBody)-len, "#. %s^n", name) + len += formatex(menuBody[len], charsmax(menuBody)-len, "#. %s^n", name) } else { keys |= (1< 0) // 1 { keys |= MENU_KEY_7 - len += format(menuBody[len], charsmax(menuBody)-len, "^n7. To location: %.0f %.0f %.0f^n", g_menuOrigin[id][0], g_menuOrigin[id][1], g_menuOrigin[id][2]) + len += formatex(menuBody[len], charsmax(menuBody)-len, "^n7. To location: %.0f %.0f %.0f^n", g_menuOrigin[id][0], g_menuOrigin[id][1], g_menuOrigin[id][2]) } else if (g_menuOption[id]) // -1 { if (g_coloredMenus) - len += format(menuBody[len], charsmax(menuBody)-len, "^n\d7. %L^n\w", id, "CUR_LOC") + len += formatex(menuBody[len], charsmax(menuBody)-len, "^n\d7. %L^n\w", id, "CUR_LOC") else - len += format(menuBody[len], charsmax(menuBody)-len, "^n#. %L^n", id, "CUR_LOC") + len += formatex(menuBody[len], charsmax(menuBody)-len, "^n#. %L^n", id, "CUR_LOC") } else { // 0 keys |= MENU_KEY_7 - len += format(menuBody[len], charsmax(menuBody)-len, "^n7. %L^n", id, "CUR_LOC") + len += formatex(menuBody[len], charsmax(menuBody)-len, "^n7. %L^n", id, "CUR_LOC") } - len += format(menuBody[len], charsmax(menuBody)-len, "8. %L^n", id, "SAVE_LOC") + len += formatex(menuBody[len], charsmax(menuBody)-len, "8. %L^n", id, "SAVE_LOC") if (end != g_menuPlayersNum[id]) { - format(menuBody[len], charsmax(menuBody)-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT") + formatex(menuBody[len], charsmax(menuBody)-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT") keys |= MENU_KEY_9 } else - format(menuBody[len], charsmax(menuBody)-len, "^n0. %L", id, pos ? "BACK" : "EXIT") + formatex(menuBody[len], charsmax(menuBody)-len, "^n0. %L", id, pos ? "BACK" : "EXIT") show_menu(id, keys, menuBody, -1, "Teleport Menu") } From 914ae9e0d1a7bd4c098364f2534a2f92ee84c53a Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Mon, 19 May 2014 13:52:21 +0200 Subject: [PATCH 06/13] Telemenu: Improve ducking feature Apply ducking state on teleported player only when the teleportation point is saved by a ducking player. This feature fix possibles errors that could happen with games that don't use crouch, like ESF, NNK... And for game like Counter-Strike 1.6, this is more logic. --- plugins/telemenu.sma | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/plugins/telemenu.sma b/plugins/telemenu.sma index 6c34a5bd..d9620810 100755 --- a/plugins/telemenu.sma +++ b/plugins/telemenu.sma @@ -45,6 +45,11 @@ new Float:g_menuOrigin[MAX_PLAYERS][3] new Float:g_menuVAngle[MAX_PLAYERS][3] new g_coloredMenus +new g_bDuckingStateSaved +#define SaveInDuckingState(%1) g_bDuckingStateSaved |= 1<<(%1&31) +#define SaveNoDuckingState(%1) g_bDuckingStateSaved &= ~(1<<(%1&31)) +#define HasInDuckingStateSaved(%1) g_bDuckingStateSaved & 1<<(%1&31) + public plugin_init() { register_plugin("Teleport Menu", AMXX_VERSION_STR, "AMXX Dev Team") @@ -72,6 +77,10 @@ public actionTelMenu(id, key) pev(id, pev_origin, g_menuOrigin[id]) pev(id, pev_v_angle, g_menuVAngle[id]) + if (pev(id, pev_flags) & FL_DUCKING && is_user_alive(id)) + SaveInDuckingState(id) + else + SaveNoDuckingState(id) displayTelMenu(id, g_menuPosition[id]) } case 8: displayTelMenu(id, ++g_menuPosition[id]) @@ -92,7 +101,8 @@ public actionTelMenu(id, key) if (g_menuOption[id] > 0) { - set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) + if ( HasInDuckingStateSaved(id) ) + set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) engfunc(EngFunc_SetOrigin, player, g_menuOrigin[id]) set_pev(player, pev_angles, g_menuVAngle[id]) set_pev(player, pev_fixangle, 1) @@ -101,7 +111,8 @@ public actionTelMenu(id, key) pev(id, pev_origin, f_origin) pev(id, pev_v_angle, f_vangle) - set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) + if ( HasInDuckingStateSaved(id) ) + set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) engfunc(EngFunc_SetOrigin, player, f_origin) set_pev(player, pev_angles, f_vangle) set_pev(player, pev_fixangle, 1) From d3bae33c6467a25fdb2a3004587b0f709de133c1 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Mon, 19 May 2014 14:03:31 +0200 Subject: [PATCH 07/13] Telemenu: Plugin style compliancy --- plugins/telemenu.sma | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/telemenu.sma b/plugins/telemenu.sma index d9620810..98f1ef71 100755 --- a/plugins/telemenu.sma +++ b/plugins/telemenu.sma @@ -101,7 +101,7 @@ public actionTelMenu(id, key) if (g_menuOption[id] > 0) { - if ( HasInDuckingStateSaved(id) ) + if (HasInDuckingStateSaved(id)) set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) engfunc(EngFunc_SetOrigin, player, g_menuOrigin[id]) set_pev(player, pev_angles, g_menuVAngle[id]) @@ -111,7 +111,7 @@ public actionTelMenu(id, key) pev(id, pev_origin, f_origin) pev(id, pev_v_angle, f_vangle) - if ( HasInDuckingStateSaved(id) ) + if (HasInDuckingStateSaved(id)) set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) engfunc(EngFunc_SetOrigin, player, f_origin) set_pev(player, pev_angles, f_vangle) From 44b4ff6f0573f6b64a3f4d7d55c28495da01aa65 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Wed, 21 May 2014 00:59:48 +0200 Subject: [PATCH 08/13] Telemenu: Fix view_ofs not correctly set at teleportation --- plugins/telemenu.sma | 66 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/plugins/telemenu.sma b/plugins/telemenu.sma index 98f1ef71..8017c053 100755 --- a/plugins/telemenu.sma +++ b/plugins/telemenu.sma @@ -101,8 +101,37 @@ public actionTelMenu(id, key) if (g_menuOption[id] > 0) { - if (HasInDuckingStateSaved(id)) - set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) + if ( HasInDuckingStateSaved(id) ) + { + new sz_modname[16] + + get_modname(sz_modname, charsmax(sz_modname)) + if (equal(sz_modname, "cstrike") // Counter-Strike 1.6 + || equal(sz_modname, "czero") // Counter-Strike: Condition Zero + || equal(sz_modname, "valve") // Half-Life + || equal(sz_modname, "tfc") // Team Fortress Classic + || equal(sz_modname, "gearbox")) // Half-Life: Opposing Force + { + set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) + set_pev(id, pev_view_ofs, {0.0, 0.0, 12.0}) + } + else if (equal(sz_modname, "dod")) // Day of Defeat + { + set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) + set_pev(id, pev_view_ofs, {0.0, 0.0, 18.0}) + } + else if (equal(sz_modname, "ns")) // Natural Selection + { + set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) + // Natural Selection handle view_ofs by itself + } + else if (equal(sz_modname, "ts")) // The Specialists + { + set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) + set_pev(id, pev_view_ofs, {0.0, 0.0, 16.0}) + } + // Don't add this feature for mods that we don't know how their view_ofs work + } engfunc(EngFunc_SetOrigin, player, g_menuOrigin[id]) set_pev(player, pev_angles, g_menuVAngle[id]) set_pev(player, pev_fixangle, 1) @@ -111,8 +140,37 @@ public actionTelMenu(id, key) pev(id, pev_origin, f_origin) pev(id, pev_v_angle, f_vangle) - if (HasInDuckingStateSaved(id)) - set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) + if ( HasInDuckingStateSaved(id) ) + { + new sz_modname[16] + + get_modname(sz_modname, charsmax(sz_modname)) + if (equal(sz_modname, "cstrike") // Counter-Strike 1.6 + || equal(sz_modname, "czero") // Counter-Strike: Condition Zero + || equal(sz_modname, "valve") // Half-Life + || equal(sz_modname, "tfc") // Team Fortress Classic + || equal(sz_modname, "gearbox")) // Half-Life: Opposing Force + { + set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) + set_pev(id, pev_view_ofs, {0.0, 0.0, 12.0}) + } + else if (equal(sz_modname, "dod")) // Day of Defeat + { + set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) + set_pev(id, pev_view_ofs, {0.0, 0.0, 18.0}) + } + else if (equal(sz_modname, "ns")) // Natural Selection + { + set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) + // Natural Selection handle view_ofs by itself + } + else if (equal(sz_modname, "ts")) // The Specialists + { + set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) + set_pev(id, pev_view_ofs, {0.0, 0.0, 16.0}) + } + // Don't add this feature for mods that we don't know how their view_ofs work + } engfunc(EngFunc_SetOrigin, player, f_origin) set_pev(player, pev_angles, f_vangle) set_pev(player, pev_fixangle, 1) From aa67fae7b9c34f85d1da98f057f7621e05afbbdc Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sat, 24 May 2014 15:53:30 +0200 Subject: [PATCH 09/13] Telemenu: Fix some bugs and add some improvements Bugfixes - a typo error induced by me, id instead of player - The second teleportation way of this plugin can only be done when the menuactor is not alive. There is no crouch in death mod or spectator mod, so i remove this useless call. (Line 134 - 139) Improvements : - Check mod VEC_DUCK_VIEW only one time. - Removal of code duplication --- plugins/telemenu.sma | 108 +++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 66 deletions(-) diff --git a/plugins/telemenu.sma b/plugins/telemenu.sma index 8017c053..da36d90b 100755 --- a/plugins/telemenu.sma +++ b/plugins/telemenu.sma @@ -75,12 +75,13 @@ public actionTelMenu(id, key) if (g_menuOption[id] < 0) /* unlocking position for the first time */ g_menuOption[id] = 0 - pev(id, pev_origin, g_menuOrigin[id]) - pev(id, pev_v_angle, g_menuVAngle[id]) + getTeleportData(id, g_menuOrigin[id], g_menuVAngle[id]) + if (pev(id, pev_flags) & FL_DUCKING && is_user_alive(id)) SaveInDuckingState(id) else SaveNoDuckingState(id) + displayTelMenu(id, g_menuPosition[id]) } case 8: displayTelMenu(id, ++g_menuPosition[id]) @@ -101,79 +102,41 @@ public actionTelMenu(id, key) if (g_menuOption[id] > 0) { - if ( HasInDuckingStateSaved(id) ) + if (HasInDuckingStateSaved(id)) { - new sz_modname[16] + static Float:VEC_DUCK_VIEW[3] = -1.0 - get_modname(sz_modname, charsmax(sz_modname)) - if (equal(sz_modname, "cstrike") // Counter-Strike 1.6 - || equal(sz_modname, "czero") // Counter-Strike: Condition Zero - || equal(sz_modname, "valve") // Half-Life - || equal(sz_modname, "tfc") // Team Fortress Classic - || equal(sz_modname, "gearbox")) // Half-Life: Opposing Force + if (VEC_DUCK_VIEW[0]) { - set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) - set_pev(id, pev_view_ofs, {0.0, 0.0, 12.0}) + VEC_DUCK_VIEW[0] = 0.0 + + new modname[16] + + get_modname(modname, charsmax(modname)) + if (equal(modname, "cstrike") // Counter-Strike 1.6 + || equal(modname, "czero") // Counter-Strike: Condition Zero + || equal(modname, "valve") // Half-Life + || equal(modname, "tfc") // Team Fortress Classic + || equal(modname, "ns") // Natural Selection + || equal(modname, "gearbox")) // Half-Life: Opposing Force + VEC_DUCK_VIEW[2] = 12.0 + else if (equal(modname, "dod")) // Day of Defeat + VEC_DUCK_VIEW[2] = 18.0 + else if (equal(modname, "ts")) // The Specialists + VEC_DUCK_VIEW[2] = 16.0 } - else if (equal(sz_modname, "dod")) // Day of Defeat + if (VEC_DUCK_VIEW[2]) { - set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) - set_pev(id, pev_view_ofs, {0.0, 0.0, 18.0}) + set_pev(id, pev_flags, pev(id, pev_flags) | FL_DUCKING) + set_pev(id, pev_view_ofs, VEC_DUCK_VIEW) } - else if (equal(sz_modname, "ns")) // Natural Selection - { - set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) - // Natural Selection handle view_ofs by itself - } - else if (equal(sz_modname, "ts")) // The Specialists - { - set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) - set_pev(id, pev_view_ofs, {0.0, 0.0, 16.0}) - } - // Don't add this feature for mods that we don't know how their view_ofs work } - engfunc(EngFunc_SetOrigin, player, g_menuOrigin[id]) - set_pev(player, pev_angles, g_menuVAngle[id]) - set_pev(player, pev_fixangle, 1) + doTeleport(player, g_menuOrigin[id], g_menuVAngle[id]) } else { - new Float:f_origin[3], Float:f_vangle[3] + new Float:origin[3], Float:vAngle[3] - pev(id, pev_origin, f_origin) - pev(id, pev_v_angle, f_vangle) - if ( HasInDuckingStateSaved(id) ) - { - new sz_modname[16] - - get_modname(sz_modname, charsmax(sz_modname)) - if (equal(sz_modname, "cstrike") // Counter-Strike 1.6 - || equal(sz_modname, "czero") // Counter-Strike: Condition Zero - || equal(sz_modname, "valve") // Half-Life - || equal(sz_modname, "tfc") // Team Fortress Classic - || equal(sz_modname, "gearbox")) // Half-Life: Opposing Force - { - set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) - set_pev(id, pev_view_ofs, {0.0, 0.0, 12.0}) - } - else if (equal(sz_modname, "dod")) // Day of Defeat - { - set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) - set_pev(id, pev_view_ofs, {0.0, 0.0, 18.0}) - } - else if (equal(sz_modname, "ns")) // Natural Selection - { - set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) - // Natural Selection handle view_ofs by itself - } - else if (equal(sz_modname, "ts")) // The Specialists - { - set_pev(player, pev_flags, pev(player, pev_flags) | FL_DUCKING) - set_pev(id, pev_view_ofs, {0.0, 0.0, 16.0}) - } - // Don't add this feature for mods that we don't know how their view_ofs work - } - engfunc(EngFunc_SetOrigin, player, f_origin) - set_pev(player, pev_angles, f_vangle) - set_pev(player, pev_fixangle, 1) + getTeleportData(id, origin, vAngle) + doTeleport(player, origin, vAngle) } new authid[32], authid2[32], name[32] @@ -193,6 +156,19 @@ public actionTelMenu(id, key) return PLUGIN_HANDLED } +getTeleportData(id, Float:origin[3], Float:vAngle[3]) +{ + pev(id, pev_origin, origin) + pev(id, pev_v_angle, vAngle) +} + +doTeleport(id, const Float:origin[3], const Float:vAngle[3]) +{ + engfunc(EngFunc_SetOrigin, id, origin) + set_pev(id, pev_angles, vAngle) + set_pev(id, pev_fixangle, 1) +} + displayTelMenu(id, pos) { if (pos < 0) From 2ca61e2de23bb9a01a504708cf9e71b555f448b1 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sat, 24 May 2014 18:30:02 +0200 Subject: [PATCH 10/13] Telemenu: Fix bad array usage --- plugins/telemenu.sma | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/telemenu.sma b/plugins/telemenu.sma index da36d90b..fb1c7e04 100755 --- a/plugins/telemenu.sma +++ b/plugins/telemenu.sma @@ -104,12 +104,10 @@ public actionTelMenu(id, key) { if (HasInDuckingStateSaved(id)) { - static Float:VEC_DUCK_VIEW[3] = -1.0 + static Float:VEC_DUCK_VIEW[3] = {0.0, 0.0, -1.0} - if (VEC_DUCK_VIEW[0]) + if (VEC_DUCK_VIEW[2] == -1.0) { - VEC_DUCK_VIEW[0] = 0.0 - new modname[16] get_modname(modname, charsmax(modname)) @@ -124,8 +122,10 @@ public actionTelMenu(id, key) VEC_DUCK_VIEW[2] = 18.0 else if (equal(modname, "ts")) // The Specialists VEC_DUCK_VIEW[2] = 16.0 + else + VEC_DUCK_VIEW[0] = 0.0 } - if (VEC_DUCK_VIEW[2]) + if (VEC_DUCK_VIEW[2] > 0.0) { set_pev(id, pev_flags, pev(id, pev_flags) | FL_DUCKING) set_pev(id, pev_view_ofs, VEC_DUCK_VIEW) From 1b4d0c79654df463a57e934952888f6e7479f909 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sat, 24 May 2014 18:35:06 +0200 Subject: [PATCH 11/13] Telemenu: Remove some TAB before comments for readability --- plugins/telemenu.sma | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/telemenu.sma b/plugins/telemenu.sma index fb1c7e04..c81ddc94 100755 --- a/plugins/telemenu.sma +++ b/plugins/telemenu.sma @@ -112,10 +112,10 @@ public actionTelMenu(id, key) get_modname(modname, charsmax(modname)) if (equal(modname, "cstrike") // Counter-Strike 1.6 - || equal(modname, "czero") // Counter-Strike: Condition Zero - || equal(modname, "valve") // Half-Life - || equal(modname, "tfc") // Team Fortress Classic - || equal(modname, "ns") // Natural Selection + || equal(modname, "czero") // Counter-Strike: Condition Zero + || equal(modname, "valve") // Half-Life + || equal(modname, "tfc") // Team Fortress Classic + || equal(modname, "ns") // Natural Selection || equal(modname, "gearbox")) // Half-Life: Opposing Force VEC_DUCK_VIEW[2] = 12.0 else if (equal(modname, "dod")) // Day of Defeat From 94e0021e78c2f4aec141525093adee8852c51e93 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sun, 25 May 2014 11:50:11 +0200 Subject: [PATCH 12/13] Telemenu: Fix a typo error --- plugins/telemenu.sma | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/telemenu.sma b/plugins/telemenu.sma index c81ddc94..25e1ecec 100755 --- a/plugins/telemenu.sma +++ b/plugins/telemenu.sma @@ -123,7 +123,7 @@ public actionTelMenu(id, key) else if (equal(modname, "ts")) // The Specialists VEC_DUCK_VIEW[2] = 16.0 else - VEC_DUCK_VIEW[0] = 0.0 + VEC_DUCK_VIEW[2] = 0.0 } if (VEC_DUCK_VIEW[2] > 0.0) { From 18b91278dbbf2dec63ae863d9016579598bb60df Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Thu, 3 Jul 2014 22:19:20 +0200 Subject: [PATCH 13/13] Telemenu: Remove ducking feature for Natural Selection because of incompatibilities The main reason to remove this feature and let it behave like normal in Natural Selection is the fact that, in this game, there is different classes. Humans can crouch when some (small) aliens can't and normally never get the FL_DUCKING flag. There is a small chance to create a teleportion point ducking as human and teleport an alien who will get an unsual flag for an alien. So to don't mess with the game, this feature is disabled. --- plugins/telemenu.sma | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/telemenu.sma b/plugins/telemenu.sma index 25e1ecec..aaf6da68 100755 --- a/plugins/telemenu.sma +++ b/plugins/telemenu.sma @@ -115,7 +115,6 @@ public actionTelMenu(id, key) || equal(modname, "czero") // Counter-Strike: Condition Zero || equal(modname, "valve") // Half-Life || equal(modname, "tfc") // Team Fortress Classic - || equal(modname, "ns") // Natural Selection || equal(modname, "gearbox")) // Half-Life: Opposing Force VEC_DUCK_VIEW[2] = 12.0 else if (equal(modname, "dod")) // Day of Defeat