Too Long
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
The syntax is not even correct. The correct syntax is:
pawn Код:
if(Model[ playerid ] == 400 || Model[ playerid ] == 401 || Model[ playerid ] == 402 || ...)
But that would make the line even longer so you should instead use either a switch or, preferably, an array.

First, put this function somewhere in your script:
pawn Код:
stock in_array(needle, const haystack[], size = sizeof haystack, &index = 0)
{
    for(new i; i < size; i++)
    {
        if(haystack[i] == needle)
        {
            index = i;
            return true;
        }
    }
       
    return false;
}
In your OnPlayerStateChange block (or at the top of your script if you expect to use the same collection of models elsewhere) create a constant array of valid vehicle models like:
pawn Код:
static const validVehicles[] = {400, 401, 402, 405, 409, /*etc*/ , 609};
Then you can check if the model is valid by doing
pawn Код:
if(in_array(Model[ playerid ], validVehicles))
tnx u vince will try your way . stock i can put anyware right ? and do i need to leave space by doing this static const validVehicles[] = {400, 401, 402, 405, 409, /*etc*/ , 609}; after each number ?
Reply


Messages In This Thread
Too Long - by cyberlord - 26.12.2014, 14:22
Re: Too Long - by jackx3rx - 26.12.2014, 15:34
Re: Too Long - by cyberlord - 26.12.2014, 15:45
Re: Too Long - by Vince - 26.12.2014, 15:47
Re: Too Long - by cyberlord - 26.12.2014, 15:57
Re: Too Long - by cyberlord - 26.12.2014, 16:22
Re: Too Long - by Vince - 26.12.2014, 16:40
Re: Too Long - by cyberlord - 26.12.2014, 16:46

Forum Jump:


Users browsing this thread: 2 Guest(s)