What could be the problem with a countdown that doesn't work properly and the menu selection you choose is wrong
Quote:
[AMXX] Run time error 10: native error (native "ArrayGetCell")
[AMXX] [0] HNR_Core.sma::Open_DayModeMenu (line 1142)
[AMXX] [1] HNR_Core.sma::vote_day_mode_timer (line 1239)
|
Code:
new Array:g_aChoses;
#define GAME_MODE 6
new const g_szGame[GAME_MODE][] = {
"NoScope",
"Fog",
"knife",
"p228",
"weapon",
"grenade"
};
Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
g_aChoses = ArrayCreate(4);
register_menu("Open_DayModeMenu", "Close_DayModeMenu");
register_event("HLTV", "Event_HLTV", "a", "1=0", "2=0");
}
public Open_DayModeMenu(id)
{
if(g_iDayModeVoteTime < 1)
return PLUGIN_HANDLED;
new szMenu[512], iBitKeys = (1<<9), iLen;
title_menu(szMenu, iLen, "\r[4Honor`] \d- Please choose your favorite day^n^n\d- Time: %d secs -^n^n", g_iDayModeVoteTime);
for(new i = 0; i < 4; i++)
{
if (!g_bVoteStarted)
{
new iRandom = random_num(0,5);
while (IsRandomInArray(g_aChoses, iRandom))
{
iRandom = random_num(0,5);
}
ArrayPushCell(g_aChoses, iRandom);
}
if(!g_bUserVoted[id])
{
add_item_menu(szMenu, iLen, "\y[%d] \w%s \y(%d Votes)^n", i+1, g_szGame[ArrayGetCell(g_aChoses, i)], g_aDataDayMode[i][VOTES_NUM]);
iBitKeys |= (1<<i);
}
else
{
add_item_menu(szMenu, iLen, "\d[%d] %s \y(%d Votes)^n", i+1, g_szGame[ArrayGetCell(g_aChoses, i)], g_aDataDayMode[i][VOTES_NUM]);
}
}
ArrayClear(g_aChoses);
return menu_show(id, iBitKeys, szMenu, "Open_DayModeMenu");
}
public Close_DayModeMenu(id, iKey)
{
if(iKey == 9)
return PLUGIN_HANDLED;
g_aDataDayMode[iKey][VOTES_NUM]++;
g_bUserVoted[id] = true;
client_print_color(0, id, "%s ^3%n ^1vote for ^4%s^1.", PREFIX, id, g_szGame[iKey]);
//set_task(1.0, "main_informer", id+TASK_INDEX_SHOW_INFORMER, _, _, "b");
return PLUGIN_HANDLED;
}
stock IsRandomInArray(Array:aRandomArray, iRandom)
{
for(new i = 0; i < ArraySize(aRandomArray); i++)
{
if (ArrayGetCell(aRandomArray, i) == iRandom)
{
return true;
}
}
return false;
}
public vote_day_mode_timer()
{
if(_get_alive_players() > 1)
{
if(--g_iDayModeVoteTime)
{
for(new iPlayer = 1; iPlayer <= g_iMaxPlayers; iPlayer++)
{
if(!is_user_alive(iPlayer))
continue;
Open_DayModeMenu(iPlayer);
if (!g_bVoteStarted)
{
g_bVoteStarted = true;
}
}
}
else
{
vote_day_mode_ended();
}
}
}
public Event_HLTV()
{
g_bVoteStarted = false;
g_iGame = -1;
g_iDay += 1;
if(g_iDay % SPECIAL_DAY == 0) {
new i;
for(i = 1; i <= g_iMaxPlayers; i++)
g_bUserVoted[i] = false;
for(i = 0; i < GAME_MODE; i++)
g_aDataDayMode[i][VOTES_NUM] = 0;
g_iDay = 0;
g_iDayModeVoteTime = 15;
set_task(1.0, "vote_day_mode_timer", TASK_ID_VOTE_DAY_MODE_TIMER, _, _, "a", g_iDayModeVoteTime + 1);
} else
client_print_color(0, print_team_red, "%s HitAndRun:^4 Special Round^1 in^3 %d ^1Round%s", PREFIX, SPECIAL_DAY - g_iDay, g_iDay == 1 ? "" : "s");
}
If you want more information or something that will help you I will basically add what I try to do in the Time: SEC menu then time is always stuck at 14 and there is no countdown and even if I choose a menu that appears from the GAME_MODE list select
1. Fog
It will print in the chat I chose Weapon event