Skip to content

Commit

Permalink
refactor for prefix cvar
Browse files Browse the repository at this point in the history
  • Loading branch information
Mistrick committed Apr 20, 2018
1 parent bd62156 commit 7281bf9
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 33 deletions.
12 changes: 9 additions & 3 deletions addons/amxmodx/scripting/map_manager_effects.sma
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <map_manager>

#define PLUGIN "Map Manager: Effects"
#define VERSION "0.0.3"
#define VERSION "0.0.4"
#define AUTHOR "Mistrick"

#pragma semicolon 1
Expand All @@ -27,7 +27,9 @@ enum Cvars {
FREEZETIME,
VOTE_IN_NEW_ROUND,
PREPARE_TIME,
VOTE_TIME
VOTE_TIME,
CHANGE_TYPE,
LAST_ROUND
};

enum {
Expand Down Expand Up @@ -70,6 +72,8 @@ public plugin_cfg()
g_pCvars[VOTE_IN_NEW_ROUND] = get_cvar_pointer("mapm_vote_in_new_round");
g_pCvars[PREPARE_TIME] = get_cvar_pointer("mapm_prepare_time");
g_pCvars[VOTE_TIME] = get_cvar_pointer("mapm_vote_time");
g_pCvars[CHANGE_TYPE] = get_cvar_pointer("mapm_change_type");
g_pCvars[LAST_ROUND] = get_cvar_pointer("mapm_last_round");
}
}
public plugin_end()
Expand Down Expand Up @@ -158,7 +162,9 @@ public mapm_vote_finished(map[], type, total_votes)
g_bFreezetimeChanged = false;
set_float(FREEZETIME, get_float(FREEZETIME) - get_float(PREPARE_TIME) - get_float(VOTE_TIME) - 1);
}
freeze_unfreeze(1);
if(get_num(CHANGE_TYPE) || get_num(LAST_ROUND)) {
freeze_unfreeze(1);
}
}
DisableHamForward(g_hHamSpawn);
}
Expand Down
26 changes: 13 additions & 13 deletions addons/amxmodx/scripting/map_manager_informer.sma
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#endif

#define PLUGIN "Map Manager: Informer"
#define VERSION "0.0.2"
#define VERSION "0.0.3"
#define AUTHOR "Mistrick"

#pragma semicolon 1
Expand All @@ -26,7 +26,7 @@ new g_pCvars[Cvars];

new g_iTeamScore[2];
new g_szCurMap[MAPNAME_LENGTH];
new PREFIX[32];
new g_sPrefix[48];

public plugin_init()
{
Expand All @@ -40,7 +40,6 @@ public plugin_init()
register_event("TeamScore", "event_teamscore", "a");

get_mapname(g_szCurMap, charsmax(g_szCurMap));
mapm_get_prefix(PREFIX, charsmax(PREFIX));
}
public plugin_cfg()
{
Expand All @@ -49,6 +48,8 @@ public plugin_cfg()
g_pCvars[MAXROUNDS] = get_cvar_pointer("mp_maxrounds");
g_pCvars[NEXTMAP] = get_cvar_pointer("amx_nextmap");
g_pCvars[EXTENDED_TYPE] = get_cvar_pointer("mapm_extended_type");

mapm_get_prefix(g_sPrefix, charsmax(g_sPrefix));
}
public event_teamscore()
{
Expand All @@ -60,52 +61,51 @@ public clcmd_timeleft(id)
new win_limit = get_num(WINLIMIT);
new max_rounds = get_num(MAXROUNDS);

// TODO: need subtract left_wins/left_rounds if mapm_change_type 0 or 1
if((win_limit || max_rounds) && get_num(EXTENDED_TYPE) == EXTEND_ROUNDS) {
new text[128], len;
len = formatex(text, charsmax(text), "%L ", LANG_PLAYER, "MAPM_TIME_TO_END");
if(win_limit) {
new left_wins = win_limit - max(g_iTeamScore[0], g_iTeamScore[1]);
// TODO: add to ML MAPM_WINS
len += formatex(text[len], charsmax(text) - len, "%d %L", left_wins, LANG_PLAYER, "MAPM_WINS");
}
if(win_limit && max_rounds) {
len += formatex(text[len], charsmax(text) - len, " %L ", LANG_PLAYER, "MAPM_TIMELEFT_OR");
}
if(max_rounds) {
new left_rounds = max_rounds - g_iTeamScore[0] - g_iTeamScore[1];
// TODO: add to ML MAPM_ROUNDS
len += formatex(text[len], charsmax(text) - len, "%d %L", left_rounds, LANG_PLAYER, "MAPM_ROUNDS");
}
client_print_color(0, print_team_default, "%s^1 %s.", PREFIX, text);
client_print_color(0, print_team_default, "%s^1 %s.", g_sPrefix, text);
} else {
if (get_num(TIMELIMIT)) {
new a = get_timeleft();
client_print_color(0, id, "%s^1 %L:^3 %d:%02d", PREFIX, LANG_PLAYER, "MAPM_TIME_TO_END", (a / 60), (a % 60));
client_print_color(0, id, "%s^1 %L:^3 %d:%02d", g_sPrefix, LANG_PLAYER, "MAPM_TIME_TO_END", (a / 60), (a % 60));
} else {
if(is_vote_will_in_next_round()) {
// TODO: add ML
client_print_color(0, print_team_default, "%s^1 Wait vote in next round.", PREFIX);
client_print_color(0, print_team_default, "%s^1 Wait vote in next round.", g_sPrefix);
} else {
client_print_color(0, print_team_default, "%s^1 %L", PREFIX, LANG_PLAYER, "MAPM_NO_TIMELIMIT");
client_print_color(0, print_team_default, "%s^1 %L", g_sPrefix, LANG_PLAYER, "MAPM_NO_TIMELIMIT");
}
}
}
}
public clcmd_thetime(id)
{
new curtime[64]; get_time("%Y/%m/%d - %H:%M:%S", curtime, charsmax(curtime));
client_print_color(0, print_team_default, "%s^3 %L", PREFIX, LANG_PLAYER, "MAPM_THETIME", curtime);
client_print_color(0, print_team_default, "%s^3 %L", g_sPrefix, LANG_PLAYER, "MAPM_THETIME", curtime);
}
public clcmd_nextmap(id)
{
if(is_vote_finished()) {
new map[MAPNAME_LENGTH]; get_pcvar_string(g_pCvars[NEXTMAP], map, charsmax(map));
client_print_color(0, id, "%s^1 %L ^3%s^1.", PREFIX, LANG_PLAYER, "MAPM_NEXTMAP", map);
client_print_color(0, id, "%s^1 %L ^3%s^1.", g_sPrefix, LANG_PLAYER, "MAPM_NEXTMAP", map);
} else {
client_print_color(0, id, "%s^1 %L ^3%L^1.", PREFIX, LANG_PLAYER, "MAPM_NEXTMAP", LANG_PLAYER, "MAPM_NOT_SELECTED");
client_print_color(0, id, "%s^1 %L ^3%L^1.", g_sPrefix, LANG_PLAYER, "MAPM_NEXTMAP", LANG_PLAYER, "MAPM_NOT_SELECTED");
}
}
public clcmd_currentmap(id)
{
client_print_color(0, id, "%s^1 %L", PREFIX, LANG_PLAYER, "MAPM_CURRENT_MAP", g_szCurMap);
client_print_color(0, id, "%s^1 %L", g_sPrefix, LANG_PLAYER, "MAPM_CURRENT_MAP", g_szCurMap);
}
20 changes: 10 additions & 10 deletions addons/amxmodx/scripting/map_manager_nomination.sma
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#endif

#define PLUGIN "Map Manager: Nomination"
#define VERSION "0.0.2"
#define VERSION "0.0.3"
#define AUTHOR "Mistrick"

#pragma semicolon 1
Expand Down Expand Up @@ -46,7 +46,7 @@ new g_hCallbackDisabled;
new g_iNomMaps[33];
new g_iLastDenominate[33];

new PREFIX[32];
new g_sPrefix[48];

public plugin_init()
{
Expand Down Expand Up @@ -93,7 +93,7 @@ public mapm_maplist_loaded(Array:maplist)
{
g_aMapsList = maplist;
g_aNomList = ArrayCreate(NomStruct, 1);
mapm_get_prefix(PREFIX, charsmax(PREFIX));
mapm_get_prefix(g_sPrefix, charsmax(g_sPrefix));
}
public client_disconnected(id)
{
Expand Down Expand Up @@ -140,13 +140,13 @@ nominate_map(id, map[], index)
new map_info[MapStruct]; ArrayGetArray(g_aMapsList, index, map_info);

if(mapm_get_blocked_count(map)) {
client_print_color(id, print_team_default, "%s^1 %L", PREFIX, id, "MAPM_NOM_NOT_AVAILABLE_MAP");
client_print_color(id, print_team_default, "%s^1 %L", g_sPrefix, id, "MAPM_NOM_NOT_AVAILABLE_MAP");
return NOMINATION_FAIL;
}

if(get_num(TYPE) == TYPE_FIXED && ArraySize(g_aNomList) >= get_num(MAPS_IN_VOTE)) {
// TODO: add ML
client_print_color(id, print_team_default, "%s^1 All nomination slots are reserved.", PREFIX);
client_print_color(id, print_team_default, "%s^1 All nomination slots are reserved.", g_sPrefix);
return NOMINATION_FAIL;
}

Expand All @@ -157,26 +157,26 @@ nominate_map(id, map[], index)
if(nom_index != INVALID_MAP_INDEX) {
ArrayGetArray(g_aNomList, nom_index, nom_info);
if(id != nom_info[NomPlayer]) {
client_print_color(id, print_team_default, "%s^1 %L", PREFIX, id, "MAPM_NOM_ALREADY_NOM");
client_print_color(id, print_team_default, "%s^1 %L", g_sPrefix, id, "MAPM_NOM_ALREADY_NOM");
return NOMINATION_FAIL;
}

new systime = get_systime();
if(g_iLastDenominate[id] + get_num(DENOMINATE_TIME) >= systime) {
client_print_color(id, print_team_default, "%s^1 %L", PREFIX, id, "MAPM_NOM_SPAM");
client_print_color(id, print_team_default, "%s^1 %L", g_sPrefix, id, "MAPM_NOM_SPAM");
return NOMINATION_FAIL;
}

g_iLastDenominate[id] = systime;
g_iNomMaps[id]--;
ArrayDeleteItem(g_aNomList, nom_index);

client_print_color(0, id, "%s^3 %L", PREFIX, LANG_PLAYER, "MAPM_NOM_REMOVE_NOM", name, map);
client_print_color(0, id, "%s^3 %L", g_sPrefix, LANG_PLAYER, "MAPM_NOM_REMOVE_NOM", name, map);
return NOMINATION_REMOVED;
}

if(g_iNomMaps[id] >= get_num(MAPS_PER_PLAYER)) {
client_print_color(id, print_team_default, "%s^1 %L", PREFIX, id, "MAPM_NOM_CANT_NOM");
client_print_color(id, print_team_default, "%s^1 %L", g_sPrefix, id, "MAPM_NOM_CANT_NOM");
return NOMINATION_FAIL;
}

Expand All @@ -186,7 +186,7 @@ nominate_map(id, map[], index)

g_iNomMaps[id]++;

client_print_color(0, id, "%s^3 %L", PREFIX, LANG_PLAYER, "MAPM_NOM_MAP", name, map);
client_print_color(0, id, "%s^3 %L", g_sPrefix, LANG_PLAYER, "MAPM_NOM_MAP", name, map);

return NOMINATION_SUCCESS;
}
Expand Down
16 changes: 9 additions & 7 deletions addons/amxmodx/scripting/map_manager_rtv.sma
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#endif

#define PLUGIN "Map Manager: Rtv"
#define VERSION "0.0.1"
#define VERSION "0.0.2"
#define AUTHOR "Mistrick"

#pragma semicolon 1
Expand Down Expand Up @@ -37,7 +37,7 @@ new g_iMapStartTime;
new bool:g_bVoted[33];
new g_iVotes;

new PREFIX[32];
new g_sPrefix[48];

public plugin_init()
{
Expand All @@ -55,8 +55,10 @@ public plugin_init()

// reset it with sv_restart?
g_iMapStartTime = get_systime();

mapm_get_prefix(PREFIX, charsmax(PREFIX));
}
public plugin_cfg()
{
mapm_get_prefix(g_sPrefix, charsmax(g_sPrefix));
}
public client_disconnected(id)
{
Expand All @@ -74,7 +76,7 @@ public clcmd_rtv(id)

new delay = get_num(DELAY) * 60 - (get_systime() - g_iMapStartTime);
if(delay > 0) {
client_print_color(id, print_team_default, "%s^1 %L", PREFIX, id, "MAPM_RTV_DELAY", delay / 60, delay % 60);
client_print_color(id, print_team_default, "%s^1 %L", g_sPrefix, id, "MAPM_RTV_DELAY", delay / 60, delay % 60);
return PLUGIN_HANDLED;
}

Expand All @@ -97,9 +99,9 @@ public clcmd_rtv(id)
if(!g_bVoted[id]) {
g_bVoted[id] = true;
new name[32]; get_user_name(id, name, charsmax(name));
client_print_color(0, print_team_default, "%s^3 %L.", PREFIX, LANG_PLAYER, "MAPM_RTV_VOTED", name, need_votes);
client_print_color(0, print_team_default, "%s^3 %L.", g_sPrefix, LANG_PLAYER, "MAPM_RTV_VOTED", name, need_votes);
} else {
client_print_color(id, print_team_default, "%s^1 %L.", PREFIX, id, "MAPM_RTV_ALREADY_VOTED", need_votes);
client_print_color(id, print_team_default, "%s^1 %L.", g_sPrefix, id, "MAPM_RTV_ALREADY_VOTED", need_votes);
}

return PLUGIN_HANDLED;
Expand Down

0 comments on commit 7281bf9

Please sign in to comment.