CMD:command(playerid) { new vehicleid = GetPlayerVehicleID(playerid), passengerID = INVALID_PLAYER_ID; if(AccountInfo[playerid][Job] == JOB_TAXI) { for(new p; p < MAX_PLAYERS; p++) { if(IsPlayerInVehicle(p, 438 && 420 ) && GetPlayerState(p) == PLAYER_STATE_PASSENGER) { passengerID = p; break; } } if(passengerID == passengerID == INVALID_PLAYER_ID) { SendClientMessage(playerid, -1, "There is no passenger"); } else { SendClientMessage(playerid, -1, "There is one"); } } return true; }
CMD:command(playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You must be in a vehicle to use this command.");
new vehicleid = GetPlayerVehicleID(playerid);
if(GetVehicleModel(vehicleid) != 420 && GetVehicleModel(vehicleid) != 438) return SendClientMessage(playerid, 0xFF0000FF, "You must be in a taxi to use this command.");
if(AccountInfo[playerid][Job] == JOB_TAXI)
{
new string[145];
new count = 0;
new pName[MAX_PLAYER_NAME];
for(new p = 0; p < MAX_PLAYERS; p++)
{
if(IsPlayerConnected(p))
{
if(IsPlayerInVehicle(p, vehicleid))
{
if(GetPlayerState(p) == PLAYER_STATE_PASSENGER)
{
GetPlayerName(p, pName, MAX_PLAYER_NAME);
format(string, sizeof(string), "%s(%d) is a passenger in this vehicle.", pName, p);
SendClientMessage(playerid, 0xFFFF00FF, string);
count++;
}
}
}
}
if(count == 0)
{
SendClientMessage(playerid, 0xFF0000FF, "There are no passengers in this vehicle.");
}
else
{
format(string, sizeof(string), "There are currently %d passenger(s) in this vehicle.", count);
SendClientMessage(playerid, -1, string);
}
}
return 1;
}
for(new p = 0; p < MAX_PLAYERS; p++)
I can't force someone to use foreach so I did a loop, but yes, if you get the opportunity you should use it.
(Not even sure if that was directed at me, but whatever) |