Adding Func. in less lines possible
#4

Don't use vehicle IDs directly. Create a new array to hold the vehicle IDs then check if the vehicle ID is in the array.

pawn Код:
// Top of script
// Array sizes MUST match
new gAnsipaVehicle[3]; // Holds 3 vehicles (0 - 2)
new Text3D:gAnsipaVehicleLabel[3]; // Holds 3 labels(0 - 2)

// OnGameModeInit/OnFilterScriptInit
gAnsipaVehicle[0] = AddStaticVehicle(...);
gAnsipaVehicle[1] = AddStaticVehicle(...);
gAnsipaVehicle[2] = AddStaticVehicle(...);

// loop through and attach a label to all vehicle IDs stored in the array
for (new i; i < sizeof(gAnsipaVehicle); i++)
{
    gAnsipaVehicleLabel[i] = Create3DTextLabel(...);
    Attach3DTextLabelToVehicle(gAnsipaVehicleLabel[i], gAnsipaVehicle[i]);
}

// New IsAnsipaCar function
bool:IsAnsipaVehicle(vehicleid)
{
    for (new i; i < sizeof(gAnsipaVehicle); i++)
    {
        if (vehicleid == gAnsipaVehicle[i])
        {
            return true;
        }
    }
    false;
}
Reply


Messages In This Thread
Adding Func. in less lines possible - by Stereotype - 06.08.2013, 12:44
Re: Adding Func. in less lines possible - by Konstantinos - 06.08.2013, 12:51
Re: Adding Func. in less lines possible - by Stereotype - 06.08.2013, 12:57
Re: Adding Func. in less lines possible - by Psymetrix - 06.08.2013, 19:45
Re: Adding Func. in less lines possible - by Misiur - 06.08.2013, 19:49
Re: Adding Func. in less lines possible - by Stereotype - 08.08.2013, 15:28
Re: Adding Func. in less lines possible - by Pottus - 08.08.2013, 17:35
Re: Adding Func. in less lines possible - by Stereotype - 09.08.2013, 11:32

Forum Jump:


Users browsing this thread: 1 Guest(s)