1 этап. Создание переменных.
C++:
new race;
new LapRace[MAX_PLAYERS];
new RaceFinalPlayerSlot;
static VolumeLapRace = 6;
static TOTAL_RACE_SLOTS = 1;
new TOTAL_RACE_PLAYER;
enum TempPlayer
{
pRacePart,
pRaceSlot,
}
new pTemp[MAX_PLAYERS][TempPlayer];
new Float:RaceCheckpoint[][6] = {
{2838.1589,-2053.6638,10.4991, 2837.9897,-1941.7283,10.5027},
{2837.9897,-1941.7283,10.5027, 2856.3132,-1747.8889,10.4405},
{2856.3132,-1747.8889,10.4405, 2910.5881,-1545.1462,10.4405},
{2910.5881,-1545.1462,10.4405, 2917.6101,-1347.0300,10.4406},
{2917.6101,-1347.0300,10.4406, 0.0,0.0,0.0}
};
C++:
CMD:enrace(playerid)
{
switch(race)
{
case 0: race = 1;
case 1: race = 0;
default: race = 0;
}
SendClientMessage(playerid, -1, "Регистрация на гонки начата");
SetTimer("raceTimer", 1000*20, false);
return 1;
}
CMD:gotorace(playerid)
{
if(race == 0) return 1;
if(pTemp[playerid][pRacePart] == 1) return SendClientMessage(playerid, -1, "Вы уже на гонках");
if(TOTAL_RACE_PLAYER >= TOTAL_RACE_SLOTS) return SendClientMessage(playerid, -1, "Все места на гонки заняты");
pTemp[playerid][pRaceSlot] = TOTAL_RACE_PLAYER;
RaceFinalPlayerSlot = 0;
LapRace[playerid] = 1;
TOTAL_RACE_PLAYER++;
pTemp[playerid][pRacePart] = 1;
SendClientMessage(playerid, -1, "Вы зарегестрировались на гонки");
return 1;
}
C++:
forward raceTimer();
public raceTimer()
{
foreach(new i: Player)
{
if(pTemp[i][pRacePart] == 1)
{
new vehicleid;
switch(pTemp[i][pRaceSlot])
{
case 0:
{
SetPlayerPos(i, 2820.0583,-2122.3643,10.4996);
vehicleid = CreateVehicle(522, 2820.0583,-2122.3643,10.4996, 0.9730, -1, -1, 0);
PutPlayerInVehicle(i, vehicleid, 0);
}
}
LapRace[i] = 1;
SetPlayerRaceCheckpoint(i, 3, RaceCheckpoint[0][0], RaceCheckpoint[0][1], RaceCheckpoint[0][2], RaceCheckpoint[0][3], RaceCheckpoint[0][4], RaceCheckpoint[0][5], 6.0);
}
}
return 1;
}
C++:
public OnPlayerEnterRaceCheckpoint(playerid)
{
if(pTemp[playerid][pRacePart] > 0)
{
new string[128];
format(string, sizeof(string), "Вы проехали %d из %d чекпоинтов", LapRace[playerid], VolumeLapRace);
SendClientMessage(playerid, -1, string);
LapRace[playerid]++;
switch(LapRace[playerid])
{
case 2: SetPlayerRaceCheckpoint(playerid, 3,RaceCheckpoint[1][0], RaceCheckpoint[1][1], RaceCheckpoint[1][2], RaceCheckpoint[1][3], RaceCheckpoint[1][4], RaceCheckpoint[1][5], 6.0);
case 3: SetPlayerRaceCheckpoint(playerid, 3,RaceCheckpoint[2][0], RaceCheckpoint[2][1], RaceCheckpoint[2][2], RaceCheckpoint[2][3], RaceCheckpoint[2][4], RaceCheckpoint[2][5], 6.0);
case 4: SetPlayerRaceCheckpoint(playerid, 3,RaceCheckpoint[3][0], RaceCheckpoint[3][1], RaceCheckpoint[3][2], RaceCheckpoint[3][3], RaceCheckpoint[3][4], RaceCheckpoint[3][5], 6.0);
case 5: SetPlayerRaceCheckpoint(playerid, 3,RaceCheckpoint[4][0], RaceCheckpoint[4][1], RaceCheckpoint[4][2], RaceCheckpoint[4][3], RaceCheckpoint[4][4], RaceCheckpoint[4][5], 6.0);
case 6:
{
RaceFinalPlayerSlot++;
format(string, sizeof(string), "Вы завершили гонку и заняли %d место", RaceFinalPlayerSlot);
SendClientMessage(playerid, -1, string);
DestroyVehicle(GetPlayerVehicleID(playerid));
SpawnPlayer(playerid);
pTemp[playerid][pRacePart] = 0;
pTemp[playerid][pRaceSlot] = 0;
if(RaceFinalPlayerSlot >= TOTAL_RACE_SLOTS)
{
SendClientMessageToAll(-1, "Гонки закончились");
RaceFinalPlayerSlot = 0;
}
}
}
}
return 1;
}
Переделать это все под свой игровой мод не трудно. Моя задача донести до вас основную идею.
Последнее редактирование: