Ejall problem - 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: Ejall problem (
/showthread.php?tid=347190)
Ejall problem -
Face9000 - 31.05.2012
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?
Re: Ejall problem -
cod5devious - 31.05.2012
Add
PLAYER_STATE_PASSENGER
to it
Re: Ejall problem -
Revo - 31.05.2012
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)!
Re: Ejall problem -
Face9000 - 31.05.2012
Thanks but i fixed in another way.
Re: Ejall problem -
Ray0 - 31.05.2012
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.