02.11.2015, 09:07
I am still on the process creating the 11th game for X Games Series, the Derby!
I am having some problems with the CheckDerby.
Information about CheckDerby: It is used to detect if the player has fallen out of the arena by checking the Z height.
I have tried making a bool variable and set it to true if a winner is declared, so in that way the next time CheckDerby is called in, it will be blocked in by the code i placed in (returning 1 instead). However this didn't worked. The timer is set to be called for 3500 mileseconds. This callback gets called twice or thrice.. Help me out bruh.
I am having some problems with the CheckDerby.
Information about CheckDerby: It is used to detect if the player has fallen out of the arena by checking the Z height.
I have tried making a bool variable and set it to true if a winner is declared, so in that way the next time CheckDerby is called in, it will be blocked in by the code i placed in (returning 1 instead). However this didn't worked. The timer is set to be called for 3500 mileseconds. This callback gets called twice or thrice.. Help me out bruh.
PHP код:
forward CheckDerby();
public CheckDerby()
{
new string[150];
if(derby_time == false) return 1;
if(winner_derby == true) return 1;
foreach(derby, playerid)
{
new Float:_pos[3];
GetPlayerPos(playerid, _pos[0], _pos[1], _pos[2]);
switch(mode)
{
case DB_ID:
{
if(_pos[2] <= 10)
{
if(OnDerby[playerid] == true)
{
format(string, sizeof string, "Eliminated:"white" %s has lost the derby [Fall out of Arena] (%d position)", GetName(playerid), Iter_Count(derby));
SendClientMessageToAll(COLOR_RED, string);
Iter_Remove(derby, playerid);
new specplayer = Iter_Random(derby);
StartSpectate(playerid, specplayer);
OnDerby[playerid] = false;
}
if (Iter_Count(derby) == 1)
{
foreach(derby, x)
{
format(string, sizeof string, "Winner:"white" %s has won the Derby, they won 5+ scores, 4 cakes and $2500", GetName(x));
SendClientMessageToAll(COLOR_GREEN, string);
SetPlayerScore(x, GetPlayerScore(x) + 5);
GivePlayerCash(x, 2500);
GiveCake(x, 4);
User[x][accountDerby] ++;
winner_derby = true;
SetTimer("ProcessEnding", 3500, false);
KillTimer(timer);
KillTimer(timer2);
}
}
}
}
}
}
return 1;
}