15.02.2017, 19:49
(
Последний раз редактировалось danielpalade; 25.09.2017 в 21:59.
)
-- DELETED --
stock GetRandomPlayer()
{
my_label:
new id = Iter_Random(Player);
if (pInfo[id][pMember] == 8 && pInfo[id][pScore] < 3 && pInfo[id][aVar][23] != 0)
{
goto my_label
}
return id;
}
|
I have no clue. I think it happens when there are no users online, so the variable users returns 0, but when the timer check for an ID, it see ID 0 from variable users, thus it gives array index out of bounds in my pInfo because the player doesn't exist.
|
|
I'm getting the error Array index out of bounds with this code:
Код:
#include <YSI\y_timers>
stock GetRandomPlayer()
{
new users[MAX_PLAYERS], pl = 0;
for(new i; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && pInfo[i][pMember] != 8 && pInfo[i][pScore] >= 3 && pInfo[i][aVar][23] == 0)
{
users[pl] = i;
pl++;
}
}
return users[random(pl)];
}
task AutoContracts[180000]()
{
new string[128], amount = RandomEx(6000, 30000), id = GetRandomPlayer();
if(IsPlayerConnected(id))
{
pInfo[id][aVar][23] += amount;
mysql_format(MySQLCon, quMYSQL, 200, "UPDATE `players` SET `Contract`=%d WHERE `ID`=%d", pInfo[id][aVar][23], pInfo[id][pID]), mysql_tquery(MySQLCon, quMYSQL);
format(string, sizeof(string), "HITMAN: A new hit is available. Name: %s | Amount: %s$, (/hits).", GetName(id), FormatNumber(pInfo[id][aVar][23]));
SendTeamMessage(8, COLOR_HITMAN, string);
}
return 1;
}
|
return users[((pl < 2) ? 0 : random(pl))];