Check if the vehicle is occupied
#1

I created a racing event wanted each player to be placed on a vehicle that is not occupied tried to do but not have the right time that the player and set on a vehicle that is already occupied.

pawn Код:
new Carro[20];


    if(dialogid == 666)
    {
        if(response == 0)
        {
            SendClientMessage(playerid, COR_RED, "You chose to go on the Event!");
            TrazerKart[playerid] = 0;
            return 1;
        }
        if(response == 1)
        {
            if(PlayerInfo[playerid][pJailed] != 0)
            {
                SendClientMessage(playerid,COR_RED,"ERRO* you are stuck and can not go to the Event!");
                TrazerKart[playerid] = 0;
                return 0;
            }
            new tmp[128];
            new plo, world;
            plo = ReturnUser(tmp);
            world = GetPlayerVirtualWorld(playerid);
            new tmpcar = GetPlayerVehicleID(playerid);
            SetPlayerVirtualWorld(plo,world);
            RemovePlayerFromVehicle(tmpcar);
            SetVehicleToRespawn(GetPlayerVehicleID(playerid));
            SetPlayerVirtualWorld(plo,world);
            ResetPlayerWeaponsEx(playerid);
           PlayerInfo[playerid][pTrazerKart] = 1;
            SendClientMessage(playerid,COR_RED,"Welcome to the event!");
            for(new i=0; i<MAX_PLAYERS; i++)
            {
                if(PlayerInfo[i][pTrazerKart] == 1)
                {
                   if(!IsPlayerInVehicle(i, Carro[random(20)]))
                   {
                      SetPlayerInterior(i,0);
                      PutPlayerInVehicle(i, Carro[random(20)], 0);
                      Jogadoreskart++;
                      EVENTO[i] = 1;
                      SetPlayerRaceCheckpoint(i,1,-1341.8914,-671.3342,1055.9453,0.0,0.0,0.0,10.0);
                   }
                }
             }
         }
         return 1;
    }
Reply
#2

Edit; nvm
Reply
#3

I like to put it in? Carro[random(20)
Reply
#4

Show your Carro code
Reply
#5

is that the right way?
pawn Код:
Jogadoreskart++;
            for(new i=0; i<MAX_PLAYERS; i++)
            {
                if(PlayerInfo[i][pTrazerKart] == 1)
                {
                   if(!IsPlayerConnected(i) || IsPlayerInAnyVehicle(i)) continue;
                   if(Jogadoreskart != 20)
                   {
                     PutPlayerInVehicle(i,Carro[Jogadoreskart],0);
Reply
#6

Here's something confusing, what kind of seat id is 0?
pawn Код:
for(new i=0; i<MAX_PLAYERS; i++)
            {
                if(PlayerInfo[i][pTrazerKart] == 1)
                {
                   if(!IsPlayerConnected(i) || IsPlayerInAnyVehicle(i)) continue;
                   if(Jogadoreskart != 20)
                   {
                     PutPlayerInVehicle(i,Carro[Jogadoreskart],1); // 1 so it will put the player as a driver.
Reply
#7

wanted to put each player in vehicles new car [20]; that is not occupied
Reply
#8

Alright on player joins the event, you can instead create event vehicle and simply put that player in the vehicle, that should solve the problem, define MAX_EVENTCARS to your wished amount.
Reply
#9

Can you give me an example please?
Reply
#10

Quote:
Originally Posted by Jack_Leslie
Посмотреть сообщение
Show your Carro code
pawn Код:
Carro[0] = AddStaticVehicleEx(468,-1417.0273,-659.9675,1058.8440,269.9847,6,6,60000*RESPAWN_TIME); // carros moto cross
Carro[1] = AddStaticVehicleEx(468,-1417.3922,-661.8430,1058.8627,267.1085,6,6,60000*RESPAWN_TIME); // carros moto cross
Carro[2] = AddStaticVehicleEx(468,-1416.8267,-664.0300,1058.7948,269.4243,6,6,60000*RESPAWN_TIME); // carros moto cross
Carro[3] = AddStaticVehicleEx(468,-1417.3604,-666.2977,1058.8297,267.7939,6,6,60000*RESPAWN_TIME); // carros moto cross
Carro[4] = AddStaticVehicleEx(468,-1420.3275,-668.1931,1059.0905,266.7281,6,6,60000*RESPAWN_TIME); // carros moto cross
Carro[5] = AddStaticVehicleEx(468,-1423.4838,-668.0016,1059.3794,264.8923,6,6,60000*RESPAWN_TIME); // carros moto cross
Carro[6] = AddStaticVehicleEx(468,-1426.1588,-668.0992,1059.6221,264.6644,6,6,60000*RESPAWN_TIME); // carros moto cross
Carro[7] = AddStaticVehicleEx(468,-1426.4806,-666.3209,1059.6608,268.1281,6,6,60000*RESPAWN_TIME); // carros moto cross
Carro[8] = AddStaticVehicleEx(468,-1423.2908,-666.0146,1059.3727,268.5226,6,6,60000*RESPAWN_TIME); // carros moto cross
Carro[9] = AddStaticVehicleEx(468,-1420.1783,-666.1967,1059.0876,270.7532,6,6,60000*RESPAWN_TIME); // carros moto cross
Carro[10] = AddStaticVehicleEx(468,-1420.1664,-663.9179,1059.1014,264.5124,6,6,60000*RESPAWN_TIME); // carros moto cross
Carro[11] = AddStaticVehicleEx(468,-1423.0852,-663.7866,1059.3689,270.0768,6,6,60000*RESPAWN_TIME); // carros moto cross
Carro[12] = AddStaticVehicleEx(468,-1426.5165,-664.7682,1059.6732,269.6854,6,6,60000*RESPAWN_TIME); // carros moto cross
Carro[13] = AddStaticVehicleEx(468,-1426.8501,-663.0245,1059.7174,264.3732,6,6,60000*RESPAWN_TIME); // carros moto cross
Carro[14] = AddStaticVehicleEx(468,-1426.5531,-661.3387,1059.6722,264.8974,6,6,60000*RESPAWN_TIME); // carros moto cross
Carro[15] = AddStaticVehicleEx(468,-1426.6637,-659.3900,1059.7256,265.4692,6,6,60000*RESPAWN_TIME); // carros moto cross
Carro[16] = AddStaticVehicleEx(468,-1423.2377,-661.3705,1059.4026,268.8428,6,6,60000*RESPAWN_TIME); // carros moto cross
Carro[17] = AddStaticVehicleEx(468,-1423.0555,-659.5181,1059.3905,268.6081,6,6,60000*RESPAWN_TIME); // carros moto cross
Carro[18] = AddStaticVehicleEx(468,-1420.0482,-659.6635,1059.1185,272.2489,6,6,60000*RESPAWN_TIME); // carros moto cross
Carro[19] = AddStaticVehicleEx(468,-1420.1868,-661.6171,1059.1233,264.9102,6,6,60000*RESPAWN_TIME); // carros moto cross
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)