Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <dudb>
- #include <colors>
- #include <zcmd>
- #define MIEJSCA 20
- new place, Miejsc = MIEJSCA, TrwajaZapisy, Czas, Text:Zapis[5], string5[128],
- car[MIEJSCA], Timer, Timer2, Zapisanych, TimerKoniec;
- new Float:race[4][3] = {
- {615.3611, 1204.6102, 11.7188},
- {713.8354, 1151.5127, 18.6087},
- {813.9896, 1140.8918, 29.2188},
- {910.7899, 973.2886, 12.6588}
- };
- /*
- new Float:race[22][3] = {
- {615.3611, 1204.6102, 11.7188},
- {713.8354, 1151.5127, 18.6087},
- {813.9896, 1140.8918, 29.2188},
- {910.7899, 973.2886, 12.6588},
- {905.9996, 904.0521, 12.6588},
- {786.7798, 837.5287, 11.9088},
- {768.4978, 892.2958, 1.4488},
- {686.5998, 974.9083, -4.7612},
- {710.4655, 915.3843, -13.7612},
- {723.2537, 883.9349, -25.2612},
- {657.0000, 953.5000, -25.000},
- {520.0766, 903.7183, -34.291},
- {492.7228, 848.7427, -24.651},
- {534.0397, 785.3353, -16.7612},
- {619.0856, 752.7917, -8.0512},
- {676.3746, 748.3087, -3.6612},
- {758.7260, 771.2565, -0.1612},
- {780.3107, 816.7007, 6.8388},
- {830.1301, 849.3740, 15.7988},
- {838.8344, 769.7183, 25.3288},
- {932.8493, 737.3365, 17.1188},
- {1033.8295, 736.5201, 10.8203}
- };
- */
- new Float:PozycjeAut[20][4] = {
- {466.3150, 1174.0455, 8.1881,287.99560547},
- {466.9623, 1172.9762, 8.1881,287.99560547},
- {467.0526, 1171.8613, 8.1881,287.99560547},
- {467.6996, 1170.7926, 8.1881,287.99560547},
- {468.1333, 1169.5936, 8.1881,287.99560547},
- {468.4373, 1168.6082, 8.1881,287.99560547},
- {468.7410, 1167.6228, 8.1881,287.99560547},
- {469.2897, 1166.5190, 8.1881,287.99560547},
- {469.6838, 1165.4203, 8.1881,287.99560547},
- {470.2321, 1164.4822, 8.1881,287.99560547},
- {470.4562, 1163.5068, 8.1881,287.99560547},
- {470.8805, 1162.2295, 8.1881,287.99560547},
- {471.3342, 1161.4512, 8.1881,287.99560547},
- {471.5238, 1160.4382, 8.1881,287.99560547},
- {471.9628, 1159.4097, 8.1881,287.99560547},
- {472.6658, 1158.6160, 8.1881,287.99560547},
- {465.8843, 1175.0457, 8.1881,287.99560547},
- {465.4444, 1176.0728, 8.1881,287.99560547},
- {465.0831, 1177.1078, 8.1881,287.99560547},
- {464.8221, 1178.1849, 8.1881,287.99560547}
- };
- new Float:spawn[22][3] = {
- {1958.3783,1343.1572,15.3746},
- {2199.6531,1393.3678,10.8203},
- {2483.5977,1222.0825,10.8203},
- {2637.2712,1129.2743,11.1797},
- {2000.0106,1521.1111,17.0625},
- {2024.8190,1917.9425,12.3386},
- {2261.9048,2035.9547,10.8203},
- {2262.0986,2398.6572,10.8203},
- {2244.2566,2523.7280,10.8203},
- {2335.3228,2786.4478,10.8203},
- {2150.0186,2734.2297,11.1763},
- {2158.0811,2797.5488,10.8203},
- {1969.8301,2722.8564,10.8203},
- {1652.0555,2709.4072,10.8265},
- {1564.0052,2756.9463,10.8203},
- {1271.5452,2554.0227,10.8203},
- {1441.5894,2567.9099,10.8203},
- {1480.6473,2213.5718,11.0234},
- {1400.5906,2225.6960,11.0234},
- {1598.8419,2221.5676,11.0625},
- {1318.7759,1251.3580,10.8203},
- {1558.0731,1007.8292,10.8125}
- };
- forward Zapisy();
- forward Odlicz();
- public OnFilterScriptInit()
- {
- Zapis[0] = TextDrawCreate(310.0, 283.0, "Wyscig !");
- TextDrawAlignment(Zapis[0], 2);
- TextDrawBackgroundColor(Zapis[0], 255);
- TextDrawFont(Zapis[0], 1);
- TextDrawLetterSize(Zapis[0], 0.5, 1.3);
- TextDrawColor(Zapis[0], -1);
- TextDrawSetOutline(Zapis[0], 1);
- TextDrawSetProportional(Zapis[0], 1);
- Zapis[1] = TextDrawCreate(462.0, 370.0, "~n~");
- TextDrawBackgroundColor(Zapis[1], 255);
- TextDrawFont(Zapis[1], 1);
- TextDrawLetterSize(Zapis[1], 0.37, -11.099998);
- TextDrawColor(Zapis[1], -1);
- TextDrawSetOutline(Zapis[1], 0);
- TextDrawSetProportional(Zapis[1], 1);
- TextDrawSetShadow(Zapis[1], 1);
- TextDrawUseBox(Zapis[1], 1);
- TextDrawBoxColor(Zapis[1], 65);
- TextDrawTextSize(Zapis[1], 162.0, 43.0);
- Zapis[2] = TextDrawCreate(261.0, 304.0, "Dolacz do ~g~/race ~w~!");
- TextDrawBackgroundColor(Zapis[2], 255);
- TextDrawFont(Zapis[2], 1);
- TextDrawLetterSize(Zapis[2], 0.349999, 1.0);
- TextDrawColor(Zapis[2], -1);
- TextDrawSetOutline(Zapis[2], 1);
- TextDrawSetProportional(Zapis[2], 1);
- Zapis[3] = TextDrawCreate(236.0, 324.0, "Zapisanych osob: ~b~0/20");
- TextDrawBackgroundColor(Zapis[3], 255);
- TextDrawFont(Zapis[3], 1);
- TextDrawLetterSize(Zapis[3], 0.379999, 1.0);
- TextDrawColor(Zapis[3], -1);
- TextDrawSetOutline(Zapis[3], 1);
- TextDrawSetProportional(Zapis[3], 1);
- Zapis[4] = TextDrawCreate(224.0, 344.0, "Pozostalo ~r~30 ~w~sekund.");
- TextDrawBackgroundColor(Zapis[4], 255);
- TextDrawFont(Zapis[4], 1);
- TextDrawLetterSize(Zapis[4], 0.49, 1.1);
- TextDrawColor(Zapis[4], -1);
- TextDrawSetOutline(Zapis[4], 1);
- TextDrawSetProportional(Zapis[4], 1);
- return 1;
- }
- CMD:koniecrace(playerid, params[])
- {
- KillTimer(TimerKoniec);
- SetPVarInt(playerid, "ZapisalSieNaWyscig", 0);
- DeletePVar(playerid,"CP");
- DestroyVehicle(car[GetPVarInt(playerid, "cos")]);
- Zapisanych--;
- new rand = random(sizeof spawn);
- SetPlayerPos(playerid, spawn[rand][0], spawn[rand][1], spawn[rand][2]);
- for(new x=0; x<GetMaxPlayers(); x++)
- {
- if(IsPlayerConnected(x) && (GetPVarInt(x, "ZapisalSieNaWyscig")==1))
- {
- SetPVarInt(x, "ZapisalSieNaWyscig", 0);
- DeletePVar(x,"CP");
- DestroyVehicle(car[GetPVarInt(x, "cos")]);
- Zapisanych--;
- SetPlayerPos(x, spawn[rand][0], spawn[rand][1], spawn[rand][2]);
- }
- }
- return 1;
- }
- CMD:race(playerid, params[])
- {
- if(!TrwajaZapisy)
- return SendClientMessage(playerid, CZERWONY, "Nie ma zapisów do wyścigu!");
- if(GetPVarInt(playerid, "ZapisalSieNaWyscig"))
- return SendClientMessage(playerid, CZERWONY, "Zapisałeś się na wyścig!");
- SendClientMessage(playerid, ZIELONY, "Zapisałeś się na wyścig!");
- new str_nick[64];
- format(str_nick, sizeof str_nick, "Gracz %s zapisał się na wyśćig !",PlayerName(playerid));
- SendClientMessageToAll(0x80FF80FF,str_nick);
- Miejsc--;
- SetPVarInt(playerid, "ZapisalSieNaWyscig", 1);
- Zapisanych++;
- return 1;
- }
- CMD:startrace(playerid, params[])
- {
- if(!IsPlayerAdmin(playerid))
- return SendClientMessage(playerid, CZERWONY, "Nie jesteś administratorem!");
- if(TrwajaZapisy)
- return SendClientMessage(playerid, CZERWONY, "Obecnie trwają zapisy na race!");
- Timer = SetTimer("Zapisy", 1000, true);
- Czas = 10;
- Zapisanych = 0;
- TrwajaZapisy = 1;
- format(string5, sizeof string5, "Zapisanych osob: ~b~%d/%d", MIEJSCA-Miejsc, MIEJSCA);
- TextDrawSetString(Zapis[3], string5);
- format(string5, sizeof string5, "Pozostalo ~r~%d ~w~sekund.", Czas);
- TextDrawSetString(Zapis[4], string5);
- TextDrawShowForAll(Zapis[0]);
- TextDrawShowForAll(Zapis[1]);
- TextDrawShowForAll(Zapis[2]);
- TextDrawShowForAll(Zapis[3]);
- TextDrawShowForAll(Zapis[4]);
- TimerKoniec = SetTimer("fkoniecrace",1000,true);
- for(new i = 0; i < MIEJSCA; i++)
- DestroyVehicle(car[i]);
- for(new i = 0; i != MIEJSCA; i++)
- car[i] = CreateVehicle(468, PozycjeAut[i][0], PozycjeAut[i][1], PozycjeAut[i][2], PozycjeAut[i][3], 0, 0, 1);
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- SetPVarInt(playerid, "CP", GetPVarInt(playerid, "CP") +1);
- new y = GetPVarInt(playerid, "CP");
- switch(y)
- {
- case 1..2: SetPlayerRaceCheckpoint(playerid,0,race[y][0],race[y][1],race[y][2],race[y+1][0],race[y+1][1],race[y+1][2],10);
- case 3: SetPlayerRaceCheckpoint(playerid,1,race[y][0],race[y][1],race[y][2],0,0,0,10);
- case 4:
- {
- DisablePlayerRaceCheckpoint(playerid);
- place++;
- switch(place)
- {
- case 1:
- {
- format(string5, sizeof(string5), "Gracz %s ukończył wyścig jako pierwszy", PlayerName(playerid));
- SetPlayerScore(playerid, GetPlayerScore(playerid) + 14);
- GivePlayerMoney(playerid, 10000);
- }
- case 2:
- {
- format(string5,sizeof(string5),"Gracz %s ukończył wyścig jako drugi",PlayerName(playerid));
- SetPlayerScore(playerid, GetPlayerScore(playerid) + 9);
- GivePlayerMoney(playerid, 5000);
- }
- case 3:
- {
- format(string5,sizeof(string5),"Gracz %s ukończył wyścig jako trzeci",PlayerName(playerid));
- SetPlayerScore(playerid, GetPlayerScore(playerid) + 4);
- GivePlayerMoney(playerid, 1000);
- }
- }
- if(!strlen(string5))
- format(string5,sizeof(string5),"Gracz %s ukończył wyścig na miejscu %d",PlayerName(playerid),place);
- SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
- SendClientMessageToAll(NIEBIESKI,string5);
- SetPVarInt(playerid, "ZapisalSieNaWyscig", 0);
- DeletePVar(playerid,"CP");
- DestroyVehicle(car[GetPVarInt(playerid, "cos")]);
- Zapisanych--;
- new rand = random(sizeof spawn);
- SetPlayerPos(playerid, spawn[rand][0], spawn[rand][1], spawn[rand][2]);
- }
- }
- return 1;
- }
- public Zapisy()
- {
- if(Czas >= 1)
- {
- format(string5, sizeof string5, "Zapisanych osob: ~b~%d/%d", MIEJSCA-Miejsc, MIEJSCA);
- TextDrawSetString(Zapis[3], string5);
- format(string5, sizeof string5, "Pozostalo ~r~%d ~w~sekund.", Czas);
- TextDrawSetString(Zapis[4], string5);
- }
- if(Czas == 0 || Miejsc == 0)
- {
- if(Miejsc >= MIEJSCA - 1)
- {
- for(new i = 0; i < MIEJSCA; i++)
- DestroyVehicle(car[i]);
- KillTimer(Timer);
- TextDrawHideForAll(Zapis[0]);
- TextDrawHideForAll(Zapis[1]);
- TextDrawHideForAll(Zapis[2]);
- TextDrawHideForAll(Zapis[3]);
- TextDrawHideForAll(Zapis[4]);
- for(new i = 0; i < GetMaxPlayers(); i++)
- SetPVarInt(i, "ZapisalSieNaWyscig", 0);
- TrwajaZapisy = 0;
- return SendClientMessageToAll(CZERWONY, "Wyścig nie wystartował, zapisało się za mało osób!");
- }
- KillTimer(Timer);
- Timer2 = SetTimer("Odlicz", 1000, 1);
- Czas = 5;
- TextDrawHideForAll(Zapis[0]);
- TextDrawHideForAll(Zapis[1]);
- TextDrawHideForAll(Zapis[2]);
- TextDrawHideForAll(Zapis[3]);
- TextDrawHideForAll(Zapis[4]);
- new cos;
- for(new i = 0; i < GetMaxPlayers(); i++)
- {
- if(!GetPVarInt(i, "ZapisalSieNaWyscig"))
- continue;
- SetPVarInt(i, "cos", cos);
- PutPlayerInVehicle(i, car[cos++], 0);
- TogglePlayerControllable(i, false);
- }
- cos = 0;
- return 1;
- }
- Czas--;
- return 1;
- }
- public Odlicz()
- {
- if(Czas >= 1 )
- {
- format(string5, sizeof string5, "~n~~n~~n~~g~%d", Czas);
- GameTextForAll(string5, 1100, 5);
- }
- if(Czas == 0)
- {
- KillTimer(Timer2);
- TrwajaZapisy = 0;
- Miejsc = MIEJSCA;
- place = 0;
- for(new i = 0; i < GetMaxPlayers(); i++)
- {
- if(!GetPVarInt(i, "ZapisalSieNaWyscig"))
- continue;
- GameTextForPlayer(i, "~n~~n~~n~~g~START!", 1000, 5);
- TogglePlayerControllable(i, true);
- SetPlayerRaceCheckpoint(i, 0, race[0][0], race[0][1], race[0][2], race[1][0], race[1][1], race[1][2], 10);
- SetPVarInt(i, "ZapisalSieNaWyscig", 1);
- }
- return 1;
- }
- Czas--;
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- if(GetPVarInt(playerid, "ZapisalSieNaWyscig") == 1)
- {
- DestroyVehicle(vehicleid);
- SetPVarInt(playerid, "ZapisalSieNaWyscig", 0);
- SendClientMessage(playerid, CZERWONY, "Odpadasz z wyścigu !");
- new rand = random(sizeof spawn);
- SetPlayerPos(playerid, spawn[rand][0], spawn[rand][1], spawn[rand][2]);
- Zapisanych--;
- DeletePVar(playerid,"CP");
- DisablePlayerRaceCheckpoint(playerid);
- if(Zapisanych == 0)
- return SendClientMessage(playerid, CZERWONY, "Wyścig sie zakończył !");
- }
- return 1;
- }
- forward fkoniecrace(playerid);
- public fkoniecrace(playerid)
- {
- if(!TrwajaZapisy)
- {
- if(Zapisanych == 0)
- {
- SetPVarInt(playerid, "Koniecwysciogow",1);
- KillTimer(TimerKoniec);
- SetPVarInt(playerid, "ZapisalSieNaWyscig", 0);
- DeletePVar(playerid,"CP");
- DestroyVehicle(car[GetPVarInt(playerid, "cos")]);
- Zapisanych--;
- new rand = random(sizeof spawn);
- for(new x=0; x<GetMaxPlayers(); x++)
- {
- if(IsPlayerConnected(x) && (GetPVarInt(x, "ZapisalSieNaWyscig")==1))
- {
- SetPVarInt(x, "ZapisalSieNaWyscig", 0);
- DeletePVar(x,"CP");
- DestroyVehicle(car[GetPVarInt(x, "cos")]);
- Zapisanych--;
- SetPlayerPos(x, spawn[rand][0], spawn[rand][1], spawn[rand][2]);
- }
- }
- }
- }
- return 1;
- }
- stock PlayerName(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof(name));
- return name;
- }
Advertisement
Add Comment
Please, Sign In to add comment