Too Long
#1

Hello i write this code and now i get that my line is too long , in this code i want to check all cars , trucks ,bikes,planes driving license . please help

Код:
 if( newstate == PLAYER_STATE_ENTER_VEHICLE_DRIVER )
		{
			Vehicleid[ playerid ] = GetPlayerVehicleID( playerid );
            Model[ playerid ] = GetVehicleModel( Vehicleid[ playerid ] );
            if(Model[ playerid ] == 403 || 406 || 407 || 408 || 431 || 427 || 428 || 437 || 433 || 443 || 455 || 456 || 486 || 515 || 524 || 532 || 544 || 573 || 578 || 601) //C CATEGORY DRIVING LICENSE CHECK
            {
				if(PlayerInfo[playerid][CarC] != 1)
				{
                    RemovePlayerFromVehicle( playerid );
                    GameTextForPlayer(playerid,"~r~Neturite C kategorijos vairuotojo pazymejimo",3000,3);
				}
			}
			else if(Model[ playerid ] == 461 || 463 || 468 || 521 || 522 || 523 || 581) // A Category Driving license check
			{
				if(PlayerInfo[playerid][CarA] != 1)
				{
                    RemovePlayerFromVehicle( playerid );
                    GameTextForPlayer(playerid,"~r~Neturite A kategorijos vairuotojo pazymejimo",3000,3);
				}
			}
			else if(Model[ playerid ] == 417 || 425 || 447 || 460 || 464 || 465 || 469 || 476 || 487 || 488 || 497 || 501 || 511 || 512 || 513 || 519 || 520 || 548 || 553 || 563 || 577 || 592 || 593)//PILOT License check
			{
			
			}
			else if(Model[ playerid ] == 400 || 401 || 402 || 404 || 405 || 409 || 410 || 411 || 412 || 413 || 414 || 415 || 416 || 418 || 419 || 420 || 421 || 422 || 423 || 424 || 426 || 429 || 434 || 436 || 438 || 439 || 440 || 441 || 442 || 444 || 445 || 451 || 458 || 459 || 466 || 467 || 470 || 471 || 474 || 475 || 477 || 478 || 479 || 480 || 482 || 483 || 485 || 489 || 490 || 491 || 492 || 494 || 495 || 496 || 498 || 499 || 500 || 502 || 503 || 504 || 505 || 506 || 507 || 508 || 516 || 517 || 518 || 533 || 534 || 535 || 536 || 525 || 526 || 527 || 528 || 529 || 530 || 531 || 540 || 541 || 542 || 543 || 545 || 546 || 547 || 549 || 550 || 551 || 552 || 554 || 555 || 556 || 557 || 558 || 559 || 560 || 561 || 562 || 565 || 566 || 567 || 568 || 572 || 574 || 575 || 576 || 579 || 580 || 582 || 583 || 585 || 587 || 588 || 596 || 597 || 598 || 599 || 600 || 602 || 603 || 604 || 605 || 609)
			{
			    if(PlayerInfo[playerid][CarB] != 1)
				{
                    RemovePlayerFromVehicle( playerid );
                    GameTextForPlayer(playerid,"~r~Neturite B kategorijos vairuotojo pazymejimo",3000,3);
				}
			}
		
		}
hare is errors i got
Код:
C:\Users\Cyberlord\Desktop\samp server stuff\Samp Server R4\gamemodes\RP.pwn(1125) : error 075: input line too long (after substitutions)
C:\Users\Cyberlord\Desktop\samp server stuff\Samp Server R4\gamemodes\RP.pwn(1127) : error 001: expected token: ")", but found "-integer value-"
C:\Users\Cyberlord\Desktop\samp server stuff\Samp Server R4\gamemodes\RP.pwn(1127) : warning 215: expression has no effect
C:\Users\Cyberlord\Desktop\samp server stuff\Samp Server R4\gamemodes\RP.pwn(1127) : error 001: expected token: ";", but found ")"
C:\Users\Cyberlord\Desktop\samp server stuff\Samp Server R4\gamemodes\RP.pwn(1127) : error 029: invalid expression, assumed zero
C:\Users\Cyberlord\Desktop\samp server stuff\Samp Server R4\gamemodes\RP.pwn(1127) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.
Reply
#2

pawn Код:
else if(Model[ playerid ] == 400 || 401 || 402 || 404 || 405 || 409 || 410 || 411 || 412 || 413 || 414 || 415 || 416 || 418 || 419 || 420 || 421 || 422 || 423 || 424 || 426 || 429 || 434 || 436 || 438 || 439 || 440 || 441 || 442 || 444 || 445 || 451 || 458 || 459 || 466 || 467 || 470 || 471 || 474 || 475 || 477 || 478 || 479 || 480 || 482 || 483 || 485 || 489 || 490 || 491 || 492 || 494 || 495 || 496 || 498 || 499 || 500 || 502 || 503 || 504 || 505 || 506 || 507 || 508 || 516 || 517 || 518 || 533 || 534 || 535 || 536 || 525 || 526 || 527 || 528 || 529 || 530 || 531 || 540 || 541 || 542 || 543 || 545 || 546 || 547 || 549 || 550 || 551 || 552 || 554 || 555 || 556 || 557 || 558 || 559 || 560 || 561 || 562 || 565 || 566 || 567 || 568 || 572 || 574 || 575 || 576 || 579 || 580 || 582 || 583 || 585 || 587 || 588 || 596 || 597 || 598 || 599 || 600 || 602 || 603 || 604 || 605 || 609)
By the way ^ this is too long, you need to shorten it, try splitting it into two/three so you end up with something like this:

pawn Код:
else if(Model[playerid] == 400 || 401 || 402 || 404 || 405 || 409 || 410) // to about 500
{

}
else if(Model[playerid] == 502 || 503 || 504 || 505 || 506 || 507 || 508) // to about 550
{

}
else if(Model[playerid] == 551 || 552 || 554) // to the end
{

}
Also this line:

pawn Код:
if(PlayerInfo[playerid][CarB] != 1)
.. try changing it to this:

pawn Код:
if(!PlayerInfo[playerid][CarB] == 1)
Reply
#3

Quote:
Originally Posted by jackx3rx
Посмотреть сообщение
pawn Код:
else if(Model[ playerid ] == 400 || 401 || 402 || 404 || 405 || 409 || 410 || 411 || 412 || 413 || 414 || 415 || 416 || 418 || 419 || 420 || 421 || 422 || 423 || 424 || 426 || 429 || 434 || 436 || 438 || 439 || 440 || 441 || 442 || 444 || 445 || 451 || 458 || 459 || 466 || 467 || 470 || 471 || 474 || 475 || 477 || 478 || 479 || 480 || 482 || 483 || 485 || 489 || 490 || 491 || 492 || 494 || 495 || 496 || 498 || 499 || 500 || 502 || 503 || 504 || 505 || 506 || 507 || 508 || 516 || 517 || 518 || 533 || 534 || 535 || 536 || 525 || 526 || 527 || 528 || 529 || 530 || 531 || 540 || 541 || 542 || 543 || 545 || 546 || 547 || 549 || 550 || 551 || 552 || 554 || 555 || 556 || 557 || 558 || 559 || 560 || 561 || 562 || 565 || 566 || 567 || 568 || 572 || 574 || 575 || 576 || 579 || 580 || 582 || 583 || 585 || 587 || 588 || 596 || 597 || 598 || 599 || 600 || 602 || 603 || 604 || 605 || 609)
By the way ^ this is too long, you need to shorten it, try splitting it into two/three so you end up with something like this:

pawn Код:
else if(Model[playerid] == 400 || 401 || 402 || 404 || 405 || 409 || 410) // to about 500
{

}
else if(Model[playerid] == 502 || 503 || 504 || 505 || 506 || 507 || 508) // to about 550
{

}
else if(Model[playerid] == 551 || 552 || 554) // to the end
{

}
Also this line:

pawn Код:
if(PlayerInfo[playerid][CarB] != 1)
.. try changing it to this:

pawn Код:
if(!PlayerInfo[playerid][CarB] == 1)
what do u meen change this line ?
Код:
if(PlayerInfo[playerid][CarB] != 1)
if i change it into == it its meens that player have driver license and then he will be kicked and how him that he is have no driving license , i solve that erorr but its not working not sure why , when i try to get into car nothing happens it just skip it this code
Reply
#4

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))
Reply
#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
#6

i tried your way vince i get no erorrs or something but its not working

this code is just skipped :
Код:
if( newstate == PLAYER_STATE_ENTER_VEHICLE_DRIVER )
		{
		    Vehicleid[ playerid ] = GetPlayerVehicleID( playerid );
            Model[ playerid ] = GetVehicleModel( Vehicleid[ playerid ] );
		    if(in_array(Model[ playerid ], validVehicles))
		    {
                if(PlayerInfo[playerid][CarB] != 1)
				{
                    RemovePlayerFromVehicle( playerid );
                    GameTextForPlayer(playerid,"~r~Neturite B kategorijos vairuotojo pazymejimo",3000,3);
				}
			}
		}
i paste your stock code and make this
Код:
static const validVehicles[] = {400,
401,
402,
404,
405,
409,
410,
411,
412,
413,
414,
415,
416,
418,
419,
420,
421,
422,
423,
424,
426,
429,
434,
436,
438,
439,
440,
441,
442,
444,
451,
459,
466,
467,
470,
471,
474,
475,
477,
478,
479,
480,
482,
483,
485,
489,
490,
491,
492,
494,
495,
496,
498,
499,
500,
502,
503,
504,
505,
506,
507,
508,
516,
517,
518,
533,
534,
535,
536,
525,
526,
527,
528,
529,
530,
531,
540,
541,
542,
543,
545,
546,
547,
549,
550,
551,
552,
554,
555,
556,
557,
558,
559,
560,
561,
562,
565,
566,
567,
568,
572,
574,
575,
576,
579,
580,
582,
583,
585,
587,
588,
596,
597,
598,
599,
600,
602,
603,
604,
605,
609};
but its not working , its give my no gametext i set or remove my from car
Reply
#7

Oh, that's probably because PLAYER_STATE_ENTER_VEHICLE_DRIVER is only used internally, you will want to use PLAYER_STATE_DRIVER instead (see: https://sampwiki.blast.hk/wiki/Playerstates).
Reply
#8

Quote:
Originally Posted by Vince
Посмотреть сообщение
Oh, that's probably because PLAYER_STATE_ENTER_VEHICLE_DRIVER is only used internally, you will want to use PLAYER_STATE_DRIVER instead (see: https://sampwiki.blast.hk/wiki/Playerstates).
yes tnx u that works and , what is it meens PLAYER_STATE_ENTER_VEHICLE_DRIVER used internally,
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)