08-30-2016, 09:32 PM
There appears to be some bug here in the code, and I haven't figured out what it is yet:
Code:
Float:map_getMinutesElapsed()
{
dbg_log(2, "%32s mp_timelimit: %f", "map_getMinutesElapsed(in/out)", get_cvar_float("mp_timelimit"));
return get_cvar_float("mp_timelimit") - (float(get_timeleft()) / 60.0);
}
public vote_rock(id)
{
// if an early vote is pending, don't allow any rocks
if (g_voteStatus & VOTE_IS_EARLY)
{
client_print(id, print_chat, "%L", id, "GAL_ROCK_FAIL_PENDINGVOTE");
return;
}
new Float:minutesElapsed = map_getMinutesElapsed();
// if the player is the only one on the server, bring up the vote immediately
if (get_realplayersnum() == 1 && minutesElapsed > floatmin(2.0, g_rtvWait))
{
vote_startDirector(true);
return;
}
// make sure enough time has gone by on the current map
if (g_rtvWait)
{
if (minutesElapsed < g_rtvWait)
{
client_print(id, print_chat, "%L", id, "GAL_ROCK_FAIL_TOOSOON", floatround(g_rtvWait - minutesElapsed, floatround_ceil));
return;
}
}
// rocks can only be made if a vote isn't already in progress
if (g_voteStatus & VOTE_IN_PROGRESS)
{
client_print(id, print_chat, "%L", id, "GAL_ROCK_FAIL_INPROGRESS");
return;
}
// and if the outcome of the vote hasn't already been determined
else if (g_voteStatus & VOTE_IS_OVER)
{
client_print(id, print_chat, "%L", id, "GAL_ROCK_FAIL_VOTEOVER");
return;
}
// determine how many total rocks are needed
new rocksNeeded = vote_getRocksNeeded();
// make sure player hasn't already rocked the vote
if (g_rockedVote[id])
{
client_print(id, print_chat, "%L", id, "GAL_ROCK_FAIL_ALREADY", rocksNeeded - g_rockedVoteCnt);
rtv_remind(TASKID_REMINDER + id);
return;
}
// allow the player to rock the vote
g_rockedVote[id] = true;
client_print(id, print_chat, "%L", id, "GAL_ROCK_SUCCESS");
// make sure the rtv reminder timer has stopped
if (task_exists(TASKID_REMINDER))
{
remove_task(TASKID_REMINDER);
}
// determine if there have been enough rocks for a vote yet
if (++g_rockedVoteCnt >= rocksNeeded)
{
// announce that the vote has been rocked
client_print(0, print_chat, "%L", LANG_PLAYER, "GAL_ROCK_ENOUGH");
// start up the vote director
vote_startDirector(true);
}
else
{
// let the players know how many more rocks are needed
rtv_remind(TASKID_REMINDER);
if (get_pcvar_num(cvar_rtvReminder))
{
// initialize the rtv reminder timer to repeat how many rocks are still needed, at regular intervals
set_task(get_pcvar_float(cvar_rtvReminder) * 60.0, "rtv_remind", TASKID_REMINDER, _, _, "b");
}
}
}