Using arrays?
#5

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Well that will work but you don't want to keep calling the same function every iteration it should actually look like this.

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new veh = GetPlayerVehicleID(playerid);
    for(new i; i < sizeof(CGLSVehicles); i++)
    {
        if(veh== CGLSVehicles[i]) // LINE 656
        {
            //Do stuff, they're in one of your vehicle!
            break; //Stop the loop, we don't need it anymore.
        }
    }
    return 1;
}
I'd also make a dynamic car loader instead of sequentially incrementing the array during vehicle creation.
By the way, it's:

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    for(new i; i < sizeof(CGLSVehicles); i++)
    {
        if(vehicleid == CGLSVehicles[i]) // LINE 656
        {
            //Do stuff, they're in one of your vehicle!
            break; //Stop the loop, we don't need it anymore.
        }
    }
    return 1;
}
And, there is no difference as this function will be called along side again and again either if it's out the loop.
Reply


Messages In This Thread
Using arrays? - by arjanforgames - 19.08.2013, 09:50
Re: Using arrays? - by RajatPawar - 19.08.2013, 09:54
Re: Using arrays? - by Ash. - 19.08.2013, 09:55
Re: Using arrays? - by Pottus - 19.08.2013, 13:23
Re: Using arrays? - by Cypress - 19.08.2013, 13:30
Re: Using arrays? - by Edix - 19.08.2013, 14:37
Re: Using arrays? - by Vince - 19.08.2013, 15:40
Re: Using arrays? - by Jefff - 19.08.2013, 16:56
Re: Using arrays? - by Ash. - 21.08.2013, 23:58

Forum Jump:


Users browsing this thread: 1 Guest(s)