If (IsPlayerInVehicle()) - GameTextForAll()
#1

Hey, I can't figure out how to do this properly. When you enter vehicle 573, a GameTextForAll() should pop up. Here is the code:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  if (IsPlayerInVehicle(playerid, 573))
    {
    new name[ 24 ], string[ 64 ];
    GetPlayerName( playerid, name, 24 );
    format( string, sizeof(string), "~w~%s has stolen the car!", name );
    GameTextForAll( string, 5000, 3 );
    }
    return 1;
}
Reply
#2

IsPlayerInVehicle checks for vehicle-ID and vehicle-ID is NOT model-ID. Use GetVehicleModel (for model-IDs) instead.
Reply
#3

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  if (GetPlayerVehicleID(playerid) == 573))
    {
    new name[ 24 ], string[ 64 ];
    GetPlayerName( playerid, name, 24 );
    format( string, sizeof(string), "~w~%s has stolen the car!", name );
    GameTextForAll( string, 5000, 3 );
    }
    return 1;
}
SHould work
Reply
#4

pawn Код:
if (GetPlayerVehicleID(playerid) == 573))
Код:
error 029: invalid expression, assumed zero
:/

EDIT: O I C. Too many brackets lol.

Reply
#5

if(GetPlayerVehicleID(playerid) == 573))
Reply
#6

Quote:
Originally Posted by Shinzei_Banzai
pawn Код:
if (GetPlayerVehicleID(playerid) == 573))
Код:
error 029: invalid expression, assumed zero
:/
remove one bracket from last
Reply
#7

if the model of the vehicle is 573
so:
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  if (GetVehicleModel(vehicleid) == 573)
	{
  	new name[ 24 ], string[ 64 ];
  	GetPlayerName( playerid, name, 24 );
  	format( string, sizeof(string), "~w~%s has stolen the car!", name );
  	GameTextForAll( string, 5000, 3 );
	}
	return 1;
}
if the ID of the vehicle 573
so:
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  if (vehicleid == 573)
	{
  	new name[ 24 ], string[ 64 ];
  	GetPlayerName( playerid, name, 24 );
  	format( string, sizeof(string), "~w~%s has stolen the car!", name );
  	GameTextForAll( string, 5000, 3 );
	}
	return 1;
}
Reply
#8

Yep, the if(GetVehicleModel(vehicleid) == 573) worked.

Next step which has nothing to do with that..

- Is it possible to disable a CMD by using another CMD?
Reply
#9

Quote:
Originally Posted by Shinzei_Banzai
- Is it possible to disable a CMD by using another CMD?
Yes.
Reply
#10

Got a guide or something?
Reply
#11

Just set a variable in the command 1 and use the if-statement to check the variable in the command 2.
Reply
#12

Quote:
Originally Posted by Don Correlli
Just set a variable in the command 1 and use the if-statement to check the variable in the command 2.
I'm too big of an amateur to understand that.. Something like this maybe?:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/disable", cmdtext, true, 10) == 0)
        {
         SetCMDStatus = Disabled;
        }
        else
        {
         SetCMDStatus = Enabled;
         }
     return 1;

}
    if (strcmp("/teleporter", cmdtext, true, 10) == 0)
    if(IsPlayerInAnyVehicle(playerid))
        {
        SendClientMessage(playerid,0x00FF00AA,"You're in a vehicle, get out of it first!");
        }
        else
        {
        SetPlayerPos(playerid,-119.5348,-368.5644,1.4297);
        SendClientMessage(playerid,0x00FF00AA,"Shut up and listen to the admin!.");
        return 1;
        }
Reply
#13

Wow you should really look for a guide instead of botherning like this! It's a simple command!
Reply
#14

Quote:
Originally Posted by Shinzei_Banzai
Quote:
Originally Posted by Don Correlli
Just set a variable in the command 1 and use the if-statement to check the variable in the command 2.
I'm too big of an amateur to understand that.. Something like this maybe?:
Here's my example-code (i didn't tested this):
pawn Код:
new bool:myVariable = false;

public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp(cmdtext, "/mycommand1", true) == 0)
  {
    if(myVariable == false)
    {
      myVariable = true; // set variable to true.
    }
    else if(myVariable == true)
    {
      myVariable = false; // set variable to false.
    }
    return 1;
  }
 
  if(strcmp(cmdtext, "/mycommand2", true) == 0)
  {
    if(myVariable == true)
    {
      // myVariable is true, you can execute your code.
    }
    else if(myVariable == false)
    {
      // myVariable is NOT true (it's false), send message that user can't use this command.
    }
    return 1;
  }
  return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)