PutPlayerInVehicle PROBLEM
#1

Hi, i have a problem, i want to make when player join the event to put him in one of two cars, i put IsPlayerInVehicle to check is the first car avalible or not, if not...i wont to put that player in avalible car...and i made that but when player join the event, nothing happens...tnx

Код:
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);
			}
			}
		}
        }
}
Reply
#2

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.
Reply
#3

Quote:
Originally Posted by Kindred
Посмотреть сообщение
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.
dahell...you are right, so...how can i make to check is that car avalible...if not...to put him in avalible? tnx
Reply
#4

This is an example, I came up with it on the spot and I'm not sure if it will work. Do something similar or the same as this:

pawn Код:
#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
}
Reply
#5

Something like tih? What now?

PHP код:
#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 
0MAX_EVENT_CARS;)
        {
            if(!
IsVehicleOccupied(i))
            {
                
PutPlayerInVehicle(iEventCars0); //argument type mismatch (argument 2)
                
SCM(iCOLOR_WHITE"EVENT POKRENUT (10 sekundi)");
                
SetTimerEx("EventStart"10000false"i"playerid);
                return 
1;
            }
        }
    }

Reply
#6

I got it, thanks for your help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)