how to put player in random cars
#1

ok i am working on a stunt game.

i have a derby system but i want player to Put in a sultan once they do /join

I have created 6 sultans, so each player are put on each of the sultans.

and after all the players in derby game are destroyed, I want last winner player, after he wins he'll be Teleported out of the derby. Then everyone sees his name that he won using sendclientmessagetoall
Reply
#2

Want help asap
Reply
#3

You're asking too much from this section, that's not going to work.
Try here https://sampforum.blast.hk/showthread.php?tid=30938&page=223.
Reply
#4

Use a loop to check if a player is in a car and if is no one in the car put the player in.
And for the winner problem use a variable to know how many players are in the game and when variable = 1 he is the winner.
Reply
#5

pawn Код:
#define MAX_SULTANS 6

native IsValidVehicle(vehicleid);

new iCars[MAX_SULTANS]
      ;

stock GetVehicleDriver( vehicleID )
{
       for(new i = 0; i < MAX_PLAYERS; i++)
       {
            if( IsPlayerInVehicle(i, vehicleID) ) return i;
            else continue;
       }
       return -1;
}

public OnGameModeInit()
{
       for(new i = 0; i < MAX_SULTANS; i++)
       {
            iCars[ i ] = AddStaticVehicle(....);
       }
       return 1;
}

CMD:join(playerid)
{
      // Player checks, admin levels, etc.
      for(new i = 0; i < MAX_SULTANS; i++)
      {
           if( IsValidVehicle(iCars[i]) )
           {
              if( GetVehicleDriver(iCars[i]) == -1) { return PutPlayerInVehicle(playerid, iCars[i], 0); }
              else continue;
           }
      }
      SendClientMessage(playerid, -1, "Sorry, all vehicles have been occupied.");
      return 1;
}
  • Creates vehicles under OnGameModeInit()
  • When the player joins - check in a loop if the 'i'th vehicle is valid
  • If it is - get the player's driver - if there is no driver, put him in that vehicle.
  • If no vehicle is empty, simply return to him that message.
There are other ways, but whatever suits you.
Cheers!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)