-
Couldn't load subscription status.
- Fork 24
New plugin: online checker #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
ff3506c
add new plugin
c59b136
remove pluginURL
caf2311
change plugin registration info
c141879
add 1.8.2 support
a7b679d
compile fix
4134505
more 1.8.2 support
fd29085
fix color message
87b158e
reorder functions
0247f4b
indent fix
b1446df
naming fix
53b1206
g_sPrefix in `plugin_cfg()`
32ef030
move `VOTE_BY_INCORRECT_ONLINE` to `map_manager_consts.inc`
0bfc0f3
call `get_mapname()` in `plugin_cfg()`
7189be4
use `mapm_get_map_index()`
901a451
add desc to .cfg
9a717b3
mapm_online_check_count <= 0 - disable checks
51cef3b
fix `mapm_can_be_extended()` usage when CVar disabled
8d9b33a
fix when map not found
e7ff5a4
run task in `plugin_cfg()`
2d3f337
add `type` check in `mapm_can_be_extended()`
9a40adf
compile fix
b4e6817
change task creation
3d1e23f
Update map_manager.cfg
Mistrick 5835847
Update map_manager_online_checker.sma
Mistrick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
cstrike/addons/amxmodx/scripting/map_manager_online_checker.sma
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| #include <amxmodx> | ||
| #include <map_manager> | ||
| #include <map_manager_scheduler> | ||
|
|
||
| #define PLUGIN "Map Manager: Online checker" | ||
| #define VERSION "1.0.0" | ||
| #define AUTHOR "Sergey Shorokhov" | ||
|
|
||
| #pragma semicolon 1 | ||
|
|
||
| #define get_num(%0) get_pcvar_num(g_pCvars[%0]) | ||
| #define get_float(%0) get_pcvar_float(g_pCvars[%0]) | ||
|
|
||
| enum (+=100) { | ||
| TASK_CHECK_ONLINE = 100 | ||
| }; | ||
|
|
||
| enum Cvars { | ||
| CHECK_INTERVAL, | ||
| CHECKS_COUNT, | ||
| CHECK_TIMEOUT | ||
| }; | ||
|
|
||
| new g_sPrefix[48]; | ||
| new g_pCvars[Cvars]; | ||
|
|
||
| new g_CurrentMap[MapStruct]; | ||
| new g_Warnings; | ||
|
|
||
| public plugin_init() { | ||
| register_plugin(PLUGIN, VERSION + VERSION_HASH, AUTHOR); | ||
|
|
||
| g_pCvars[CHECK_INTERVAL] = register_cvar("mapm_online_check_interval", "30"); | ||
| g_pCvars[CHECKS_COUNT] = register_cvar("mapm_online_check_count", "3"); | ||
| g_pCvars[CHECK_TIMEOUT] = register_cvar("mapm_online_check_timeout", "120"); | ||
| } | ||
|
|
||
| public plugin_cfg() { | ||
| mapm_get_prefix(g_sPrefix, charsmax(g_sPrefix)); | ||
| get_mapname(g_CurrentMap[Map], charsmax(g_CurrentMap[Map])); | ||
| } | ||
|
|
||
| public task_check_online() { | ||
| if(get_num(CHECKS_COUNT) <= 0) { | ||
| return; | ||
| } | ||
|
|
||
| new current_online = get_players_num(); | ||
| if(current_online != 0 && get_float(CHECK_TIMEOUT) > get_gametime()) { | ||
| return; | ||
| } | ||
|
|
||
| new bool: is_online_incorrect = (current_online < g_CurrentMap[MinPlayers] || current_online > g_CurrentMap[MaxPlayers]); | ||
|
|
||
| g_Warnings = clamp(is_online_incorrect ? ++g_Warnings : --g_Warnings, 0, get_num(CHECKS_COUNT)); | ||
| if(g_Warnings != get_num(CHECKS_COUNT)) { | ||
| return; | ||
| } | ||
|
|
||
| client_print_color(0, print_team_default, "%s^1 %L", g_sPrefix, LANG_PLAYER, "MAPM_RTV_START_VOTE"); | ||
|
|
||
| map_scheduler_start_vote(VOTE_BY_INCORRECT_ONLINE); | ||
| } | ||
|
|
||
| public mapm_maplist_loaded(Array: maplist, const nextmap[]) { | ||
| remove_task(TASK_CHECK_ONLINE); | ||
|
|
||
| new idx = mapm_get_map_index(g_CurrentMap[Map]); | ||
| if(idx == INVALID_MAP_INDEX) { | ||
| return; | ||
| } | ||
|
|
||
| g_Warnings = 0; | ||
| set_task(get_float(CHECK_INTERVAL), "task_check_online", .flags = "b", .id = TASK_CHECK_ONLINE); | ||
| ArrayGetArray(maplist, idx, g_CurrentMap); | ||
| } | ||
|
|
||
| public mapm_can_be_extended(type) { | ||
wopox1337 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if(type != VOTE_BY_INCORRECT_ONLINE) { | ||
| return EXTEND_ALLOWED; | ||
| } | ||
|
|
||
| return EXTEND_BLOCKED; | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.