IsPlayerInVehicle problem.
#1

Hello guys.. Again a comand doesn't work for me. When i check if the player is in certain vehicle it just skips this part:
Код:
GetPlayerVehicleID(playerid);
	if(IsPlayerInVehicle(playerid, 509 | 481 | 510 | 462 | 448 | 581 | 522 | 461 | 521 | 523 | 463 | 586 | 468 | 471))
 	{
  	SendClientMessage(playerid,COLOR_BRIGHTRED,"Љo komandu nevar izmantot kamēr atrodies uz motocikla.");
  	return 1;
   	}
Код:
if(strcmp(cmdtext, "/neon 2", true)==0)
	{
	if(GetPlayerScore(playerid) >= 7)
	{
	if(IsPlayerInAnyVehicle(playerid))
 	{
  	SendClientMessage(playerid,COLOR_BRIGHTRED,"Tev jāatrodas maљīnā lai izmantotu љo komandu.");
  	return 1;
   	}
   	GetPlayerVehicleID(playerid);
	if(IsPlayerInVehicle(playerid, 509 | 481 | 510 | 462 | 448 | 581 | 522 | 461 | 521 | 523 | 463 | 586 | 468 | 471))
 	{
  	SendClientMessage(playerid,COLOR_BRIGHTRED,"Љo komandu nevar izmantot kamēr atrodies uz motocikla.");
  	return 1;
   	}
   	GetPlayerVehicleID(playerid);
   	if(IsPlayerInVehicle(playerid, 592 | 577 | 511 | 512 | 593 | 553 | 476 | 519 | 460 | 513 | 548 | 425 | 417 | 487 | 488 | 497 | 562 | 447 | 469))
 	{
  	SendClientMessage(playerid,COLOR_BRIGHTRED,"Љo komandu nevar izmantot kamēr atrodies iekљ helikoptera.");
  	return 1;
   	}
	SetPVarInt(playerid, "Status", 1);
	SetPVarInt(playerid, "neon2", neon2[playerid] = CreateObject(18647,0,0,0,0,0,0));
 	SetPVarInt(playerid, "neon3", neon3[playerid] = CreateObject(18647,0,0,0,0,0,0));
  	AttachObjectToVehicle(GetPVarInt(playerid, "neon2"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
   	AttachObjectToVehicle(GetPVarInt(playerid, "neon3"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
    SendClientMessage(playerid, 0xFFFFFFAA, "Neon installed");
	}
	else
	{
	SendClientMessage(playerid, COLOR_BRIGHTRED, "Љo kommandu var izmantot tikai no 7. līmeņa.");
	}
	return 1;
	}
What could be the problem?
Reply
#2

please expand your problem so I can understand it better.
Reply
#3

pawn Код:
if(IsPlayerInVehicle(playerid, 592 | 577 | 511 | 512 | 593 | 553 | 476 | 519 | 460 | 513 | 548 | 425 | 417 | 487 | 488 | 497 | 562 | 447 | 469))
You can't hold the logical OR operator here, so you need to make an array list with all the wrong IDs and check them with IsPlayerInVehicle.
Reply
#4

So for example

new 592, 577, 511, 512...... ; ?

or

new NoCars = 592, 577, 511, 512.... ; ?
Reply
#5

Please answer.
Reply
#6

Quote:
Originally Posted by Shetch
Посмотреть сообщение
Please answer.
Yes, exactly like that. try it then post your results. try the 2nd option you gave tho.
Reply
#7

pawn Код:
if(IsPlayerInVehicle(playerid, 509 | 481 | 510 | 462 | 448 | 581 | 522 | 461 | 521 | 523 | 463 | 586 | 468 | 471))
To
pawn Код:
new vid = GetPlayerVehicleID( playerid );
if( vid == 509 || vid == 481 || vid == 510 || vid == 462 || vid == 448 || vid == 581 || vid == 522 || vid == 461 || vid == 521 || vid == 523 || vid == 463 || vid == 586 || vid == 468 || vid == 471 )
It might give you an error that line is too long, in that case, seperate lines with "\".
Reply
#8

Pot of cookies to all of you.

Fixed it.
Reply
#9

Actually, a Switch/Case works better in your case...
You can define the vehicles you want to do something to so much easier...
Here's a little example I wrote for you to examine...
Just spawn yourself in different type of vehicles and you'll see how it works when you type /INVEH
Once you "get" the coding you can adapt it to your particular needs...

(Put in OnPlayerCommandText)

if(strcmp(cmd,"/INVEH",true)==0){
if(IsPlayerInAnyVehicle(playerid)){
new vehtype[16];
switch(GetVehicleModel(GetPlayerVehicleID(playerid ))){
case 441,464,465,501,564,594:{vehtype="RC Vehicle";}
case 430,446,452 .. 454,472,473,484,493,595:{vehtype="Boat";}
case 461,463,468,521 .. 523,581,586:{vehtype="MotorCycle";}
default:{vehtype="who cares?";}
}// end of switch
format(msv0,sizeof(msv0),"You are in a %s",vehtype);
SendClientMessage(playerid,0xFFFFFFAA,msv0);
}// end of IsPlayerInAnyVehicle
return 1;}

Cheers
8^}>
Reply
#10

Quote:
Originally Posted by Mean
Посмотреть сообщение
pawn Код:
if(IsPlayerInVehicle(playerid, 509 | 481 | 510 | 462 | 448 | 581 | 522 | 461 | 521 | 523 | 463 | 586 | 468 | 471))
To
pawn Код:
new vid = GetPlayerVehicleID( playerid );
if( vid == 509 || vid == 481 || vid == 510 || vid == 462 || vid == 448 || vid == 581 || vid == 522 || vid == 461 || vid == 521 || vid == 523 || vid == 463 || vid == 586 || vid == 468 || vid == 471 )
It might give you an error that line is too long, in that case, seperate lines with "\".
Huh... This one doesn't work either.







Quote:
Originally Posted by Spectre
Посмотреть сообщение
Actually, a Switch/Case works better in your case...
You can define the vehicles you want to do something to so much easier...
Here's a little example I wrote for you to examine...
Just spawn yourself in different type of vehicles and you'll see how it works when you type /INVEH
Once you "get" the coding you can adapt it to your particular needs...

(Put in OnPlayerCommandText)

if(strcmp(cmd,"/INVEH",true)==0){
if(IsPlayerInAnyVehicle(playerid)){
new vehtype[16];
switch(GetVehicleModel(GetPlayerVehicleID(playerid ))){
case 441,464,465,501,564,594:{vehtype="RC Vehicle";}
case 430,446,452 .. 454,472,473,484,493,595:{vehtype="Boat";}
case 461,463,468,521 .. 523,581,586:{vehtype="MotorCycle";}
default:{vehtype="who cares?";}
}// end of switch
format(msv0,sizeof(msv0),"You are in a %s",vehtype);
SendClientMessage(playerid,0xFFFFFFAA,msv0);
}// end of IsPlayerInAnyVehicle
return 1;}

Cheers
8^}>
And i cant fin a way to put this ^ script in an if command.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)