Slasheer

SkokiSpadochronowe 2.0

Apr 20th, 2011
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.62 KB | None | 0 0
  1. /*                       SKRYPT ZOSTAŁ STWORZONY PRZEZ SLASH
  2.                               © Copyright by Slash                            */
  3.  
  4. //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=DEFINE-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  5.  
  6. #include a_samp.inc
  7. #include zcmd.inc
  8. #include sscanf2.inc
  9.  
  10. #define FILTERSCRIPT
  11.  
  12. #define GUI_ADMIN       (4500)
  13. #define GUI_ADD         (4501)
  14. #define GUI_EDIT        (4502)
  15. #define GUI_DELETE      (4503)
  16. #define GUI_WRITE       (4504)
  17. #define GUI_ADMIN_2     (4505)
  18. #define GUI_CZAS        (4506)
  19. #define GUI_MIEJSC      (4507)
  20.  
  21. #define MAX_MIEJSC      20
  22.  
  23. #define C_CZERWONY      0xFF0000FF
  24. #define C_ZIELONY       0x008006FF
  25.  
  26. new Timer, TrwajaZapisy, Czas[2], update[200], Miejsc[2], Text:TextDraw[2], p;
  27.  
  28. enum ssInfo {
  29.     NazwaSS[24],
  30.     Float:X,
  31.     Float:Y,
  32.     Float:Z,
  33.     Float:Ang
  34. }
  35.  
  36. new SS[MAX_MIEJSC][ssInfo];
  37.  
  38. forward StartujSS();
  39.  
  40. public OnFilterScriptInit()
  41. {
  42.     print("\n\tSkoki Spadochronowe 2.0 by Slash");
  43.     print("\tZapraszam na Pawno.PL\n");
  44.     Czas[0] = 30;
  45.     Czas[1] = 30;
  46.     Miejsc[0] = 30;
  47.     Miejsc[1] = 30;
  48.     new File:f;
  49.     if(!fexist("ss.ini"))
  50.     {
  51.         f = fopen("ss.ini", io_write);
  52.         for(new i = 0; i != MAX_MIEJSC; i++)
  53.             fwrite(f, "Pusta|0.0|0.0|0.0|0.0\r\n");
  54.  
  55.         fclose(f);
  56.     } else {
  57.         new string[64], x;
  58.         f = fopen("ss.ini", io_read);
  59.         while(fread(f, string))
  60.         {
  61.             sscanf(string, "p<|>e<s[24]ffff>", SS[x]);
  62.             x++;
  63.         }
  64.     }
  65.     TextDraw[1] = TextDrawCreate(221.000000, 350.000000, "_");
  66.     TextDrawBackgroundColor(TextDraw[1], 255);
  67.     TextDrawFont(TextDraw[1], 1);
  68.     TextDrawLetterSize(TextDraw[1], 0.500000, 10.499998);
  69.     TextDrawColor(TextDraw[1], -1);
  70.     TextDrawSetOutline(TextDraw[1], 0);
  71.     TextDrawSetProportional(TextDraw[1], 1);
  72.     TextDrawSetShadow(TextDraw[1], 1);
  73.     TextDrawUseBox(TextDraw[1], 1);
  74.     TextDrawBoxColor(TextDraw[1], 90);
  75.     TextDrawTextSize(TextDraw[1], 420.000000, 10.000000);
  76.  
  77.     TextDraw[0] = TextDrawCreate(321.000000, 351.000000, "~w~Skoki Spadochronowe~n~~n~Uzyj ~g~/ss ~w~by sie zapisac!~n~~n~Pozostalo ~g~30 ~w~sekund!~n~~n~Pozostalo ~g~30 ~w~wolnych miejsc!");
  78.     TextDrawAlignment(TextDraw[0], 2);
  79.     TextDrawBackgroundColor(TextDraw[0], 255);
  80.     TextDrawFont(TextDraw[0], 1);
  81.     TextDrawLetterSize(TextDraw[0], 0.360000, 1.399999);
  82.     TextDrawColor(TextDraw[0], -1);
  83.     TextDrawSetOutline(TextDraw[0], 1);
  84.     TextDrawSetProportional(TextDraw[0], 1);
  85.     return 1;
  86. }
  87.  
  88. //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  89.  
  90. public OnFilterScriptExit()
  91. {
  92.     TextDrawDestroy(TextDraw[0]);
  93.     TextDrawDestroy(TextDraw[1]);
  94.     return 1;
  95. }
  96.  
  97. //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  98.  
  99. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  100. {
  101.     switch(dialogid)
  102.     {
  103.         case GUI_ADMIN:
  104.         {
  105.             if(!response)
  106.                 return 1;
  107.  
  108.             if(PustaPozycja(listitem))
  109.                 ShowPlayerDialog(playerid, GUI_ADD, DIALOG_STYLE_INPUT, ">> PA MIEJSC >> Zapisz Nową Pozycję", "Podaj nazwę tej pozycji, a następnie wciśnij 'OK'.", "Ok", "Anuluj");
  110.             else
  111.                 ShowPlayerDialog(playerid, GUI_EDIT, DIALOG_STYLE_LIST, ">> PA MIEJSC >> Edycja Pozycji", "Startuj SS z tej pozycji\nNadpisz tą pozycję\nUsuń tę pozycję", "Ok", "Anuluj");
  112.             SetPVarInt(playerid, "miejsce", listitem);
  113.             return 1;
  114.         }
  115.         case GUI_EDIT:
  116.         {
  117.             if(!response)
  118.                 return 1;
  119.  
  120.             switch(listitem)
  121.             {
  122.                 case 0:
  123.                 {
  124.                     Timer = SetTimer("StartujSS", 1000, 1);
  125.                     TrwajaZapisy = 1;
  126.                     TextDrawShowForAll(TextDraw[1]);
  127.                     TextDrawShowForAll(TextDraw[0]);
  128.                     Miejsc[0] = Miejsc[1];
  129.                     Czas[0] = Czas[1];
  130.                     p = GetPVarInt(playerid, "miejsce");
  131.                     return 1;
  132.                 }
  133.                 case 1: ShowPlayerDialog(playerid, GUI_WRITE, DIALOG_STYLE_INPUT, ">> PA MIEJSC >> Edycja Pozycji >> Nadpisz Pozycję", "Podaj nazwę tej pozycji, a następnie wciśnij 'OK'.", "Ok", "Anuluj");
  134.                 case 2:
  135.                 {
  136.                     new x = GetPVarInt(playerid, "miejsce");
  137.                     format(SS[x][NazwaSS], 24, "Pusta");
  138.                     SS[x][X] = 0;
  139.                     SS[x][Y] = 0;
  140.                     SS[x][Z] = 0;
  141.                     SS[x][Ang] = 0;
  142.                     ZapiszPozycje();
  143.                     DeletePVar(playerid, "miejsce");
  144.                     SendClientMessage(playerid, C_ZIELONY, "> Pozycja została usunięta! <");
  145.                     return 1;
  146.                 }
  147.             }
  148.             return 1;
  149.         }
  150.         case GUI_ADD:
  151.         {
  152.             if(!response)
  153.                 return 1;
  154.  
  155.             new x = GetPVarInt(playerid, "miejsce"), Float:pos[4];
  156.             GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  157.             GetPlayerFacingAngle(playerid, pos[3]);
  158.             format(SS[x][NazwaSS], 24, "%s", inputtext);
  159.             SS[x][X] = pos[0];
  160.             SS[x][Y] = pos[1];
  161.             SS[x][Z] = pos[2];
  162.             SS[x][Ang] = pos[3];
  163.             ZapiszPozycje();
  164.             DeletePVar(playerid, "miejsce");
  165.             SendClientMessage(playerid, C_ZIELONY, "> Pozycja została zapisana! <");
  166.             return 1;
  167.         }
  168.         case GUI_WRITE:
  169.         {
  170.             if(!response)
  171.                 return 1;
  172.  
  173.             new x = GetPVarInt(playerid, "miejsce"), Float:pos[4];
  174.             GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  175.             GetPlayerFacingAngle(playerid, pos[3]);
  176.             format(SS[x][NazwaSS], 24, "%s", inputtext);
  177.             SS[x][X] = pos[0];
  178.             SS[x][Y] = pos[1];
  179.             SS[x][Z] = pos[2];
  180.             SS[x][Ang] = pos[3];
  181.             ZapiszPozycje();
  182.             SendClientMessage(playerid, C_ZIELONY, "> Pozycja została nadpisana! <");
  183.             return 1;
  184.         }
  185.         case GUI_ADMIN_2:
  186.         {
  187.             if(!response)
  188.                 return 1;
  189.  
  190.             switch(listitem)
  191.             {
  192.                 case 0: ShowPlayerDialog(playerid, GUI_CZAS, DIALOG_STYLE_INPUT, ">> PA >> Ustaw czas", "Podaj czas (w sekundach) odliczania!", "Ok", "Anuluj");
  193.                 case 1: ShowPlayerDialog(playerid, GUI_MIEJSC, DIALOG_STYLE_INPUT, ">> PA >> Ustaw ilość miejsc", "Podaj ilość miejsc!", "Ok", "Anuluj");
  194.                 case 2:
  195.                 {
  196.                     new string[512];
  197.                     for(new i = 0; i < MAX_MIEJSC; i++)
  198.                         format(string, sizeof string, "%s%s\n", string, SS[i][NazwaSS]);
  199.  
  200.                     ShowPlayerDialog(playerid, GUI_ADMIN, DIALOG_STYLE_LIST, ">> PA MIEJSC", string, "OK", "Anuluj");
  201.                     return 1;
  202.                 }
  203.              }
  204.         }
  205.         case GUI_CZAS:
  206.         {
  207.             if(!response)
  208.                 return 1;
  209.  
  210.             Czas[1] = strval(inputtext);
  211.             SendClientMessage(playerid, C_ZIELONY, "> Ustawiłeś nowy czas odliczania! <");
  212.             return 1;
  213.         }
  214.         case GUI_MIEJSC:
  215.         {
  216.             if(!response)
  217.                 return 1;
  218.  
  219.             Miejsc[1] = strval(inputtext);
  220.             SendClientMessage(playerid, C_ZIELONY, "> Ustawiłeś nową liczbę miejsc! <");
  221.             return 1;
  222.         }
  223.     }
  224.     return 1;
  225. }
  226.  
  227. //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  228.  
  229. public StartujSS()
  230. {
  231.     if(Czas[0] >= 1)
  232.     {
  233.         format(update, sizeof update, "~w~Skoki Spadochronowe~n~~n~Uzyj ~g~/ss ~w~by sie zapisac!~n~~n~Pozostalo ~g~%d ~w~sekund!~n~~n~Pozostalo ~g~%d ~w~wolnych miejsc!", Czas[0], Miejsc[0]);
  234.         TextDrawSetString(TextDraw[0], update);
  235.     }
  236.     if(Czas[0] == 0)
  237.     {
  238.         if(Miejsc[0] == Miejsc[1])
  239.             return 1, SendClientMessageToAll(C_CZERWONY, "> Skoki spadochrone nie wystartowały! (Zapisało się zbyt mało osób)");
  240.         RozpocznijSS();
  241.     } else if(Miejsc[0] == 0)
  242.         RozpocznijSS();
  243.  
  244.     Czas[0]--;
  245.     return 1;
  246. }
  247.  
  248. //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  249.  
  250. stock PustaPozycja(listitem)
  251. {
  252.     if(!strcmp(SS[listitem][NazwaSS], "Pusta", true))
  253.         return 1;
  254.  
  255.     return 0;
  256. }
  257.  
  258. stock RozpocznijSS()
  259. {
  260.     Czas[0] = Czas[1];
  261.     KillTimer(Timer);
  262.     TextDrawHideForAll(TextDraw[0]);
  263.     TextDrawHideForAll(TextDraw[1]);
  264.     TrwajaZapisy = 0;
  265.     Miejsc[0] = Miejsc[1];
  266.     for(new i = 0; i < GetMaxPlayers(); i++)
  267.     {
  268.         if(GetPVarInt(i, "ZapisalSS"))
  269.         {
  270.             SetPlayerPos(i, SS[p][X], SS[p][Y], SS[p][Z]);
  271.             SetPlayerFacingAngle(i, SS[p][Ang]);
  272.             SetCameraBehindPlayer(i);
  273.             GivePlayerWeapon(i, 46, 1);
  274.             SetPVarInt(i, "ZapisalSS", 0);
  275.         }
  276.     }
  277.     return 1;
  278. }
  279.  
  280. stock ZapiszPozycje()
  281. {
  282.     new string[64], File:f = fopen("ss.ini", io_write);
  283.     for(new i = 0; i != MAX_MIEJSC; i++)
  284.     {
  285.         format(string, sizeof string, "%s|%0.3f|%0.3f|%0.3f|%0.3f\r\n", SS[i][NazwaSS], SS[i][X], SS[i][Y], SS[i][Z], SS[i][Ang]);
  286.         fwrite(f, string);
  287.     }
  288.     fclose(f);
  289.     return 1;
  290. }
  291.  
  292. //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  293.  
  294. CMD:admin(playerid, params[])
  295. {
  296.     if(!IsPlayerAdmin(playerid))
  297.         return 1, SendClientMessage(playerid, C_CZERWONY, "> Nie jesteś administratorem! <");
  298.  
  299.     if(TrwajaZapisy == 1)
  300.         return 1, SendClientMessage(playerid, C_CZERWONY, "> Trwają zapisy na skoki spadochronowe! <");
  301.  
  302.     ShowPlayerDialog(playerid, GUI_ADMIN_2, DIALOG_STYLE_LIST, ">> PA ", "Ustaw czas zapisów (domyślnie 30s)\nUstaw ilość miejsc (domyślnie 30)\nPanel zarządzania miejscami", "Ok", "Anuluj");
  303.     return 1;
  304. }
  305.  
  306. CMD:ss(playerid, params[])
  307. {
  308.     if(!TrwajaZapisy)
  309.         return 1, SendClientMessage(playerid, C_CZERWONY, "> Obecnie nie ma zapisów na skoki spadochronowe! <");
  310.  
  311.     if(GetPVarInt(playerid, "ZapisalSS"))
  312.         return 1, SendClientMessage(playerid, C_CZERWONY, "> Już się zapisałeś na skoki spadochronowe! <");
  313.  
  314.     SetPVarInt(playerid, "ZapisalSS", 1);
  315.     SendClientMessage(playerid, C_ZIELONY, "> Zapisałeś się na skoki spadochronowe! <");
  316.     Miejsc[0]--;
  317.     return 1;
  318. }
  319.  
  320. CMD:about(playerid, params[])
  321.     return 1, ShowPlayerDialog(playerid, 9999, DIALOG_STYLE_MSGBOX, "Skoki Spadochronowe 1.0", "Autor: \t\tSlash/Slasheer www.slasheer.xaa.pl\nZapraszam na:\twww.Pawno.PL\n\nSerdeczne podziękowania dla bocian941", "Ok", "");
Advertisement
Add Comment
Please, Sign In to add comment