Slasheer

Untitled

Aug 14th, 2011
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 13.58 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dudb>
  3. #include <colors>
  4. #include <zcmd>
  5.  
  6. #define MIEJSCA 20
  7.  
  8. new place, Miejsc = MIEJSCA, TrwajaZapisy, Czas, Text:Zapis[5], string5[128],
  9.     car[MIEJSCA], Timer, Timer2, Zapisanych, TimerKoniec;
  10.  
  11. new Float:race[4][3] = {
  12.     {615.3611, 1204.6102, 11.7188},
  13.     {713.8354, 1151.5127, 18.6087},
  14.     {813.9896, 1140.8918, 29.2188},
  15.     {910.7899, 973.2886, 12.6588}
  16.     };
  17.  
  18.     /*
  19.     new Float:race[22][3] = {
  20.     {615.3611, 1204.6102, 11.7188},
  21.     {713.8354, 1151.5127, 18.6087},
  22.     {813.9896, 1140.8918, 29.2188},
  23.     {910.7899, 973.2886, 12.6588},
  24.     {905.9996, 904.0521, 12.6588},
  25.     {786.7798, 837.5287, 11.9088},
  26.     {768.4978, 892.2958, 1.4488},
  27.     {686.5998, 974.9083, -4.7612},
  28.     {710.4655, 915.3843, -13.7612},
  29.     {723.2537, 883.9349, -25.2612},
  30.     {657.0000, 953.5000, -25.000},
  31.     {520.0766, 903.7183, -34.291},
  32.     {492.7228, 848.7427, -24.651},
  33.     {534.0397, 785.3353, -16.7612},
  34.     {619.0856, 752.7917, -8.0512},
  35.     {676.3746, 748.3087, -3.6612},
  36.     {758.7260, 771.2565, -0.1612},
  37.     {780.3107, 816.7007, 6.8388},
  38.     {830.1301, 849.3740, 15.7988},
  39.     {838.8344, 769.7183, 25.3288},
  40.     {932.8493, 737.3365, 17.1188},
  41.     {1033.8295, 736.5201, 10.8203}
  42.     };
  43.     */
  44.  
  45. new Float:PozycjeAut[20][4] = {
  46.     {466.3150, 1174.0455, 8.1881,287.99560547},
  47.     {466.9623, 1172.9762, 8.1881,287.99560547},
  48.     {467.0526, 1171.8613, 8.1881,287.99560547},
  49.     {467.6996, 1170.7926, 8.1881,287.99560547},
  50.     {468.1333, 1169.5936, 8.1881,287.99560547},
  51.     {468.4373, 1168.6082, 8.1881,287.99560547},
  52.     {468.7410, 1167.6228, 8.1881,287.99560547},
  53.     {469.2897, 1166.5190, 8.1881,287.99560547},
  54.     {469.6838, 1165.4203, 8.1881,287.99560547},
  55.     {470.2321, 1164.4822, 8.1881,287.99560547},
  56.     {470.4562, 1163.5068, 8.1881,287.99560547},
  57.     {470.8805, 1162.2295, 8.1881,287.99560547},
  58.     {471.3342, 1161.4512, 8.1881,287.99560547},
  59.     {471.5238, 1160.4382, 8.1881,287.99560547},
  60.     {471.9628, 1159.4097, 8.1881,287.99560547},
  61.     {472.6658, 1158.6160, 8.1881,287.99560547},
  62.     {465.8843, 1175.0457, 8.1881,287.99560547},
  63.     {465.4444, 1176.0728, 8.1881,287.99560547},
  64.     {465.0831, 1177.1078, 8.1881,287.99560547},
  65.     {464.8221, 1178.1849, 8.1881,287.99560547}
  66. };
  67.  
  68. new Float:spawn[22][3] = {
  69.     {1958.3783,1343.1572,15.3746},
  70.     {2199.6531,1393.3678,10.8203},
  71.     {2483.5977,1222.0825,10.8203},
  72.     {2637.2712,1129.2743,11.1797},
  73.     {2000.0106,1521.1111,17.0625},
  74.     {2024.8190,1917.9425,12.3386},
  75.     {2261.9048,2035.9547,10.8203},
  76.     {2262.0986,2398.6572,10.8203},
  77.     {2244.2566,2523.7280,10.8203},
  78.     {2335.3228,2786.4478,10.8203},
  79.     {2150.0186,2734.2297,11.1763},
  80.     {2158.0811,2797.5488,10.8203},
  81.     {1969.8301,2722.8564,10.8203},
  82.     {1652.0555,2709.4072,10.8265},
  83.     {1564.0052,2756.9463,10.8203},
  84.     {1271.5452,2554.0227,10.8203},
  85.     {1441.5894,2567.9099,10.8203},
  86.     {1480.6473,2213.5718,11.0234},
  87.     {1400.5906,2225.6960,11.0234},
  88.     {1598.8419,2221.5676,11.0625},
  89.     {1318.7759,1251.3580,10.8203},
  90.     {1558.0731,1007.8292,10.8125}
  91. };
  92.  
  93. forward Zapisy();
  94. forward Odlicz();
  95.  
  96. public OnFilterScriptInit()
  97. {
  98.     Zapis[0] = TextDrawCreate(310.0, 283.0, "Wyscig !");
  99.     TextDrawAlignment(Zapis[0], 2);
  100.     TextDrawBackgroundColor(Zapis[0], 255);
  101.     TextDrawFont(Zapis[0], 1);
  102.     TextDrawLetterSize(Zapis[0], 0.5, 1.3);
  103.     TextDrawColor(Zapis[0], -1);
  104.     TextDrawSetOutline(Zapis[0], 1);
  105.     TextDrawSetProportional(Zapis[0], 1);
  106.  
  107.     Zapis[1] = TextDrawCreate(462.0, 370.0, "~n~");
  108.     TextDrawBackgroundColor(Zapis[1], 255);
  109.     TextDrawFont(Zapis[1], 1);
  110.     TextDrawLetterSize(Zapis[1], 0.37, -11.099998);
  111.     TextDrawColor(Zapis[1], -1);
  112.     TextDrawSetOutline(Zapis[1], 0);
  113.     TextDrawSetProportional(Zapis[1], 1);
  114.     TextDrawSetShadow(Zapis[1], 1);
  115.     TextDrawUseBox(Zapis[1], 1);
  116.     TextDrawBoxColor(Zapis[1], 65);
  117.     TextDrawTextSize(Zapis[1], 162.0, 43.0);
  118.  
  119.     Zapis[2] = TextDrawCreate(261.0, 304.0, "Dolacz do ~g~/race ~w~!");
  120.     TextDrawBackgroundColor(Zapis[2], 255);
  121.     TextDrawFont(Zapis[2], 1);
  122.     TextDrawLetterSize(Zapis[2], 0.349999, 1.0);
  123.     TextDrawColor(Zapis[2], -1);
  124.     TextDrawSetOutline(Zapis[2], 1);
  125.     TextDrawSetProportional(Zapis[2], 1);
  126.  
  127.     Zapis[3] = TextDrawCreate(236.0, 324.0, "Zapisanych osob: ~b~0/20");
  128.     TextDrawBackgroundColor(Zapis[3], 255);
  129.     TextDrawFont(Zapis[3], 1);
  130.     TextDrawLetterSize(Zapis[3], 0.379999, 1.0);
  131.     TextDrawColor(Zapis[3], -1);
  132.     TextDrawSetOutline(Zapis[3], 1);
  133.     TextDrawSetProportional(Zapis[3], 1);
  134.  
  135.     Zapis[4] = TextDrawCreate(224.0, 344.0, "Pozostalo ~r~30 ~w~sekund.");
  136.     TextDrawBackgroundColor(Zapis[4], 255);
  137.     TextDrawFont(Zapis[4], 1);
  138.     TextDrawLetterSize(Zapis[4], 0.49, 1.1);
  139.     TextDrawColor(Zapis[4], -1);
  140.     TextDrawSetOutline(Zapis[4], 1);
  141.     TextDrawSetProportional(Zapis[4], 1);
  142.  
  143.     return 1;
  144. }
  145.  
  146.     CMD:koniecrace(playerid, params[])
  147.     {
  148.             KillTimer(TimerKoniec);
  149.             SetPVarInt(playerid, "ZapisalSieNaWyscig", 0);
  150.             DeletePVar(playerid,"CP");
  151.             DestroyVehicle(car[GetPVarInt(playerid, "cos")]);
  152.             Zapisanych--;
  153.             new rand = random(sizeof spawn);
  154.             SetPlayerPos(playerid, spawn[rand][0], spawn[rand][1], spawn[rand][2]);
  155.             for(new x=0; x<GetMaxPlayers(); x++)
  156.             {
  157.             if(IsPlayerConnected(x) && (GetPVarInt(x, "ZapisalSieNaWyscig")==1))
  158.             {
  159.             SetPVarInt(x, "ZapisalSieNaWyscig", 0);
  160.             DeletePVar(x,"CP");
  161.             DestroyVehicle(car[GetPVarInt(x, "cos")]);
  162.             Zapisanych--;
  163.             SetPlayerPos(x, spawn[rand][0], spawn[rand][1], spawn[rand][2]);
  164.             }
  165.             }
  166.             return 1;
  167.     }
  168.  
  169.     CMD:race(playerid, params[])
  170. {
  171.  
  172.         if(!TrwajaZapisy)
  173.             return SendClientMessage(playerid, CZERWONY, "Nie ma zapisów do wyścigu!");
  174.  
  175.         if(GetPVarInt(playerid, "ZapisalSieNaWyscig"))
  176.             return SendClientMessage(playerid, CZERWONY, "Zapisałeś się na wyścig!");
  177.  
  178.         SendClientMessage(playerid, ZIELONY, "Zapisałeś się na wyścig!");
  179.         new str_nick[64];
  180.         format(str_nick, sizeof str_nick, "Gracz %s zapisał się na wyśćig !",PlayerName(playerid));
  181.         SendClientMessageToAll(0x80FF80FF,str_nick);
  182.         Miejsc--;
  183.         SetPVarInt(playerid, "ZapisalSieNaWyscig", 1);
  184.         Zapisanych++;
  185.         return 1;
  186.     }
  187.  
  188.     CMD:startrace(playerid, params[])
  189. {
  190.         if(!IsPlayerAdmin(playerid))
  191.             return SendClientMessage(playerid, CZERWONY, "Nie jesteś administratorem!");
  192.  
  193.         if(TrwajaZapisy)
  194.             return SendClientMessage(playerid, CZERWONY, "Obecnie trwają zapisy na race!");
  195.  
  196.         Timer = SetTimer("Zapisy", 1000, true);
  197.         Czas = 10;
  198.         Zapisanych = 0;
  199.         TrwajaZapisy = 1;
  200.         format(string5, sizeof string5, "Zapisanych osob: ~b~%d/%d", MIEJSCA-Miejsc, MIEJSCA);
  201.         TextDrawSetString(Zapis[3], string5);
  202.         format(string5, sizeof string5, "Pozostalo ~r~%d ~w~sekund.", Czas);
  203.         TextDrawSetString(Zapis[4], string5);
  204.         TextDrawShowForAll(Zapis[0]);
  205.         TextDrawShowForAll(Zapis[1]);
  206.         TextDrawShowForAll(Zapis[2]);
  207.         TextDrawShowForAll(Zapis[3]);
  208.         TextDrawShowForAll(Zapis[4]);
  209.  
  210.         TimerKoniec = SetTimer("fkoniecrace",1000,true);
  211.  
  212.         for(new i = 0; i < MIEJSCA; i++)
  213.             DestroyVehicle(car[i]);
  214.  
  215.         for(new i = 0; i != MIEJSCA; i++)
  216.             car[i] = CreateVehicle(468, PozycjeAut[i][0], PozycjeAut[i][1], PozycjeAut[i][2], PozycjeAut[i][3], 0, 0, 1);
  217.  
  218.         return 1;
  219.     }
  220.  
  221. public OnPlayerEnterRaceCheckpoint(playerid)
  222. {
  223.     SetPVarInt(playerid, "CP", GetPVarInt(playerid, "CP") +1);
  224.     new y = GetPVarInt(playerid, "CP");
  225.     switch(y)
  226.     {
  227.         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);
  228.         case 3: SetPlayerRaceCheckpoint(playerid,1,race[y][0],race[y][1],race[y][2],0,0,0,10);
  229.         case 4:
  230.         {
  231.             DisablePlayerRaceCheckpoint(playerid);
  232.             place++;
  233.             switch(place)
  234.             {
  235.                 case 1:
  236.                 {
  237.                     format(string5, sizeof(string5), "Gracz %s ukończył wyścig jako pierwszy", PlayerName(playerid));
  238.                     SetPlayerScore(playerid, GetPlayerScore(playerid) + 14);
  239.                     GivePlayerMoney(playerid, 10000);
  240.                 }
  241.                 case 2:
  242.                 {
  243.                     format(string5,sizeof(string5),"Gracz %s ukończył wyścig jako drugi",PlayerName(playerid));
  244.                     SetPlayerScore(playerid, GetPlayerScore(playerid) + 9);
  245.                     GivePlayerMoney(playerid, 5000);
  246.                 }
  247.                 case 3:
  248.                 {
  249.                     format(string5,sizeof(string5),"Gracz %s ukończył wyścig jako trzeci",PlayerName(playerid));
  250.                     SetPlayerScore(playerid, GetPlayerScore(playerid) + 4);
  251.                     GivePlayerMoney(playerid, 1000);
  252.                 }
  253.             }
  254.             if(!strlen(string5))
  255.             format(string5,sizeof(string5),"Gracz %s ukończył wyścig na miejscu %d",PlayerName(playerid),place);
  256.             SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
  257.             SendClientMessageToAll(NIEBIESKI,string5);
  258.             SetPVarInt(playerid, "ZapisalSieNaWyscig", 0);
  259.             DeletePVar(playerid,"CP");
  260.             DestroyVehicle(car[GetPVarInt(playerid, "cos")]);
  261.             Zapisanych--;
  262.             new rand = random(sizeof spawn);
  263.             SetPlayerPos(playerid, spawn[rand][0], spawn[rand][1], spawn[rand][2]);
  264.         }
  265.     }
  266.     return 1;
  267. }
  268.  
  269. public Zapisy()
  270. {
  271.     if(Czas >= 1)
  272.     {
  273.         format(string5, sizeof string5, "Zapisanych osob: ~b~%d/%d", MIEJSCA-Miejsc, MIEJSCA);
  274.         TextDrawSetString(Zapis[3], string5);
  275.         format(string5, sizeof string5, "Pozostalo ~r~%d ~w~sekund.", Czas);
  276.         TextDrawSetString(Zapis[4], string5);
  277.     }
  278.     if(Czas == 0 || Miejsc == 0)
  279.     {
  280.         if(Miejsc >= MIEJSCA - 1)
  281.         {
  282.             for(new i = 0; i < MIEJSCA; i++)
  283.                 DestroyVehicle(car[i]);
  284.             KillTimer(Timer);
  285.             TextDrawHideForAll(Zapis[0]);
  286.             TextDrawHideForAll(Zapis[1]);
  287.             TextDrawHideForAll(Zapis[2]);
  288.             TextDrawHideForAll(Zapis[3]);
  289.             TextDrawHideForAll(Zapis[4]);
  290.             for(new i = 0; i < GetMaxPlayers(); i++)
  291.                 SetPVarInt(i, "ZapisalSieNaWyscig", 0);
  292.             TrwajaZapisy = 0;
  293.             return SendClientMessageToAll(CZERWONY, "Wyścig nie wystartował, zapisało się za mało osób!");
  294.         }
  295.  
  296.         KillTimer(Timer);
  297.         Timer2 = SetTimer("Odlicz", 1000, 1);
  298.         Czas = 5;
  299.         TextDrawHideForAll(Zapis[0]);
  300.         TextDrawHideForAll(Zapis[1]);
  301.         TextDrawHideForAll(Zapis[2]);
  302.         TextDrawHideForAll(Zapis[3]);
  303.         TextDrawHideForAll(Zapis[4]);
  304.         new cos;
  305.         for(new i = 0; i < GetMaxPlayers(); i++)
  306.         {
  307.             if(!GetPVarInt(i, "ZapisalSieNaWyscig"))
  308.                 continue;
  309.  
  310.             SetPVarInt(i, "cos", cos);
  311.             PutPlayerInVehicle(i, car[cos++], 0);
  312.             TogglePlayerControllable(i, false);
  313.         }
  314.         cos = 0;
  315.         return 1;
  316.     }
  317.     Czas--;
  318.     return 1;
  319. }
  320.  
  321. public Odlicz()
  322. {
  323.     if(Czas >= 1 )
  324.     {
  325.         format(string5, sizeof string5, "~n~~n~~n~~g~%d", Czas);
  326.         GameTextForAll(string5, 1100, 5);
  327.     }
  328.     if(Czas == 0)
  329.     {
  330.         KillTimer(Timer2);
  331.         TrwajaZapisy = 0;
  332.         Miejsc = MIEJSCA;
  333.         place = 0;
  334.         for(new i = 0; i < GetMaxPlayers(); i++)
  335.         {
  336.             if(!GetPVarInt(i, "ZapisalSieNaWyscig"))
  337.                 continue;
  338.  
  339.             GameTextForPlayer(i, "~n~~n~~n~~g~START!", 1000, 5);
  340.             TogglePlayerControllable(i, true);
  341.             SetPlayerRaceCheckpoint(i, 0, race[0][0], race[0][1], race[0][2], race[1][0], race[1][1], race[1][2], 10);
  342.             SetPVarInt(i, "ZapisalSieNaWyscig", 1);
  343.         }
  344.         return 1;
  345.     }
  346.     Czas--;
  347.     return 1;
  348. }
  349.  
  350. public OnPlayerExitVehicle(playerid, vehicleid)
  351. {
  352.     if(GetPVarInt(playerid, "ZapisalSieNaWyscig") == 1)
  353.     {
  354.         DestroyVehicle(vehicleid);
  355.         SetPVarInt(playerid, "ZapisalSieNaWyscig", 0);
  356.         SendClientMessage(playerid, CZERWONY, "Odpadasz z wyścigu !");
  357.         new rand = random(sizeof spawn);
  358.         SetPlayerPos(playerid, spawn[rand][0], spawn[rand][1], spawn[rand][2]);
  359.         Zapisanych--;
  360.         DeletePVar(playerid,"CP");
  361.         DisablePlayerRaceCheckpoint(playerid);
  362.         if(Zapisanych == 0)
  363.             return SendClientMessage(playerid, CZERWONY, "Wyścig sie zakończył !");
  364.  
  365.     }
  366.     return 1;
  367. }
  368.  
  369. forward fkoniecrace(playerid);
  370. public fkoniecrace(playerid)
  371. {
  372. if(!TrwajaZapisy)
  373. {
  374. if(Zapisanych == 0)
  375. {
  376.             SetPVarInt(playerid, "Koniecwysciogow",1);
  377.             KillTimer(TimerKoniec);
  378.             SetPVarInt(playerid, "ZapisalSieNaWyscig", 0);
  379.             DeletePVar(playerid,"CP");
  380.             DestroyVehicle(car[GetPVarInt(playerid, "cos")]);
  381.             Zapisanych--;
  382.             new rand = random(sizeof spawn);
  383.             for(new x=0; x<GetMaxPlayers(); x++)
  384.             {
  385.             if(IsPlayerConnected(x) && (GetPVarInt(x, "ZapisalSieNaWyscig")==1))
  386.             {
  387.             SetPVarInt(x, "ZapisalSieNaWyscig", 0);
  388.             DeletePVar(x,"CP");
  389.             DestroyVehicle(car[GetPVarInt(x, "cos")]);
  390.             Zapisanych--;
  391.             SetPlayerPos(x, spawn[rand][0], spawn[rand][1], spawn[rand][2]);
  392.             }
  393.             }
  394.             }
  395.  
  396. }
  397. return 1;
  398. }
  399.  
  400. stock PlayerName(playerid)
  401. {
  402. new name[MAX_PLAYER_NAME];
  403. GetPlayerName(playerid,name,sizeof(name));
  404. return name;
  405. }
Advertisement
Add Comment
Please, Sign In to add comment