SA-MP Forums Archive
/getin with passengers - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /getin with passengers (/showthread.php?tid=398443)



/getin with passengers - Stefand - 09.12.2012

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?


Re: /getin with passengers - AndreT - 09.12.2012

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.
    }
}



Re: /getin with passengers - Stefand - 10.12.2012

Fixed thanks, You get Rep