Making a race starter
#1

So I want to make something like a race starter.

like someone has to type /join and then they get teleported to the race and automatically put in a car. Also their controlles are frozen so they don't cheat. I don't know how to make it to where each player gets put in one out of the 12 cars. (so that way two don't get put in the same car)

cars:
V12 = AddStaticVehicle(506,564.58,-2395,5.8318,360,0,1); //12
V10 = AddStaticVehicle(506,564.58,-2382,5.8317,360,0,1); //10
V8 = AddStaticVehicle(506,564.58,-2369,5.8318,360,0,1); //8
V6 = AddStaticVehicle(506,564.58,-2356,5.8317,360,0,1); //6
V4 = AddStaticVehicle(506,564.58,-2343,5.8318,360,0,1); //4
V2 = AddStaticVehicle(506,564.58,-2330,5.8317,360,0,1); //2
//__________________________________________________ ___
V11 =AddStaticVehicle(506,557.89,-2395.5,5.8317,360,0,1); //11
V9 = AddStaticVehicle(506,557.89,-2382.5,5.8317,360,0,1); //9
V7 = AddStaticVehicle(506,557.89,-2369.5,5.8317,360,0,1); //7
V5 = AddStaticVehicle(506,557.89,-2356.5,5.8317,360,0,1); //5
V3 = AddStaticVehicle(506,557.89,-2343.5,5.8317,360,0,1); //3
V1 = AddStaticVehicle(506,557.89,-2330.5,5.8317,360,0,1); //1

sorry they're in weird order but they go from V1 to V12.

How do I make it to where everytime someone types /join they get put in a car starting from 1. Also how do I make a timer so that when either all the spots are filled or when 1 minute is up the race starts.

Sorry for asking

but I can't figure it out...
Reply
#2

pawn Код:
//Top:
new IsRacePlaceTaken[12];
new InRace[MAX_PLAYERS];

//OnPlayerConnect:
InRace[playerid] = 0;

//OnPlayerDeath:
InRace[playerid] = 0;

//OnPlayerDisconnect:
InRace[playerid] = 0;

//GameModeInit:
  V12 = AddStaticVehicle(506,564.58,-2395,5.8318,360,0,1); //12
  V10 = AddStaticVehicle(506,564.58,-2382,5.8317,360,0,1); //10
  V8 = AddStaticVehicle(506,564.58,-2369,5.8318,360,0,1); //8
  V6 = AddStaticVehicle(506,564.58,-2356,5.8317,360,0,1); //6
  V4 = AddStaticVehicle(506,564.58,-2343,5.8318,360,0,1); //4
  V2 = AddStaticVehicle(506,564.58,-2330,5.8317,360,0,1); //2
  //_____________________________________________________
  V11 =AddStaticVehicle(506,557.89,-2395.5,5.8317,360,0,1); //11
  V9 = AddStaticVehicle(506,557.89,-2382.5,5.8317,360,0,1); //9
  V7 = AddStaticVehicle(506,557.89,-2369.5,5.8317,360,0,1); //7
  V5 = AddStaticVehicle(506,557.89,-2356.5,5.8317,360,0,1); //5
  V3 = AddStaticVehicle(506,557.89,-2343.5,5.8317,360,0,1); //3
  V1 = AddStaticVehicle(506,557.89,-2330.5,5.8317,360,0,1); //1


//On Command Text:
if(strcmp(cmdtext, "/join", true) == 0)
{
    new PutMeInPlaceId;
    SetPlayerPos(playerid, YourPosX, YourPosY, YourPosZ);
    TogglePlayerControllable(playerid, 0);
    SendClientMessage(playerid, YOURCOLOR, "Welcome To The Race!");

    for(new i=0; i<12; i++)
    {
        if(IsRacePlaceTaken[i] == 0 && InRace[playerid] == 0)
        {
            IsRacePlaceTaken[i] = 1;
            InRace[playerid] = 1;
            new str[100];
            format(str,100,"You Are In Race! Position: %d",i);
            SendClientMessage(playerid, YOURCOLOR, str);

            Switch(i)
            {
                case 1: PutPlayerInVehicle(playerid, V1);
                case 2: PutPlayerInVehicle(playerid, V2);
                case 3: PutPlayerInVehicle(playerid, V3);
                case 4: PutPlayerInVehicle(playerid, V4);
                case 5: PutPlayerInVehicle(playerid, V5);
                case 6: PutPlayerInVehicle(playerid, V6);
                case 7: PutPlayerInVehicle(playerid, V7);
                case 8: PutPlayerInVehicle(playerid, V8);
                case 9: PutPlayerInVehicle(playerid, V9);
                case 10: PutPlayerInVehicle(playerid, V10);
                case 11: PutPlayerInVehicle(playerid, V11);
                case 12: PutPlayerInVehicle(playerid, V12);

            }
           
        }
    }
}
note: not tested, and you need to put in the colors and tele position.
Reply
#3

You should check if they are in the race before the loop. Because if they are, it will just freeze them and put them at the race but not put them in a vehicle. And you probably want to use CreateVehicle instead because AddStaticVehicle's cannot be removed from the game. An alternative way could be like this though.

pawn Код:
//Top
new RaceVehicles[12];
new SeatPos;

//GameModeInit
RaceVehicles[0] = CreateVehicle(506,564.58,-2395,5.8318,360,0,1,9999);
RaceVehicles[1] = CreateVehicle(506,564.58,-2382,5.8317,360,0,1,9999);
RaceVehicles[2] = //And so on

if(strcmp(cmdtext, "/join", true) == 0)
{
   //No need to set their position if you're gonna put them in the vehicle anyway
   TogglePlayerControllable(playerid,0);
   PutPlayerInVehicle(RaceVehicles[SeatPos]);
   SeatPosition++;
   return 1;
}

//And when the race is over, set SeatPos to 0
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)