[SOLVED]PutPlayerInVehicle
#1

i made a race. when player connect he is auto putted in vehicle.

the cars are behind each other, when players connect they all ar putted in vehicle that is first on the line...

how to make him spawning in other vehicle? not the same as player 1.

my code:

Код:
new s1;
new s2;
new s3;
new s4;
new s5;
new s6;
new s7;
new s8;
new s9;
new s10;
new s11;
new s12;
new s13;
new s14;
new s15;
ongamemodeinit:

Код:
	s1 = AddStaticVehicle(415,2402.4631,-1446.6404,23.6110,270.3815,36,1); // s1
	s2 = AddStaticVehicle(415,2402.0166,-1442.0786,23.6080,270.4241,40,1); // s2
	s3 = AddStaticVehicle(415,2407.7305,-1442.0381,23.6090,270.3965,40,1); // s3
	s4 = AddStaticVehicle(415,2408.0452,-1446.5861,23.6091,270.4894,36,1); // s4
	s5 = AddStaticVehicle(415,2413.6567,-1446.5393,23.6050,270.4644,36,1); // s5
	s6 = AddStaticVehicle(415,2413.9993,-1441.9999,23.6040,270.4028,40,1); // s6
	s7 = AddStaticVehicle(415,2419.5208,-1441.9607,23.6013,270.3860,40,1); // s7
	s8 = AddStaticVehicle(415,2419.7329,-1446.4818,23.6059,270.5570,36,1); // s8
	s9 = AddStaticVehicle(415,2425.5464,-1446.4232,23.6013,270.5424,36,1); // s9
	s10 = AddStaticVehicle(415,2425.2202,-1441.8464,23.6007,271.8618,40,1); // s10
	s11 = AddStaticVehicle(415,2431.2822,-1441.6494,23.6000,271.8616,40,1); // s11
	s12 = AddStaticVehicle(415,2431.3943,-1446.3610,23.6034,270.6088,36,1); // s12
	s13 = AddStaticVehicle(415,2437.1985,-1446.2971,23.6022,270.6006,36,1); // s13
	s14 = AddStaticVehicle(415,2437.0444,-1441.6627,23.6005,270.2533,40,1); // s14
	s15 = AddStaticVehicle(415,2443.4941,-1441.0392,23.6021,271.7062,40,1); // s15
onplayerconnect:

Код:
 PutPlayerInVehicle(playerid, s1, 0);
	PutPlayerInVehicle(playerid, s2, 0);
	PutPlayerInVehicle(playerid, s3, 0);
	PutPlayerInVehicle(playerid, s4, 0);
	PutPlayerInVehicle(playerid, s5, 0);
	PutPlayerInVehicle(playerid, s6, 0);
	PutPlayerInVehicle(playerid, s7, 0);
	PutPlayerInVehicle(playerid, s8, 0);
	PutPlayerInVehicle(playerid, s9, 0);
	PutPlayerInVehicle(playerid, s10, 0);
	PutPlayerInVehicle(playerid, s11, 0);
	PutPlayerInVehicle(playerid, s12, 0);
	PutPlayerInVehicle(playerid, s13, 0);
	PutPlayerInVehicle(playerid, s14, 0);
	PutPlayerInVehicle(playerid, s15, 0);
Reply
#2

pawn Код:
new s[14];
pawn Код:
s[0] = AddStaticVehicle(415,2402.4631,-1446.6404,23.6110,270.3815,36,1);
    s[1] = AddStaticVehicle(415,2402.0166,-1442.0786,23.6080,270.4241,40,1);
    s[2] = ....
You also need a function which checks if vehicle is occupied.
pawn Код:
public IsVehicleOccupied(vehicleid)
{
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if(IsPlayerInVehicle(i,vehicleid)) return 1;
    }
    return 0;
}
I don't think you can put player in vehicle OnPlayerConnect, but I suggest you to do that under OnPlayerSpawn.
pawn Код:
public OnPlayerSpawn(playerid)
{
    for(new i=0; i<14; i++)
    {
        if(!IsPlayerInAnyVehicle(playerid))
        {
            if(!IsVehicleOccupied(s[i]))
            {
                PutPlayerInVehicle(playerid, s[i], 0);
            }
        }
    }
    //other code
}
Reply
#3

thanks! this worked....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)