Урок 6
Привет ученик! Теперь делаем гонки в мод! Я конечно пока вставить не могу но в виде ФС гонки выглядят так: #include
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_LAVENDER 0xFF00FFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_LIGHTBLUEA 0xB5EAFCAA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_TEAL 0x3BAAC2AA
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
forward CheckpointUpdate();
forward GPRaceCountdown();
forward GPTimer();
//forward SaveTimes();
//forward LoadTimes();
forward UpdateList(playerid,TimeRec);
new Mototime[MAX_PLAYERS] =0;
new Motocountdown[MAX_PLAYERS] =-1;
new MotoGP[MAX_PLAYERS] = 0;
new MotoGate[MAX_PLAYERS]=0;
#define MAX_POINTS 1//СТАРТ ПОИНТ
#define MAX_RACE_POINTS 100//ЧИСЛО ГОНОЧНЫХ ПОИНТОВ
new cps = MAX_RACE_POINTS - 1;
#define TT_START 0
enum kinfo{
Driver[24],
Time
}
new KartHS[5][kinfo];
new playerCheckpoint[MAX_PLAYERS];
new Float:checkpoints[MAX_POINTS][3] = {//ТУТ СТАРТОВЫЙ ЧЕКПОИНТ
{1797.2352,2251.0757,4.9755}
};
new Float:racecheckpoints[MAX_RACE_POINTS][3] = {//ТУТ //ГОНОЧНЫЙ ЧЕКПОИНТЫ КОТОРЫЕ ВО ВРЕМЯ ГОНКИ
{1797.5144,1884.4104,6.6023},
{1797.4225,1594.3551,6.5990},
{1797.2001,1037.1470,6.5983},
{1798.2466,873.0827,10.5056},
{1622.680 4,843.2832,6.5982},
{1455.1434,833.6122,6.7112},
{956.8241,741.7051,10.7060},
{855.5547,703.4802,11.7664},
{649.3840,667.5455,7.0238},
{ 474.9632,725.6837,5.1012},
{262.4301,889.1722,22.1563},
{208.3201,1015.8774,25.4640},
{177.5087,1144.3633,14.1364},
{-45.9619,1260.6456, 9.2296},
{-219.7370,1238.8441,23.1402},
{-377.1374,1298.7002,24.7620},
{-431.9221,1412.6958,32.1904},
{-421.3441,1671.2706,37.3832},
{- 379.9946,1782.9468,46.7754},
{-432.1290,1879.7438,61.3342},
{-422.9137,1784.9297,70.9443},
{-466.8343,1788.7369,74.6976},
{-464.9256,196 9.0275,82.1220},
{-382.8337,2053.7739,61.7009},
{-419.7729,2064.5906,61.3606},
{-509.3027,1983.8544,60.0850},
{-646.8643,2054.9785,60.27 41},
{-837.4421,2021.8069,60.2786},
{-867.9402,1905.9733,60.1240},
{-908.3344,1790.4731,60.0592},
{-1033.2159,1852.7333,59.3001},
{-114 5.8105,1798.4552,40.3781},
{-1178.5577,1813.7426,40.9333},
{-1241.9475,1903.1709,42.1986},
{-1337.5841,2016.4515,54.1038},
{-1352.7341,2 171.2791,48.2466},
{-1423.9059,2336.1450,53.7300},
{-1431.6934,2472.4524,61.0890},
{-1351.1937,2631.4705,51.2857},
{-1412.7439,2714.7759 ,60.4720},
{-1633.9431,2728.4771,57.7567},
{-1799.4211,2693.7271,57.1111},
{-1913.2582,2617.7471,48.1832},
{-2195.0869,2676.2134,53.9009 },
{-2425.0469,2669.3765,60.9004},
{-2614.1509,2671.4880,76.8050},
{-2770.0366,2441.6501,92.3823},
{-2681.5408,2059.4980,56.1254},
{-26 81.1685,1756.4165,68.3772},
{-2681.5007,1367.2424,55.7080},
{-2679.5535,1239.2896,55.5204},
{-2464.9307,1104.8513,55.6742},
{-2286.8269, 1066.3125,55.6811},
{-1999.6361,1066.3679,55.4660},
{-1910.2255,1066.1985,47.5866},
{-1892.3218,988.5411,35.0888},
{-1898.7400,794.9924, 38.8297},
{-1897.8530,618.8192,34.9137},
{-1963.4152,605.6826,34.9150},
{-2001.6990,537.5637,34.9114},
{-2003.8684,353.3103,34.9113},
{ -2006.1154,97.0415,27.4348},
{-2005.6558,-106.2443,35.6536},
{-2010.5597,-288.2466,35.2158},
{-2155.9524,-341.7915,35.0796},
{-2372.5454 ,-334.8734,38.4070},
{-2754.2183,-438.3979,7.0646},
{-2820.9695,-443.0231,6.9347},
{-2812.4561,-310.5171,6.9269},
{-2808.9888,-179.3705, 6.9276},
{-2808.9644,2.2234,6.9277},
{-2810.2258,51.9202,6.9289},
{-2808.9358,139.8148,6.9265},
{-2765.1001,156.9801,6.9568},
{-2597.35 21,156.7976,4.0748},
{-2406.5889,251.8733,26.3285},
{-2208.2788,320.1814,35.0675},
{-2023.7981,324.1935,34.9411},
{-1935.6423,344.1543,3 2.3373},
{-1873.8748,402.7901,16.9899},
{-1839.1860,400.3513,16.9088},
{-1656.7661,555.5449,38.9824},
{-1511.4597,708.1401,45.6228},
{- 1342.0031,887.4564,46.9306},
{-1113.2859,1130.6921,37.4382},
{-912.4370,964.1341,17.8444},
{-821.1741,734.6368,18.6041},
{-595.8551,637. 3406,16.7214},
{-222.6646,565.2453,15.7750},
{280.7512,757.4127,6.1771},
{515.8831,703.0739,3.5536},
{966.9130,746.7089,10.7151},
{1142 .4872,837.7676,10.5735},
{1231.5911,1151.9949,6.7249},
{1217.0756,1280.3558,6.6020},
{1217.6578,1695.2532,6.6009},
{1216.2842,2108.6938, 6.5991},
{1593.5679,2456.3616,6.7015},
{1798.0892,2253.2261,5.0176},
{1797.2352,2251.0757,4.9755}
};
new checkpointType[MAX_POINTS] = {
TT_START
};
public OnFilterScriptInit()
{
print("\n Mode:RACE VITALAS[goDog] - делал Виталь.\n");
SetTimer("CheckpointUpdate",1000,1);
SetTimer("GPRaceCountdown",1000,1);
SetTimer("GPTimer",1000,1);
for(new t=0; t<5; t++)
{
strmid(KartHS[t][Driver], "None", 0, strlen("None"), 24);
KartHS[t][Time]=100000;
}
// if(!fexist("Петушиный ФрирайдTimes.cfg"))
// SaveTimes();
// LoadTimes();
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(getCheckpointType(playerid)!=TT_START)
{
SendClientMessage(playerid,COLOR_GREEN," Ты не в стартовой позиции.");
return 1;
}
if (strcmp("/start", cmdtext, true, 10) == 0)
{//команда на старт гонки
if(!IsVehicle(playerid))
{
new fstr[255];
format(fstr,sizeof(fstr),"You must be in a %s to participate in this.");
SendClientMessage(playerid,COLOR_GREEN,fstr);
return 1;
}
SendClientMessage(playerid, COLOR_GREEN,"Старт...");
TogglePlayerControllable(playerid,0);
Motocountdown[playerid] = 6;
SetPlayerRaceCheckpoint(playerid,0,racecheckpoints[0][0],racecheckpoints[0][1],racecheckpoints[0][2],racecheckpoints[1][0],racecheckpoints[1][1],racecheckpoints[1][2],25);
DisablePlayerCheckpoint(playerid);
return 1;
}
if (strcmp("0", cmdtext, true, 10) == 0)
{
new kstring[255];
SendClientMessage(playerid,COLOR_GREEN," 5 лучших по времени:");
for(new z=0; z<5; z++)
{
new sec = KartHS[z][Time]%60;
new mins = (KartHS[z][Time]/60)%60;
if (strcmp("None",KartHS[z][Driver], true, 10) == 0)
{
if(z==0)
SendClientMessage(playerid,COLOR_GREY,"-No Times Recorded Yet-");
if(z>0)
SendClientMessage(playerid,COLOR_GREY,"-End Of Time Sheet-");
return 1;
}
if(strcmp("None",KartHS[z][Driver], true,10) != 0)
{
if(sec > 9) {format(kstring,sizeof(kstring),"%d. %s - %d:%d",z+1,KartHS[z][Driver],mins,sec);}
if(sec < 9) {format(kstring,sizeof(kstring),"%d. %s - %d:0%d",z+1,KartHS[z][Driver],mins,sec);}
SendClientMessage(playerid,COLOR_GREY,kstring);
}
}
return 1;
}
return 0;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
new sec = Mototime[playerid]%60;
new mins = (Mototime[playerid]/60)%60;
if(MotoGP[playerid] == 1)
{
MotoGate[playerid]++;
new one = MAX_RACE_POINTS-2;
new two = MAX_RACE_POINTS-1;
if(MotoGate[playerid] < one)
{
DisablePlayerRaceCheckpoint(playerid);
SetPlayerRaceCheckpoint(playerid,0,racecheckpoints[MotoGate[playerid]][0],racecheckpoints[MotoGate[playerid]][1],racecheckpoints[MotoGate[playerid]][2],racecheckpoints[MotoGate[playerid]+1][0],racecheckpoints[MotoGate[playerid]+1][1],racecheckpoints[MotoGate[playerid]+1][2],25);
}
if(MotoGate[playerid] == one)
{
DisablePlayerRaceCheckpoint(playerid);
SetPlayerRaceCheckpoint(playerid,1,racecheckpoints[MotoGate[playerid]][0],racecheckpoints[MotoGate[playerid]][1],racecheckpoints[MotoGate[playerid]][2],racecheckpoints[MotoGate[playerid]+1][0],racecheckpoints[MotoGate[playerid]+1][1],racecheckpoints[MotoGate[playerid]+1][2],25);
}
if(MotoGate[playerid] == two)
{
new TimeRec;
new Timestr[255];
new driver[24];
GetPlayerName(playerid,driver,sizeof(driver));
format(Timestr,sizeof(Timestr),"%s финишировал в гонке 2х Континентов за %d мин:%d сек",driver,mins,sec);
GivePlayerMoney(playerid,1500) ;
SendClientMessageToAll(COLOR_WHITE,Timestr);
SendClientMessage(playerid,COLOR_WHITE,"Ты попал в 5-ку лучших по времени.");
printf(Timestr);
TimeRec=Mototime[playerid];
MotoGP[playerid] = 0;
MotoGate[playerid] = 0;
DisablePlayerRaceCheckpoint(playerid);
Mototime[playerid]=0;
UpdateList(playerid,TimeRec);
}
}
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
if(getCheckpointType(playerid)==TT_START)
{
if(IsVehicle(playerid) == 1)
{
SendClientMessage(playerid,COLOR_GREEN,"Нажми /start для старта .");
return 1;
}
if(IsVehicle(playerid) == 0)
{
SendClientMessage(playerid,COLOR_GREEN,"Ты не в машине!");
return 1;
}
}
return 1;
}
stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
return 0;
}
public UpdateList(playerid, TimeRec)
{
new driver[24];
GetPlayerName(playerid,driver,sizeof(driver));
if(KartHS[0][Time] > TimeRec)
{
KartHS[4][Time] = KartHS[3][Time];
strmid(KartHS[4][Driver],KartHS[3][Driver],0,sizeof(driver),24);
KartHS[3][Time] = KartHS[2][Time];
strmid(KartHS[3][Driver],KartHS[2][Driver],0,sizeof(driver),24);
KartHS[2][Time] = KartHS[1][Time];
strmid(KartHS[2][Driver],KartHS[1][Driver],0,sizeof(driver),24);
KartHS[1][Time] = KartHS[0][Time];
strmid(KartHS[1][Driver],KartHS[0][Driver],0,sizeof(driver),24);
KartHS[0][Time] = TimeRec;
strmid(KartHS[0][Driver],driver,0,sizeof(driver),24);
SendClientMessage(playerid,COLOR_GREY,"Ты на 1-ом месте!");
GivePlayerMoney(playerid,10000);
}
else if(KartHS[1][Time] > TimeRec)
{
KartHS[4][Time] = KartHS[3][Time];
strmid(KartHS[4][Driver],KartHS[3][Driver],0,sizeof(driver),24);
KartHS[3][Time] = KartHS[2][Time];
strmid(KartHS[3][Driver],KartHS[2][Driver],0,sizeof(driver),24);
KartHS[2][Time] = KartHS[1][Time];
strmid(KartHS[2][Driver],KartHS[1][Driver],0,sizeof(driver),24);
KartHS[1][Time] = TimeRec;
strmid(KartHS[1][Driver],driver,0,sizeof(driver),24);
SendClientMessage(playerid,COLOR_GREY,"Ты на 2-ом месте!");
GivePlayerMoney(playerid,7500);
}
else if(KartHS[2][Time] > TimeRec)
{
KartHS[4][Time] = KartHS[3][Time];
strmid(KartHS[4][Driver],KartHS[3][Driver],0,sizeof(driver),24);
KartHS[3][Time] = KartHS[2][Time];
strmid(KartHS[3][Driver],KartHS[2][Driver],0,sizeof(driver),24);
KartHS[2][Time] = TimeRec;
strmid(KartHS[2][Driver],driver,0,sizeof(driver),24);
SendClientMessage(playerid,COLOR_GREY,"Ты на 3-ем месте!");
GivePlayerMoney(playerid,5000);
}
else if(KartHS[3][Time] > TimeRec)
{
KartHS[4][Time] = KartHS[3][Time];
strmid(KartHS[4][Driver],KartHS[3][Driver],0,sizeof(driver),24);
KartHS[3][Time] = TimeRec;
strmid(KartHS[3][Driver],driver,0,sizeof(driver),24);
SendClientMessage(playerid,COLOR_GREY,"Ты на 4 месте!");
GivePlayerMoney(playerid,2500);
}
else if(KartHS[4][Time] > TimeRec)
{
KartHS[4][Time] = TimeRec;
strmid(KartHS[4][Driver],driver,0,sizeof(driver),24);
SendClientMessage(playerid,COLOR_GREY,"Ты на 5-ом месте!");
GivePlayerMoney(playerid,1000);
}
return 1;
}
public CheckpointUpdate()
{
for(new i; i {
if(MotoGP[i] == 0)
{
for(new j=0; j < 1; j++) {
if(PlayerToPoint(25,i,checkpoints[j][0],checkpoints[j][1],checkpoints[j][2])) {
if(playerCheckpoint[i]!=j) {
DisablePlayerCheckpoint(i);
SetPlayerCheckpoint(i, checkpoints[j][0],checkpoints[j][1],checkpoints[j][2],15);
playerCheckpoint[i] = j;
}
} else {
if(playerCheckpoint[i]==j) {
DisablePlayerCheckpoint(i);
playerCheckpoint[i] = 100;//ХЗ
}
}
}
}
}
}
stock IsVehicle(playerid)
{
new model = GetPlayerVehicleID(playerid);
// model = GetVehicleModel(model);
// if(model == 573)
return 1;
// else
return 0;
}
stock getCheckpointType(playerID) {
if(playerCheckpoint[playerID] != 100)//ХЗ
return checkpointType[playerCheckpoint[playerID]];
else return -1;
}
public GPRaceCountdown()
{
for(new x=0; x {
if(Motocountdown[x] > 0)
{
new time[3];
Motocountdown[x]--;
format(time,sizeof(time),"%d",Motocountdown[x]);
GameTextForPlayer(x,time,1200,3);
}
if(Motocountdown[x] == 0)
{
GameTextForPlayer(x," GO GO GO!",1200,3);
TogglePlayerControllable(x,1);
Motocountdown[x]--;
Mototime[x]=0;
MotoGP[x]=1;
}
}
}
public GPTimer()
{
for(new i=0; i {
new progress[255];
new sec = Mototime[i]%60;
new mins = (Mototime[i]/60)%60;
if(MotoGP[i] == 1)
{
Mototime[i]++;
if(sec > 9 ) { format(progress,sizeof(progress),"~b~Race %d/%d Checkpoints Achieved. Current Time: %d:%d",MotoGate[i],cps,mins,sec);}//~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~
if(sec <10 ) { format(progress,sizeof(progress),"~b~Race: %d/%d Checkpoints Achieved. Current Time: %d:0%d",MotoGate[i],cps,mins,sec);}//~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~
// GameTextForPlayer(i,progress,1200,3);
new Text:Time = TextDrawCreate(320.0, 260.0, "i");
}
}
}
stock DelPrint(string1[])
{
strmid(string1, string1, 0, strlen(string1)-1, 255);
printf("%s", string1);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
DisablePlayerRaceCheckpoint(playerid);
return 1;
}
Урок окончен...