Random vehicle ID
#4

What you did is basically the same as:
PHP код:
new carID=randomEx(400,611), string[96]; 
if(
carID != 430 || 435 != || 446 != || 449 != || 450 != || 452 != || 453 != || 454 != || 460 != || 472 != || 473 != || 484 != || 493 != || 537 != || 538 != || 539 != || 553 != || 569 != || 570 != || 577 != || 584 != || 590 != || 591 != || 592 != || 594 != || 595 != || 606 != || 607 != || 608 != || 610 != || 611

    
format(stringsizeof(string), "You got vehicle ID: %d!",carID); 
    
SCM(playeridGREENstring); 
    return 
1

else 

    
carID randomEx(494,536); 
    
format(stringsizeof(string), "You got vehicle ID: %d!",carID); 
    
SCM(playeridBLUEstring); 
    return 
1

Because 435 is indeed different than 0 the whole check will stop at that second check and it will execute the code in the first pair of brackets, because that check is always true. What you need to do is this:
PHP код:
new carID=randomEx(400,611), string[96];
if(
carID != 430 || carID != 435 || carID != 446 || carID != 449 || carID != 450 || carID != 452 || carID != 453 || carID != 454 || carID != 460 || carID != 472 || carID != 473 || carID != 484 || carID != 493 || carID != 537 || carID != 538 || carID != 539 || carID != 553 || carID != 569 || carID != 570 || carID != 577 || carID != 584 || carID != 590 || carID != 591 || carID != 592 || carID != 594 || carID != 595 || carID != 606 || carID != 607 || carID != 608 || carID != 610 || carID != 611)
{
    
format(stringsizeof(string), "You got vehicle ID: %d!",carID);
    
SCM(playeridGREENstring);
    return 
1;
}
else
{
    
carID randomEx(494,536);
    
format(stringsizeof(string), "You got vehicle ID: %d!",carID);
    
SCM(playeridBLUEstring);
    return 
1;

This is way better, switch is way faster when having to check that many values, it is also what you tried to do in the first place:
PHP код:
new carID=randomEx(400,611), string[32];
switch(
carID)
{
    case 
430435446449450452453454460472473484493537538539553569570577584590591592594595606607608610611:
    {
        
format(stringsizeof(string), "You got vehicle ID: %d!",carID);
        
SCM(playeridGREENstring);
        return 
1;
    }
    default:
    {
        
carID randomEx(494,536);
        
format(stringsizeof(string), "You got vehicle ID: %d!",carID);
        
SCM(playeridBLUEstring);
        return 
1;
    }

Reply


Messages In This Thread
Random vehicle ID - by TayFunCZE - 27.07.2017, 21:47
Re: Random vehicle ID - by Jefff - 27.07.2017, 21:57
Re: Random vehicle ID - by Paulice - 27.07.2017, 21:58
Re: Random vehicle ID - by IstuntmanI - 27.07.2017, 21:58
Re: Random vehicle ID - by TayFunCZE - 27.07.2017, 22:03

Forum Jump:


Users browsing this thread: 2 Guest(s)