Loop issue
#1

This command is used when admin wants to sell Car Ownership car and for that he needs the car ID.

pawn Код:
if(strcmp(cmd, "/getcarid", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        if(PlayerInfo[playerid][pAdmin] >= 4)
        {
            for(new c = 0; c < sizeof(CarInfo); c++)
            {
                new Float:x,Float:y,Float:z;
                new carid = CarInfo[c][cID]; //the car ID in AddStaticVehicle
                GetVehiclePos(carid, x, y, z);
                if(PlayerToPoint(3, playerid, x, y, z))
                {
                    format(string, sizeof(string), "Car ID: %d", c);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_RED, "You are not near any Car Ownership vehicle.");
                    return 1;
                }
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "Only admins with Adm Level 4 can use this command.");
            return 1;
        }
    }
    return 1;
}
But the problem is that it only works for car that is ID 0. When I change the loop to
pawn Код:
for(new c = 1; c < sizeof(CarInfo); c++)
Than it works for car id 1
pawn Код:
for(new c = 2; c < sizeof(CarInfo); c++)
For car id 2 and so on....

_________________________________________________

This CarInfo[c][cID] is used in here under OnGameModeInIt

pawn Код:
for(new c = 0; c < sizeof(CarInfo); c++)
{
  CarInfo[c][cID] = AddStaticVehicleEx(CarInfo[c][cModel], CarInfo[c][cLocationx], CarInfo[c][cLocationy], CarInfo[c][cLocationz], CarInfo[c][cAngle], CarInfo[c][cColor1], CarInfo[c][cColor2], -1);
}
Basicly it works perfectly for car id 0 but not for the other so the problem is in loop I think...
Any ideas what is the problem?

Tnx
Reply


Messages In This Thread
Loop issue - by Dujma - 21.02.2009, 09:55
Re: Loop issue - by Finn - 21.02.2009, 10:44
Re: Loop issue - by Dujma - 21.02.2009, 10:48
Re: Loop issue - by yom - 21.02.2009, 10:55
Re: Loop issue - by Dujma - 21.02.2009, 10:58
Re: Loop issue - by yom - 21.02.2009, 11:01
Re: Loop issue - by Dujma - 21.02.2009, 11:03

Forum Jump:


Users browsing this thread: 2 Guest(s)