Why return 0?
#1

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.
Reply
#2

If rStatus is set to '1', than it's obvious that this will return 0 - the first iterator is probably 0.
Reply
#3

It's look like that:
pawn Code:
Race[0][rStatus] = 1;
In OnGameModeInit.. soo.. it's need to be = 0 as you told, yes? if it is.. it will return -1.
Reply
#4

Bump. (5th page)
Reply
#5

2nd page.. guys i need it for real..
Reply
#6

I don't understand your problem. Please be more clear and post some more code.
Reply
#7

i is probably 0 ?
The first time it executes, will return i , so = 0
Reply
#8

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
Reply
#9

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;
}
...
Reply
#10

Hah.. thank you very much.. finally works

P.S
Can i ask you something? but on PM.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)