Raggae1998

1

Jul 12th, 2012
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 13.12 KB | None | 0 0
  1. #include <a_samp>
  2. #include <sscanf2>
  3. #include <streamer>
  4. #include <zcmd>
  5.  
  6. #define MAXIMAL_PLAYERS 500
  7. #define MAXIMAL_CH 50
  8. #define FOLDER_CH "Ch"
  9. #define COLOR_RED 0xFF0000FF
  10. #define COLOR_GREEN 0x00FF00FF
  11. #define COLOR_AQUA 0x00FFFFFF
  12.  
  13. new GlobalFunctionsTimer;
  14. new ChUpdateTimer;
  15. new ChStart;
  16. new ChTakes;
  17. new ChSaved;
  18. new ChPlaces;
  19. new ChCountdown;
  20. new Float:ChHidingPosition[4];
  21. new Float:ChSeekerPosition[4];
  22. new Float:ChAreaPosition[4];
  23. new ChArea;
  24. new ChSeeker;
  25. new ChTime;
  26. new WgTakes;
  27. new WgSaved;
  28. new DerbyTakes;
  29. new DerbySaved;
  30. new HayTakes;
  31. new HaySaved;
  32. new RaceTakes;
  33. new RaceSaved;
  34. new ArenaTakes;
  35. new ArenaSaved;
  36. new PlayerCh[MAXIMAL_PLAYERS];
  37. new PlayerWg[MAXIMAL_PLAYERS];
  38. new PlayerDerby[MAXIMAL_PLAYERS];
  39. new PlayerHay[MAXIMAL_PLAYERS];
  40. new PlayerRace[MAXIMAL_PLAYERS];
  41. new PlayerArena[MAXIMAL_PLAYERS];
  42. new PlayerMoney[MAXIMAL_PLAYERS];
  43. new PlayerScore[MAXIMAL_PLAYERS];
  44.  
  45. public OnGameModeInit()
  46. {
  47.     GlobalFunctionsTimer = SetTimer("GlobalFunctions",1000,1);
  48.     ChStart = 0;
  49.     ChTakes = 0;
  50.     ChSaved = 0;
  51.     ChPlaces = 2;
  52.     ChCountdown = 0;
  53.     ChHidingPosition[0] = 0;
  54.     ChHidingPosition[1] = 0;
  55.     ChHidingPosition[2] = 0;
  56.     ChHidingPosition[3] = 0;
  57.     ChSeekerPosition[0] = 0;
  58.     ChSeekerPosition[1] = 0;
  59.     ChSeekerPosition[2] = 0;
  60.     ChSeekerPosition[3] = 0;
  61.     ChAreaPosition[0] = 0;
  62.     ChAreaPosition[1] = 0;
  63.     ChAreaPosition[2] = 0;
  64.     ChAreaPosition[3] = 0;
  65.     ChSeeker = 0;
  66.     ChTime = 0;
  67.     WgTakes = 0;
  68.     WgSaved = 0;
  69.     DerbyTakes = 0;
  70.     DerbySaved = 0;
  71.     HayTakes = 0;
  72.     HaySaved = 0;
  73.     RaceTakes = 0;
  74.     RaceSaved = 0;
  75.     ArenaTakes = 0;
  76.     ArenaSaved = 0;
  77.     return 1;
  78. }
  79.  
  80. public OnGameModeExit()
  81. {
  82.     KillTimer(GlobalFunctionsTimer);
  83.     KillTimer(ChUpdateTimer);
  84.     DestroyDynamicArea(ChArea);
  85.     return 1;
  86. }
  87.  
  88. public OnPlayerConnect(playerid)
  89. {
  90.     PlayerCh[playerid] = 0;
  91.     PlayerWg[playerid] = 0;
  92.     PlayerDerby[playerid] = 0;
  93.     PlayerHay[playerid] = 0;
  94.     PlayerRace[playerid] = 0;
  95.     PlayerArena[playerid] = 0;
  96.     PlayerMoney[playerid] = 0;
  97.     PlayerScore[playerid] = 0;
  98.     return 1;
  99. }
  100.  
  101. public OnPlayerDisconnect(playerid,reason)
  102. {
  103.     if(ChStart == 1) ChSaved -= 1;
  104.     if(ChTakes == 1)
  105.     {
  106.         ChSaved -= 1;
  107.         if(ChSaved == 1 && IsPlayerConnected(ChSeeker))
  108.         {
  109.             SendClientMessageToAll(COLOR_AQUA,">>> Zabawa w chowanego została zakończona, szukający wygrał 20000 pieniędzy i 20 punktów.");
  110.             KillTimer(ChUpdateTimer);
  111.             ChStart = 0;
  112.             ChTakes = 0;
  113.             ChSaved = 0;
  114.             ChPlaces = 2;
  115.             ChCountdown = 0;
  116.             ChHidingPosition[0] = 0;
  117.             ChHidingPosition[1] = 0;
  118.             ChHidingPosition[2] = 0;
  119.             ChHidingPosition[3] = 0;
  120.             ChSeekerPosition[0] = 0;
  121.             ChSeekerPosition[1] = 0;
  122.             ChSeekerPosition[2] = 0;
  123.             ChSeekerPosition[3] = 0;
  124.             ChAreaPosition[0] = 0;
  125.             ChAreaPosition[1] = 0;
  126.             ChAreaPosition[2] = 0;
  127.             ChAreaPosition[3] = 0;
  128.             DestroyDynamicArea(ChArea);
  129.             ChSeeker = 0;
  130.             ChTime = 0;
  131.             for(new I = 0; I < MAXIMAL_PLAYERS; I++)
  132.             {
  133.                 if(IsPlayerConnected(I) && PlayerCh[I] == 1)
  134.                 {
  135.                     PlayerCh[I] = 0;
  136.                     if(I == ChSeeker)
  137.                     {
  138.                         PlayerMoney[I] += 20000;
  139.                         PlayerScore[I] += 20;
  140.                     }
  141.                     SetPlayerInterior(I,0);
  142.                     SetPlayerVirtualWorld(I,0);
  143.                     SpawnPlayer(I);
  144.                 }
  145.             }
  146.         }
  147.         if(ChSeeker == playerid)
  148.         {
  149.             SendClientMessageToAll(COLOR_AQUA,">>> Zabawa w chowanego została zakończona, szukający opuścił serwer, chowający się wygrywają 20000 pieniędzy i 20 punktów.");
  150.             KillTimer(ChUpdateTimer);
  151.             ChStart = 0;
  152.             ChTakes = 0;
  153.             ChSaved = 0;
  154.             ChPlaces = 2;
  155.             ChCountdown = 0;
  156.             ChHidingPosition[0] = 0;
  157.             ChHidingPosition[1] = 0;
  158.             ChHidingPosition[2] = 0;
  159.             ChHidingPosition[3] = 0;
  160.             ChSeekerPosition[0] = 0;
  161.             ChSeekerPosition[1] = 0;
  162.             ChSeekerPosition[2] = 0;
  163.             ChSeekerPosition[3] = 0;
  164.             ChAreaPosition[0] = 0;
  165.             ChAreaPosition[1] = 0;
  166.             ChAreaPosition[2] = 0;
  167.             ChAreaPosition[3] = 0;
  168.             DestroyDynamicArea(ChArea);
  169.             ChSeeker = 0;
  170.             ChTime = 0;
  171.             for(new I = 0; I < MAXIMAL_PLAYERS; I++)
  172.             {
  173.                 if(IsPlayerConnected(I) && PlayerCh[I] == 1)
  174.                 {
  175.                     PlayerCh[I] = 0;
  176.                     PlayerMoney[I] += 20000;
  177.                     PlayerScore[I] += 20;
  178.                     SetPlayerInterior(I,0);
  179.                     SetPlayerVirtualWorld(I,0);
  180.                     SpawnPlayer(I);
  181.                 }
  182.             }
  183.         }
  184.     }
  185.     return 1;
  186. }
  187.  
  188. public OnPlayerDeath(playerid,killerid,reason)
  189. {
  190.     if(ChTakes == 1)
  191.     {
  192.         if(PlayerCh[playerid] == 1)
  193.         {
  194.             ChSaved -= 1;
  195.             if(ChSaved == 1)
  196.             {
  197.                 SendClientMessageToAll(COLOR_AQUA,">>> Zabawa w chowanego została zakończona, szukający wygrał 20000 pieniędzy i 20 punktów.");
  198.                 KillTimer(ChUpdateTimer);
  199.                 ChStart = 0;
  200.                 ChTakes = 0;
  201.                 ChSaved = 0;
  202.                 ChPlaces = 2;
  203.                 ChCountdown = 0;
  204.                 ChHidingPosition[0] = 0;
  205.                 ChHidingPosition[1] = 0;
  206.                 ChHidingPosition[2] = 0;
  207.                 ChHidingPosition[3] = 0;
  208.                 ChSeekerPosition[0] = 0;
  209.                 ChSeekerPosition[1] = 0;
  210.                 ChSeekerPosition[2] = 0;
  211.                 ChSeekerPosition[3] = 0;
  212.                 ChAreaPosition[0] = 0;
  213.                 ChAreaPosition[1] = 0;
  214.                 ChAreaPosition[2] = 0;
  215.                 ChAreaPosition[3] = 0;
  216.                 DestroyDynamicArea(ChArea);
  217.                 ChTime = 0;
  218.                 for(new I = 0; I < MAXIMAL_PLAYERS; I++)
  219.                 {
  220.                     if(IsPlayerConnected(I) && PlayerCh[I] == 1)
  221.                     {
  222.                         PlayerCh[I] = 0;
  223.                         if(I == ChSeeker)
  224.                         {
  225.                             PlayerMoney[I] += 20000;
  226.                             PlayerScore[I] += 20;
  227.                         }
  228.                         SetPlayerInterior(I,0);
  229.                         SetPlayerVirtualWorld(I,0);
  230.                         SpawnPlayer(I);
  231.                     }
  232.                 }
  233.                 ChSeeker = 0;
  234.             }
  235.         }
  236.     }
  237.     return 1;
  238. }
  239.  
  240. forward GlobalFunctions();
  241. public GlobalFunctions()
  242. {
  243.     if(ChStart == 0 && ChTakes == 0 && ChSaved == 2)
  244.     {
  245.         SendClientMessageToAll(COLOR_AQUA,">>> Zabawa w chwoanego wystartuje za 30 sekund, wpisz /Ch aby się zapisać.");
  246.         ChUpdateTimer = SetTimer("ChUpdate",1000,1);
  247.         ChPlaces = 10;
  248.         ChCountdown = 30;
  249.     }
  250.     return 1;
  251. }
  252.  
  253. forward ChUpdate();
  254. public ChUpdate()
  255. {
  256.     new String[150];
  257.     if(ChStart == 1)
  258.     {
  259.         ChCountdown -= 1;
  260.         if(ChCountdown == 0)
  261.         {
  262.             if(ChSaved < 2)
  263.             {
  264.                 SendClientMessageToAll(COLOR_RED,">>> Zabawa w chowanego nie wystartowała, zapisało się za mało osób.");
  265.                 KillTimer(ChUpdateTimer);
  266.                 ChStart = 0;
  267.                 ChTakes = 0;
  268.                 ChSaved = 0;
  269.                 ChPlaces = 2;
  270.                 ChCountdown = 0;
  271.                 ChHidingPosition[0] = 0;
  272.                 ChHidingPosition[1] = 0;
  273.                 ChHidingPosition[2] = 0;
  274.                 ChHidingPosition[3] = 0;
  275.                 ChSeekerPosition[0] = 0;
  276.                 ChSeekerPosition[1] = 0;
  277.                 ChSeekerPosition[2] = 0;
  278.                 ChSeekerPosition[3] = 0;
  279.                 ChAreaPosition[0] = 0;
  280.                 ChAreaPosition[1] = 0;
  281.                 ChAreaPosition[2] = 0;
  282.                 ChAreaPosition[3] = 0;
  283.                 ChSeeker = 0;
  284.                 ChTime = 0;
  285.                 for(new I = 0; I < MAXIMAL_PLAYERS; I++)
  286.                 {
  287.                     if(IsPlayerConnected(I) && PlayerCh[I] == 1) PlayerCh[I] = 0;
  288.                 }
  289.             }
  290.             if(ChSaved >= 2)
  291.             {
  292.                 SendClientMessageToAll(COLOR_AQUA,">>> Zabawa w chowanego wystartowała.");
  293.                 ChStart = 0;
  294.                 ChTakes = 1;
  295.                 format(String,150,"%s/%d.ini",FOLDER_CH,random(MAXIMAL_CH));
  296.                 new File:File = fopen(String,io_read);
  297.                 fread(File,String);
  298.                 sscanf(String,"ffffffffffff",ChHidingPosition[0],ChHidingPosition[1],ChHidingPosition[2],ChHidingPosition[3],ChSeekerPosition[0],ChSeekerPosition[1],ChSeekerPosition[2],ChSeekerPosition[3],ChAreaPosition[0],ChAreaPosition[1],ChAreaPosition[2],ChAreaPosition[3]);
  299.                 fclose(File);
  300.                 for(new I = 0; I < MAXIMAL_PLAYERS; I++)
  301.                 {
  302.                     if(IsPlayerConnected(I) && PlayerCh[I] == 1)
  303.                     {
  304.                         SetPlayerInterior(I,0);
  305.                         SetPlayerVirtualWorld(I,1);
  306.                         SetPlayerPos(I,ChHidingPosition[0],ChHidingPosition[1],ChHidingPosition[2]);
  307.                         SetPlayerFacingAngle(I,ChHidingPosition[3]);
  308.                         ChSeeker = random(I);
  309.                         SetPlayerPos(ChSeeker,ChSeekerPosition[0],ChSeekerPosition[1],ChSeekerPosition[2]);
  310.                         SetPlayerFacingAngle(ChSeeker,ChSeekerPosition[3]);
  311.                         SetPlayerHealth(ChSeeker,100000);
  312.                         GivePlayerWeapon(ChSeeker,38,100000);
  313.                         ChArea = CreateDynamicRectangle(ChAreaPosition[0],ChAreaPosition[1],ChAreaPosition[2],ChAreaPosition[3]);
  314.                     }
  315.                 }
  316.             }
  317.         }
  318.     }
  319.     if(ChTakes == 1)
  320.     {
  321.         ChTime -= 1;
  322.         if(ChTime == 0)
  323.         {
  324.             SendClientMessageToAll(COLOR_AQUA,">>> Zabawa w chowanego została zakończona, wygrali chowający się, 20000 pieniędzy i 20 punktów.");
  325.             KillTimer(ChUpdateTimer);
  326.             ChStart = 0;
  327.             ChTakes = 0;
  328.             ChSaved = 0;
  329.             ChPlaces = 2;
  330.             ChCountdown = 0;
  331.             ChHidingPosition[0] = 0;
  332.             ChHidingPosition[1] = 0;
  333.             ChHidingPosition[2] = 0;
  334.             ChHidingPosition[3] = 0;
  335.             ChSeekerPosition[0] = 0;
  336.             ChSeekerPosition[1] = 0;
  337.             ChSeekerPosition[2] = 0;
  338.             ChSeekerPosition[3] = 0;
  339.             ChAreaPosition[0] = 0;
  340.             ChAreaPosition[1] = 0;
  341.             ChAreaPosition[2] = 0;
  342.             ChAreaPosition[3] = 0;
  343.             ChTime = 0;
  344.             for(new I = 0; I < MAXIMAL_PLAYERS; I++)
  345.             {
  346.                 if(IsPlayerConnected(I) && PlayerCh[I] == 1)
  347.                 {
  348.                     PlayerCh[I] = 0;
  349.                     SetPlayerInterior(I,0);
  350.                     SetPlayerVirtualWorld(I,0);
  351.                     SpawnPlayer(I);
  352.                     if(I != ChSeeker)
  353.                     {
  354.                         PlayerMoney[I] += 20000;
  355.                         PlayerScore[I] += 20;
  356.                     }
  357.                 }
  358.             }
  359.             ChSeeker = 0;
  360.         }
  361.     }
  362.     return 1;
  363. }
  364.  
  365. COMMAND:ch(playerid,params[])
  366. {
  367.     if(PlayerCh[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,">>> Jesteś już zapisany na zabawę w chowanego.");
  368.     if(PlayerWg[playerid] == 1 || PlayerDerby[playerid] == 1 || PlayerHay[playerid] == 1 || PlayerRace[playerid] == 1 || PlayerArena[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,">>> Jesteś już zapisany na inną zabawę.");
  369.     if(ChTakes == 1) return SendClientMessage(playerid,COLOR_RED,">>> Zabawa w chowanego już trwa.");
  370.     if(ChSaved == ChPlaces) return SendClientMessage(playerid,COLOR_RED,">>> Na zabawę w chowanego nie ma miejsc.");
  371.     SendClientMessage(playerid,COLOR_GREEN,">>> Zapisałeś się na zabawę w chowanego.");
  372.     ChSaved += 1;
  373.     PlayerCh[playerid] = 1;
  374.     return 1;
  375. }
  376.  
  377. COMMAND:wg(playerid,params[])
  378. {
  379.     if(PlayerWg[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,">>> Jesteś już zapisany na zabawę w wojnę gangów.");
  380.     if(PlayerCh[playerid] == 1 || PlayerDerby[playerid] == 1 || PlayerHay[playerid] == 1 || PlayerRace[playerid] == 1 || PlayerArena[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,">>> Jesteś już zapisany na inną zabawę.");
  381.     if(WgTakes == 1) return SendClientMessage(playerid,COLOR_RED,">>> Zabawa w wojnę gangów już trwa.");
  382.     SendClientMessage(playerid,COLOR_GREEN,">>> Zapisałeś się na zabawę w wojnę gangów.");
  383.     WgSaved += 1;
  384.     PlayerWg[playerid] = 1;
  385.     return 1;
  386. }
  387.  
  388. COMMAND:derby(playerid,params[])
  389. {
  390.     if(PlayerDerby[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,">>> Jesteś już zapisany na zabawę w derby.");
  391.     if(PlayerCh[playerid] == 1 || PlayerWg[playerid] == 1 || PlayerHay[playerid] == 1 || PlayerRace[playerid] == 1 || PlayerArena[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,">>> Jesteś już zapisany na inną zabawę.");
  392.     if(DerbyTakes == 1) return SendClientMessage(playerid,COLOR_RED,">>> Zabawa w derby już trwa.");
  393.     SendClientMessage(playerid,COLOR_GREEN,">>> Zapisałeś się na zabawę w derby.");
  394.     DerbySaved += 1;
  395.     PlayerDerby[playerid] = 1;
  396.     return 1;
  397. }
  398.  
  399. COMMAND:hay(playerid,params[])
  400. {
  401.     if(PlayerHay[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,">>> Jesteś już zapisany na zabawę w hay.");
  402.     if(PlayerCh[playerid] == 1 || PlayerWg[playerid] == 1 || PlayerDerby[playerid] == 1 || PlayerRace[playerid] == 1 || PlayerArena[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,">>> Jesteś już zapisany na inną zabawę.");
  403.     if(HayTakes == 1) return SendClientMessage(playerid,COLOR_RED,">>> Zabawa w hay już trwa.");
  404.     SendClientMessage(playerid,COLOR_GREEN,">>> Zapisałeś się na zabawę w hay.");
  405.     HaySaved += 1;
  406.     PlayerHay[playerid] = 1;
  407.     return 1;
  408. }
  409.  
  410. COMMAND:race(playerid,params[])
  411. {
  412.     if(PlayerRace[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,">>> Jesteś już zapisany na zabawę w wyścig.");
  413.     if(PlayerCh[playerid] == 1 || PlayerWg[playerid] == 1 || PlayerDerby[playerid] == 1 || PlayerHay[playerid] == 1 || PlayerArena[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,">>> Jesteś już zapisany na inną zabawę.");
  414.     if(RaceTakes == 1) return SendClientMessage(playerid,COLOR_RED,">>> Zabawa w wyścig już trwa.");
  415.     SendClientMessage(playerid,COLOR_GREEN,">>> Zapisałeś się na zabawę w wyścig.");
  416.     RaceSaved += 1;
  417.     PlayerRace[playerid] = 1;
  418.     return 1;
  419. }
  420.  
  421. COMMAND:arena(playerid,params[])
  422. {
  423.     if(PlayerArena[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,">>> Jesteś już zapisany na zabawę w arenę.");
  424.     if(PlayerCh[playerid] == 1 || PlayerWg[playerid] == 1 || PlayerDerby[playerid] == 1 || PlayerHay[playerid] == 1 || PlayerRace[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,">>> Jesteś już zapisany na inną zabawę.");
  425.     if(ArenaTakes == 1) return SendClientMessage(playerid,COLOR_RED,">>> Zabawa w arenę już trwa.");
  426.     SendClientMessage(playerid,COLOR_GREEN,">>> Zapisałeś się na zabawę w arenę.");
  427.     ArenaSaved += 1;
  428.     PlayerArena[playerid] = 1;
  429.     return 1;
  430. }
Advertisement
Add Comment
Please, Sign In to add comment