@DiBlaine poftim.
O constanta cu toate locurile vehiculelor.
new const MaxVehicleSeats[ 212 ] =
{
4, 2, 2, 2, 4, 4, 1, 2, 2, 4, 2, 2, 2, 4, 2, 2, 4, 2, 4, 2, 4, 4, 2, 2, 2,
1, 4, 4, 4, 2, 1, 9, 1, 2, 2, 0, 2, 9, 4, 2, 4, 1, 2, 2, 2, 4, 1,
2, 1, 2, 0, 2, 1, 1, 1, 2, 2, 2, 4, 4, 2, 2, 1, 2, 1, 2, 4, 4, 2, 2, 4, 2, 1,
1, 2, 2, 1, 2, 2, 4, 2, 1, 4, 3, 1, 1, 1, 4, 4, 2, 4, 2, 4, 1, 2, 2, 2, 4, 4,
2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 1, 1, 2, 1, 1, 2, 2, 4, 2, 2, 1, 1, 2, 2, 2, 2,
2, 2, 2, 2, 4, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 4, 2, 2, 2, 2, 2, 4, 4, 2, 2, 4,
4, 2, 1, 2, 2, 2, 2, 2, 2, 4, 4, 2, 2, 1, 2, 4, 4, 1, 0, 0, 1, 1, 2,
1, 2, 2, 4, 2, 4, 4, 2, 4, 1, 0, 4, 2, 2, 2, 2, 0, 0, 2, 2, 1, 1,
4, 4, 4, 2, 2, 2, 2, 2, 4, 2, 0, 0, 0, 4, 0, 0
};
O functie care verifica daca masina X are vreun loc liber, daca are, functia va returna locul liber daca nu, va returna -1.
GetFreeSeat( vehicleid ) // sa-mp.com
{
new vehiclemodel = GetVehicleModel(vehicleid);
if( vehiclemodel )
{
new
bool: seattaken[ 10 ],
playerseat = -1
;
foreach( new i : Player )
{
if( !IsPlayerInVehicle( i, vehicleid ) ) continue;
playerseat = GetPlayerVehicleSeat( i );
if( 0 <= playerseat < 128 ) seattaken[ playerseat ] = true;
}
for( new v = 0; v < MaxVehicleSeats[ vehiclemodel - 400 ]; v++ )
{
if( seattaken[ v ] ) continue;
return v;
}
}
return -1;
}
Un exemplu de comanda:
CMD:goto( playerid, params[], help )
{
// verificari, etc.
new
Float: posX, Float: posY, Float: posZ, vehID;
vehID = GetPlayerVehicleID( target );
GetPlayerPos( target, posX, posY, posZ );
// Aici verifi daca jucatorul se afla intr-un vehicul
if( IsPlayerInAnyVehicle( target ) )
{
// Aici verifici daca vehiculul jucatorului nu are nici un loc liber
if( GetFreeSeat( vehID ) == -1 )
SetPlayerPos( playerid, posX, posY + 2, posZ ); // Aici iti setezi pozitia la coordonatele jucatorului
else
PutPlayerInVehicle( playerid, vehID, GetFreeSeat( vehID ) ); // Aici iti setezi pozitia in vehiculul jucatorului
}
else
SetPlayerPos( playerid, posX, posY + 2, posZ );
return true;
}