PD Garage command
#1

Alright, I have a garage command,
pawn Код:
command(enterpg, playerid, params[])
{
#pragma unused params
    if( IsPlayerInRangeOfPoint( playerid, 5.0, 620.584, -596.347, 16.945 ) ) {
        if(Groups[Player[playerid][Group]][CommandTypes] == 1 || Groups[Player[playerid][Group]][CommandTypes] == 4)
        if( !IsPlayerInAnyVehicle( playerid ) ) {
            SetPlayerInterior( playerid, 0 );
            SetPlayerPos( playerid, 1445.771, 2595.099, 572.486);
        }
        else return SetVehiclePos( GetPlayerVehicleID( playerid ),1445.771, 2595.099, 572.486);
        }
    }
    return 1;
}


command(exitpg, playerid, params[])
{
#pragma unused params
    if( IsPlayerInRangeOfPoint( playerid, 5.0, 1445.771, 2595.099, 572.486) ) {
        if(Groups[Player[playerid][Group]][CommandTypes] == 1 || Groups[Player[playerid][Group]][CommandTypes] == 4)
        if( !IsPlayerInAnyVehicle( playerid ) ) {
            SetPlayerInterior( playerid, 0 );
            SetPlayerPos( playerid, 620.584, -596.347, 16.945 );
        }
        else return SetVehiclePos( GetPlayerVehicleID( playerid ), 620.584, -596.347, 16.945 );
    }
    return 1;
}
And I was wondering about three things.

First, How would I make it so that, if your not inrange of the point, it says "You are not at the police garage entrance" Or "You are not at the police garage exit"

Second: Same concept as one, How would I make it so that if group commands does not equal 1 or 4, it will say "You are not a law enforcement officer"

Third: (Not so important)
How would I make those two commands combined, for example, I type /pdgarage at the entrance point, and it teleports me into the garage, if Im in the garage and I type /pdgarage it will teleport me outside the garage..
Reply
#2

pawn Код:
command(enterpg, playerid, params[])
{
#pragma unused params
    if( IsPlayerInRangeOfPoint( playerid, 5.0, 620.584, -596.347, 16.945 ) ) {
        if(Groups[Player[playerid][Group]][CommandTypes] == 1 || Groups[Player[playerid][Group]][CommandTypes] == 4)
        if( !IsPlayerInAnyVehicle( playerid ) )
        {
            SetPlayerInterior( playerid, 0 );
            SetPlayerPos( playerid, 1445.771, 2595.099, 572.486);
        }
        else return SetVehiclePos( GetPlayerVehicleID( playerid ),1445.771, 2595.099, 572.486);
        }
        return SendClientMessage( playerid, -1, "You are not in Police Department." );// If player is not in PD Group.
    }
    return SendClientMessage( playerid, -1, "You are not at the PD Garage door."); // If player is not in range.
}
pawn Код:
command(exitpg, playerid, params[])
{
#pragma unused params
    if( IsPlayerInRangeOfPoint( playerid, 5.0, 1445.771, 2595.099, 572.486) ) {
        if(Groups[Player[playerid][Group]][CommandTypes] == 1 || Groups[Player[playerid][Group]][CommandTypes] == 4)
        if( !IsPlayerInAnyVehicle( playerid ) ) {
            SetPlayerInterior( playerid, 0 );
            SetPlayerPos( playerid, 620.584, -596.347, 16.945 );
        }
        else return SetVehiclePos( GetPlayerVehicleID( playerid ), 620.584, -596.347, 16.945 );
    }
    return 1;
}
And for the last question ... well, that`s another thing. Let me do it:
pawn Код:
command(pdgarage, playerid, params[])
{
#pragma unused params
    if( IsPlayerInRangeOfPoint( playerid, 5.0, 1445.771, 2595.099, 572.486) && Groups[Player[playerid][Group]][CommandTypes] == 1 || Groups[Player[playerid][Group]][CommandTypes] == 4)
    {
        if( !IsPlayerInAnyVehicle( playerid ) )
        {
            SetPlayerInterior( playerid, 0 );
            SetPlayerPos( playerid, 620.584, -596.347, 16.945 );
        }
        else return SetVehiclePos( GetPlayerVehicleID( playerid ), 620.584, -596.347, 16.945 );
    }
    if( IsPlayerInRangeOfPoint( playerid, 5.0, 620.584, -596.347, 16.945 ) && Groups[Player[playerid][Group]][CommandTypes] == 1 || Groups[Player[playerid][Group]][CommandTypes] == 4)
    {
         if( !IsPlayerInAnyVehicle( playerid ) )
         {
            SetPlayerInterior( playerid, 0 );
            SetPlayerPos( playerid, 1445.771, 2595.099, 572.486);
         }
        return SetVehiclePos( GetPlayerVehicleID( playerid ),1445.771, 2595.099, 572.486);
    }
    return SendClientMessage( playerid, -1, "You are not at the PD Garage door.");
}
Something like this ... didn`t test it but it should work.
Reply
#3

For the last part, I want it so that you ARE able to teleport in a car.. or on foot.
Reply
#4

Quote:
Originally Posted by patfay
Посмотреть сообщение
For the last part, I want it so that you ARE able to teleport in a car.. or on foot.
Well, try what I wrote in the post above and tell me if it works.

Anyway, overall, with the messages, it`s not really hard. For the example, after the if, you can use else return, just like you did with the SetVehiclePos...

I`ll give you another example:
pawn Код:
if( bla bla)
{
  //bla bla
}
return SendClientMessage( playerid, -1, "Message you want." ); // -1 is the color, which is white in this case ...
Overall, you don`t have to use
pawn Код:
else return SendClientMessage( bla bla)
you can use directly return, under the closed comma '}'.

Hope you understood something.
Reply
#5

It worked fine, just an indentation warning, fixed it though
Reply
#6

If you are not in the faction, its says your not near the garage door (even if you are).
If your inside the garage and type the command it will say your not at the garage door, and teleport you out
Reply
#7

Hm, try it like this:
pawn Код:
command(pdgarage, playerid, params[])
{
#pragma unused params
    if( IsPlayerInRangeOfPoint( playerid, 5.0, 1445.771, 2595.099, 572.486) && Groups[Player[playerid][Group]][CommandTypes] == 1 || Groups[Player[playerid][Group]][CommandTypes] == 4)
    {
         if( !IsPlayerInAnyVehicle( playerid ) )
         {
               SetPlayerInterior( playerid, 0 );
               SetPlayerPos( playerid, 620.584, -596.347, 16.945 );
         }
         return SetVehiclePos( GetPlayerVehicleID( playerid ), 620.584, -596.347, 16.945 );
    }
    else if( IsPlayerInRangeOfPoint( playerid, 5.0, 620.584, -596.347, 16.945 ) && Groups[Player[playerid][Group]][CommandTypes] == 1 || Groups[Player[playerid][Group]][CommandTypes] == 4)
    {
         if( !IsPlayerInAnyVehicle( playerid ) )
         {
               SetPlayerInterior( playerid, 0 );
               SetPlayerPos( playerid, 1445.771, 2595.099, 572.486);
         }
         return SetVehiclePos( GetPlayerVehicleID( playerid ),1445.771, 2595.099, 572.486);
    }
    return 1;
}
Well, with this code, it`ll check if you`re in range and if you are in the faction, at the same time ... If you want in another way, you can try this:
pawn Код:
command(pdgarage, playerid, params[])
{
#pragma unused params
    if( Groups[Player[playerid][Group]][CommandTypes] == 1 || Groups[Player[playerid][Group]][CommandTypes] == 4 )
    {
         if( IsPlayerInRangeOfPoint( playerid, 5.0, 1445.771, 2595.099, 572.486)
         {
              if( !IsPlayerInAnyVehicle( playerid ) )
              {
                    SetPlayerInterior( playerid, 0 );
                    SetPlayerPos( playerid, 620.584, -596.347, 16.945 );
              }
              return SetVehiclePos( GetPlayerVehicleID( playerid ), 620.584, -596.347, 16.945 );
         }
         else if( IsPlayerInRangeOfPoint( playerid, 5.0, 620.584, -596.347, 16.945 )
         {
              if( !IsPlayerInAnyVehicle( playerid ) )
              {
                   SetPlayerInterior( playerid, 0 );
                   SetPlayerPos( playerid, 1445.771, 2595.099, 572.486);
              }
              return SetVehiclePos( GetPlayerVehicleID( playerid ),1445.771, 2595.099, 572.486);
         }
         return SendClientMessage( playerid, -1, "You're not in the right position." );
    }
    return SendClientMessage( playerid, -1, "Only PD members can enter the garage." );
}
This will check the faction first and if he`s in the faction then he`ll check if he`s at the correct position.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)