Why return 0? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Why return 0? (
/showthread.php?tid=278348)
Why return 0? -
Riddick94 - 21.08.2011
pawn Code:
stock ZwrocMAXIDWyscigu()
{
foreach2(i, MAX_RACES)
{
if(Race[i][rStatus])return i;
}
return -1;
}
I need to count races to use it in random. It's returning me 0 in debug. Why? rStatus is setting to = 1.
Re: Why return 0? -
RyDeR` - 21.08.2011
If rStatus is set to '1', than it's obvious that this will return 0 - the first iterator is probably 0.
Re: Why return 0? -
Riddick94 - 21.08.2011
It's look like that:
In OnGameModeInit.. soo.. it's need to be = 0 as you told, yes? if it is.. it will return -1.
Re: Why return 0? -
Riddick94 - 22.08.2011
Bump. (5th page)
Re: Why return 0? -
Riddick94 - 22.08.2011
2nd page.. guys i need it for real..
Re: Why return 0? -
RyDeR` - 22.08.2011
I don't understand your problem. Please be more clear and post some more code.
Re: Why return 0? -
Machida - 22.08.2011
i is probably 0 ?
The first time it executes, will return i , so = 0
Re: Why return 0? -
Riddick94 - 22.08.2011
It's getting race id and random from all and automaticly start. MAX_RACES is 2.. but it's dynamic system i can add more if i wan't.. [rStatus] = 1; in OnGameModeInit and it should return race id. But it's returning me 0.. and won't random from races. Understand? : d
Re: Why return 0? -
Riddick94 - 22.08.2011
pawn Code:
stock StartRandomRace()
{
if(!SerwerInfo[rRaceStarted])
{
SerwerInfo[rAktualny_Wyscig] = random(ReturnMaxIDRace());
SerwerInfo[rPlayersCanJoinRace] = true;
SerwerInfo[rRaceStarted] = true;
SerwerInfo[rTimeEntries] = 5;
SerwerInfo[sTimers][1] = SetTimer("StartRaces", SECONDS(1), true);
printf("Wyścig przypisany do ID: %d", SerwerInfo[rAktualny_Wyscig]);
}
return true;
}
pawn Code:
stock ReturnMaxIDRace()
{
foreach2(i, MAX_RACES)
{
if(Race[i][rStatus])return i;
}
return true;
}
...
Re: Why return 0? -
Riddick94 - 22.08.2011
Hah.. thank you very much.. finally works
P.S
Can i ask you something? but on PM.