public Event(playerid) { if(Event_Players >= RACE_PLAYERS) { foreach(Player, i) { if(ON_Event[i] == 1) { SCM(i, COLOR_WHITE, "EVENT POKRENUT (10 sekundi)"); SetTimerEx("EventStart", 10000, false, "i", i); if(IsPlayerInVehicle(i, INFERNUS1)) { PutPlayerInVehicle(i, INFERNUS1, 0); } else if(IsPlayerInVehicle(i, INFERNUS2)) { PutPlayerInVehicle(i, INFERNUS2, 0); } } } } }
Well, obviously, you are checking if a player is in the event, and then checking if that SAME exact player is inside infernus 1, and if they are, they get put into infernus 1. Therefore, if they are in no vehicle, they get put in no vehicle.
|
#define MAX_EVENT_PLAYERS 20 //Max players able to join the event is 20.
#define MAX_EVENT_CARS 20 //Same value as the EventCars variable
new EventCars[20];
new EventPlayers = 0;
EventCar[0] = CreateVehicle(blbablabla);
EventCar[1] = CreateVehicle(blbablabla);
EventCar[2] = CreateVehicle(blbablabla);
EventCar[3] = CreateVehicle(blbablabla);
EventCar[4] = CreateVehicle(blbablabla);
EventCar[5] = CreateVehicle(blbablabla);
EventCar[6] = CreateVehicle(blbablabla);
EventCar[7] = CreateVehicle(blbablabla);
// And so on
//When a player types a command to join an event or something, use this public (EnterEvent(playerid))
//Command here (example made using zcmd)
CMD:joinevent(playerid, params[])
{
if(EventPlayers < MAX_EVENT_PLAYERS)
{
if(PlayerLogged[playerid] == 1) //Player is logged in, just an example if you have it where the player must be logged it.
{
EnterEvent(playerid);
}
}
return 1;
}
public EnterEvent(playerid)
{
if(EventPlayers < MAX_EVENT_PLAYERS)
{
for(new i = 0; i < MAX_EVENT_CARS)
{
if(!IsVehicleOccupied(i))
{
PutPlayerInVehicle(i, INFERNUS1, 0); //If the car is not occupied, put the player in the vehicle
return 1;
}
}
SendClientMessage(playerid, -1, "No more vehicles are available!"); //Shouldn't ever happen, since when you type the command it checks if the event is available, and both the cars and players are equal
}
}
stock IsVehicleOccupied(vehicleid) // Returns 1 if there is anyone in the vehicle
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInAnyVehicle(i))
{
if(GetPlayerVehicleID(i) == vehicleid)
{
return true; //If the looped player is in that vehicleid, return true
}
}
}
return false; //If no looped player is in the vehicleid, return false
}
#define MAX_EVENT_CARS 2
new EventCars[2];
EventCars[0] = AddStaticVehicle(411,1569.9385,2250.2214,10.4009,178.9650,1,1);
EventCars[1] = AddStaticVehicle(411,1565.0801,2250.2344,10.4047,179.6880,1,1);
public Event(playerid)
{
if(Event_Players >= RACE_PLAYERS)
{
for(new i = 0; i < MAX_EVENT_CARS;)
{
if(!IsVehicleOccupied(i))
{
PutPlayerInVehicle(i, EventCars, 0); //argument type mismatch (argument 2)
SCM(i, COLOR_WHITE, "EVENT POKRENUT (10 sekundi)");
SetTimerEx("EventStart", 10000, false, "i", playerid);
return 1;
}
}
}
}