/getin with passengers
#1

Hello
I made a /getin command for a pd garage

pawn Код:
command(getin, playerid, params[])
{
    if(Factions[Player[playerid][Faction]][CommandTypes] == 1)
    {
        if(IsPlayerInRangeOfPoint(playerid, 5.0, 1588.5437,-1633.0819,13.1099))
        {
            new playercar = GetPlayerVehicleID(playerid);
            new playerseat = GetPlayerVehicleSeat(playerid);
            if(IsPlayerInAnyVehicle(playerid))
            {
                LinkVehicleToInterior(playercar, 1);
                SetVehicleVirtualWorld(playercar, 500);
                SetPlayerVirtualWorld(playerid, 500);
                SetPlayerInterior(playerid, 1);
                SetVehiclePos(playercar, 2314.2695,2446.1648,-39.3384);
                SetVehicleZAngle(playercar, 89.5626);
                PutPlayerInVehicle(playerid, playercar, playerseat);
            }
        }
    }
    return 1;
}
But If i have a person (passenger) with me he doesnt get a correct virtual world etc, is there a way to get him with me?
Reply
#2

Why do you use IsPlayerInAnyVehicle when you've already determined the ID of the player's vehicle which will be returned as 0 when the player isn't in a vehicle? Why?

Why do you get the player's seat if you're not even sure if the player is in a vehicle? Why?

Now the solution for your desired feature: you must loop through all players to see if they're also in the vehicle of your player who executed the command. This would look something like this:
pawn Код:
for(new i = 0; i != MAX_PLAYERS; i++) // or foreach(Player, i) if you use foreach
{
    if(IsPlayerInVehicle(i, playercar)) // Don't need an IsPlayerConnected check because this would never return true for an unconnected player ID.
    {
        // Change the virtual world of player i as well.
    }
}
Reply
#3

Fixed thanks, You get Rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)