Ejall problem
#1

Hello,i made this code:

pawn Код:
CMD:ejall(playerid,params[])
{
    new pCar;
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER && IsPlayerInVehicle(playerid, GetPlayerVehicleID(playerid)))
    {
    for(new i = 0; i < MAX_PLAYERS; i++)
    if(IsPlayerConnected(i) && GetPlayerVehicleID(i) == pCar)
    {
    new string[128];
    format(string, sizeof(string), "%s (%d) has ejected all passengers from his vehicle!", pNick(playerid), playerid);
    SendClientMessage(playerid, COLOR_WHITE, "Passengers ejected from your vehicle!");
    GameTextForPlayer(playerid,"~r~Players ejected from vehicle!",3000,5);
    SendClientMessage(i, 0x00FFFFFF, string);
    RemovePlayerFromVehicle(i);
    GameTextForPlayer(i,"~r~Ejected from vehicle!",3000,5);
    }
    }
    return true;
}
I dont get any errors while compiling,but ingame it doesnt eject passengers,what's wrong?
Reply
#2

Add
PLAYER_STATE_PASSENGER
to it
Reply
#3

pawn Код:
SendClientMessage(playerid, COLOR_WHITE, "Passengers ejected from your vehicle!");
    GameTextForPlayer(playerid,"~r~Players ejected from vehicle!",3000,5);
Also seems like you're sending a certain playerid 4x the same text (more if the vehicle is a bus, but you get the idea)!
Reply
#4

Thanks but i fixed in another way.
Reply
#5

1. You aren't defining pCar before going into the loop.
2. You should display any messages to playerid either before or after the loop, not inside it.
3. Indenting code is a good habit.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)