Load without a ranking plugin, and use the rank score when one is installed #1
Merged
Daemon666 merged 1 commits from
daemon-patch-1
into main
1 changed file
with 20 additions and 8 deletions
addons/amxmodx/scripting/csb_automix.sma
M
| @@ -23,7 +23,8 @@ | ||
| 23 | 23 | #include <cstrike> |
| 24 | 24 | #include <fun> |
| 25 | 25 | |
| 26 | -/* optional external ranking; falls back to frags if the module is absent */ | |
| 26 | +/* optional external ranking; the native filter below lets the plugin load | |
| 27 | + without it, and teams are then balanced by frags */ | |
| 27 | 28 | native csb_get_rank_score(id) |
| 28 | 29 | |
| 29 | 30 | new const PLUGIN[] = "CSB AutoMix 5v5" |
| @@ -39,7 +40,24 @@ new const AUTHOR[] = "counter-strike-boost.com" | ||
| 39 | 40 | new g_pEnabled, g_pNeeded |
| 40 | 41 | new bool:g_bInMix[33] |
| 41 | 42 | new g_iState |
| 42 | -new bool:g_bHasRank | |
| 43 | +new bool:g_bHasRank = true | |
| 44 | + | |
| 45 | +public plugin_natives() | |
| 46 | +{ | |
| 47 | + set_native_filter("nativeFilter") | |
| 48 | +} | |
| 49 | + | |
| 50 | +/* Called at load for every native no plugin or module provides */ | |
| 51 | +public nativeFilter(const name[], index, trap) | |
| 52 | +{ | |
| 53 | + if (!trap && equal(name, "csb_get_rank_score")) | |
| 54 | + { | |
| 55 | + g_bHasRank = false | |
| 56 | + return PLUGIN_HANDLED | |
| 57 | + } | |
| 58 | + | |
| 59 | + return PLUGIN_CONTINUE | |
| 60 | +} | |
| 43 | 61 | |
| 44 | 62 | public plugin_init() |
| 45 | 63 | { |
| @@ -59,12 +77,6 @@ public plugin_init() | ||
| 59 | 77 | g_iState = STATE_IDLE |
| 60 | 78 | } |
| 61 | 79 | |
| 62 | -public plugin_cfg() | |
| 63 | -{ | |
| 64 | - /* detect the optional ranking native once modules are loaded */ | |
| 65 | - g_bHasRank = false | |
| 66 | -} | |
| 67 | - | |
| 68 | 80 | rankOf(id) |
| 69 | 81 | { |
| 70 | 82 | if (g_bHasRank) |
| 71 | 83 |









