Advertisement
Guest User

Mix Script

a guest
Dec 31st, 2014
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 29.21 KB | None | 0 0
  1. const
  2.     GOOD = $00FF99;
  3.     BAD = $FF6666;
  4.  
  5. var
  6.     Mix, Anty: byte;    //Mix 0 - No Match, Mix 1 - 1v1, Mix 2 - 2v2, Mix 3 - 3v3, Mix 4 - 4v4
  7.     PlayerInMix, voter: array [1..32] of boolean;
  8.     prewteam: array [1..32] of integer;
  9.     MixList: array [1..8] of string;
  10.     Time, Votes, Votes2, Votes3, Votes4, pause, a, b: integer;
  11.     Voterr, VoteO, VoterM, VoteN, matchon, mixteams: boolean;
  12.     InGameSup, SupWait, Move: array [1..32] of boolean;
  13.     PlayerList: array of integer;
  14.  
  15. function Explode(Source: string; const Delimiter: string): array of string;
  16. var Position, DelLength, ResLength: integer;
  17. begin
  18.     DelLength := Length(Delimiter);
  19.     Source := Source + Delimiter;
  20.     repeat
  21.         Position := Pos(Delimiter, Source);
  22.         SetArrayLength(Result, ResLength + 1);
  23.         Result[ResLength] := Copy(Source, 1, Position - 1);
  24.         ResLength := (ResLength + 1);
  25.         Delete(Source, 1, Position + DelLength - 1);
  26.     until (Position = 0);
  27.     SetArrayLength(Result, ResLength - 1);
  28. end;
  29.  
  30. procedure ResVar(ID:byte);
  31. begin
  32.     InGameSup[id] := false;
  33.     SupWait[id] := false;
  34.     PlayerInMix[id] := false;
  35.     voter[id] := false;
  36.     Move[id] := false;
  37. end;
  38.  
  39. function GetTeamArray(const Team: byte): Array of byte;
  40. var i,x: integer;
  41. begin
  42.     i := 1;
  43.     x := 0;
  44.     while (i < 32) do begin
  45.         if (GetPlayerStat(i, 'Active') = true) then if (GetPlayerStat(i, 'Team') = Team) then begin
  46.             SetArrayLength(Result, x + 1);
  47.             Result[x] := i;
  48.             inc(x,1);
  49.         end;
  50.         inc(i,1);
  51.     end;
  52. end;
  53.  
  54. procedure Balance();
  55. var i,Difference: integer;
  56.     Players: Array of byte;
  57. begin
  58.     Difference:=(a-b);
  59.     if (Difference > 1) and (a > 1) then begin
  60.         Players := GetTeamArray(1);
  61.         while (true) do begin
  62.             i := Players[Random(1, GetArrayLength(Players) - 1)];
  63.             if (GetPlayerStat(i, 'Flagger') = false) then break;
  64.         end;
  65.         Move[i]:=true;
  66.         Command('/setteam2 ' + inttostr(i));
  67.         dec(a,1);
  68.         WriteConsole(i, 'You were balanced due to unbalanced teams.', GOOD);
  69.     end;
  70.     if (Difference < -1) and (b > 1) then begin
  71.         Players := GetTeamArray(2);
  72.         while (true) do begin
  73.             i := Players[Random(1, GetArrayLength(Players) - 1)];
  74.             if (GetPlayerStat(i,'Flagger') = false) then break;
  75.         end;
  76.         Move[i]:=true;
  77.         Command('/setteam1 ' + inttostr(i));
  78.         dec(b,1);
  79.         WriteConsole(i, 'You were balanced due to unbalanced teams.', GOOD);
  80.     end;
  81.     Difference:=(a-b);
  82.     if (Difference > 1) or (Difference < -1) then Balance() else WriteConsole(0, 'Teams balanced. If you see no result teams are balanced.', GOOD);
  83. end;
  84.  
  85. function RandomizeArray(arrayy: array of integer): array of integer;
  86. var len, high ,i, rand : integer;
  87. begin
  88.     len := GetArrayLength(arrayy);
  89.     setArrayLength(result, len)
  90.     high := (len-1);
  91.     for i := 0 to (len-1) do begin
  92.         rand := Random(0, high);
  93.         result[i] := arrayy[rand];
  94.         arrayy[rand] := arrayy[high];
  95.         dec(high, 1);
  96.     end;
  97. end;
  98.  
  99. procedure MixTeam();
  100. var c,x:integer;  ranlist: array of integer;
  101. begin
  102.     c := 1;
  103.     x := 0;
  104.     while (c < 32) do begin
  105.         if (GetPlayerStat(c, 'Active') = true) then if (PlayerInMix[c] = true) then begin
  106.             SetArrayLength(PlayerList, x + 1);
  107.             PlayerList[x] := c;         //Stworz liste graczy uczestniczacych w meczu
  108.             inc(x,1);
  109.         end;
  110.         inc(c,1);
  111.     end;
  112.  
  113.     ranlist := RandomizeArray(PlayerList);      //randomizuj liste
  114.  
  115.     x:=0;   mixteams:=true;
  116.     for c := 0 to (GetArrayLength(ranlist)-1) do begin
  117.         if(x=0) then begin
  118.             if (GetPlayerStat(ranlist[c],'Team')<>1) then Command('/setteam1 '+inttostr(ranlist[c]));       //Moving players
  119.             x:=1;
  120.         end else begin
  121.             if (GetPlayerStat(ranlist[c],'Team')<>2) then Command('/setteam2 ' + inttostr(ranlist[c]));
  122.             x:=0;
  123.         end;
  124.     end;
  125.     mixteams:=false;
  126. end;
  127.  
  128. Procedure CheckVotes();
  129. var i:byte; c:integer;
  130. begin
  131.     c:=0;
  132.     for i := 1 to (mix*2) do if (MixList[i] <> '') then inc(c,1);
  133.     if (Votes > 0) then begin
  134.         if (Votes>=iif(c>=mix,mix,c)) then begin
  135.             DrawTextEx(0,51,'Vote to OFF - Successfully!',140,GOOD,0.075,180,2);
  136.             Voteo := false;
  137.             Votes := 0;
  138.             Time := 0;
  139.             Mix := 0;
  140.             matchon := false;
  141.             for i := 1 to 32 do if (GetPlayerStat(i, 'Active')=true) and (PlayerInMix[i]=true) then ResVar(i);
  142.             for i := 1 to 8 do MixList[i] := '';
  143.         end;
  144.     end;
  145.     if (Votes2 > 0) then begin
  146.         if (Votes2>=iif(c>=mix,mix,c)) then begin
  147.             DrawTextEx(0,51,'Vote to restart - Successfully!',140,GOOD,0.075,180,2);
  148.             Voterr := false;
  149.             Votes2 := 0;
  150.             Time := 0;
  151.             Anty:=1;
  152.             Command('/restart');
  153.             for i := 1 to 32 do if (GetPlayerStat(i, 'Active')=true) then voter[i] := false;
  154.         end;
  155.     end;
  156.     if (Votes3 > 0) then begin
  157.         if (Votes3>=iif(c>=mix,mix,c)) then begin
  158.             DrawTextEx(0,51,'Vote to mix teams - Successfully!',140,GOOD,0.075,180,2);
  159.             VoterM := false;
  160.             Votes3 := 0;
  161.             Time := 0;
  162.             MixTeam();
  163.             for i := 1 to 32 do if (GetPlayerStat(i, 'Active')=true) then voter[i] := false;
  164.         end;
  165.     end;
  166.     if (Votes4 > 0) then begin
  167.         if (Votes4>=iif(c>=mix,mix,c)) then begin
  168.             DrawTextEx(0,51,'Vote to nextmap - Successfully!',140,GOOD,0.075,180,2);
  169.             DrawTextEx(0,55,'                ('+NextMap+')',140,GOOD,0.075,180,16);
  170.             VoteN := false;
  171.             Votes4 := 0;
  172.             Time := 0;
  173.             Anty:=1;
  174.             Command('/nextmap');
  175.             for i := 1 to 32 do if (GetPlayerStat(i, 'Active')=true) then voter[i] := false;
  176.         end;
  177.     end;
  178. end;
  179.  
  180. procedure SubCheck(ID,y:byte; l:boolean; m:byte);
  181. var i,b:byte; t,t2:integer;
  182. begin
  183.     if (m=1) then begin
  184.         for i:= 1 to 32 do if (GetPlayerStat(i,'active')=true) then begin
  185.             if (i<>ID) then if (InGameSup[i]=true) then begin
  186.                 t:=GetPlayerStat(i,'Team');
  187.                 t2:=GetPlayerStat(id,'Team');
  188.                 Move[id]:=true;
  189.                 Move[i]:=true;
  190.                 Command('/setteam'+inttostr(t2)+' '+inttostr(i));
  191.                 Command('/setteam'+inttostr(t)+' '+inttostr(id));
  192.                 InGameSup[id]:=false;
  193.                 InGameSup[i]:=false;
  194.                 WriteConsole(0,'Successfully changed players: '+GetPlayerStat(ID,'name')+' and '+GetPlayerStat(i,'name')+'.',GOOD);
  195.                 Exit;
  196.             end;
  197.             if (SupWait[i]=true) then begin
  198.                 t:=GetPlayerStat(ID,'Team');
  199.                 if (l=true) then begin
  200.                     ResVar(ID);
  201.                     Command('/setteam5 '+inttostr(ID));
  202.                 end;
  203.                 ResVar(i);                                  //Zamiana
  204.                 Move[i] := true;
  205.                 PlayerInMix[i] := true;
  206.                 for b := 1 to (Mix*2) do if (MixList[b]='') then begin
  207.                     MixList[b] := GetPlayerStat(i,'Name');
  208.                     break;
  209.                 end;
  210.                 Command('/setteam'+inttostr(t)+' '+inttostr(i));
  211.                 if (y=1) then if (Mix=1) then WriteConsole(0,iif(Mix=1,iif(MixList[1]<>'',MixList[1]+',','-=1=-')+' '+iif(MixList[2]<>'',MixList[2],'-=2=-'),''),GOOD) else if (Mix=2) then WriteConsole(0,iif(Mix=2,iif(MixList[1]<>'',MixList[1]+',','-=1=-')+' '+iif(MixList[2]<>'',MixList[2]+',','-=2=-')+' '+iif(MixList[3]<>'',MixList[3]+',','-=3=-')+' '+iif(MixList[4]<>'',MixList[4],'-=4=-'),''),GOOD) else if (Mix=3) then WriteConsole(0,iif(Mix=3,iif(MixList[1]<>'',MixList[1]+',','-=1=-')+' '+iif(MixList[2]<>'',MixList[2]+',','-=2=-')+' '+iif(MixList[3]<>'',MixList[3]+',','-=3=-')+' '+iif(Mix=3,iif(MixList[4]<>'',MixList[4]+',','-=4=-')+' '+iif(MixList[5]<>'',MixList[5]+',','-=5=-')+' '+iif(MixList[6]<>'',MixList[6],'-=6=-'),''),''),GOOD) else if (Mix=4) then WriteConsole(0,iif(Mix=4,iif(MixList[1]<>'',MixList[1]+',','-=1=-')+' '+iif(MixList[2]<>'',MixList[2]+',','-=2=-')+' '+iif(MixList[3]<>'',MixList[3]+',','-=3=-')+' '+iif(MixList[4]<>'',MixList[4]+',','-=4=-')+' '+iif(Mix=4,iif(MixList[5]<>'',MixList[5]+',','-=5=-')+' '+iif(MixList[6]<>'',MixList[6]+',','-=6=-')+' '+iif(MixList[7]<>'',MixList[7]+',','-=7=-')+' '+iif(MixList[8]<>'',MixList[8],'-=8=-'),''),''),GOOD);
  212.                 if (l=true) then WriteConsole(0,'Successfully changed players: '+GetPlayerStat(ID,'name')+' and '+GetPlayerStat(i,'name')+'.',GOOD) else WriteConsole(i,'Into the game per: '+GetPlayerStat(ID,'name')+'.',GOOD);
  213.                 break;
  214.             end;
  215.         end;
  216.     end;
  217.     if (m=2) then begin        
  218.         for i:= 1 to 32 do if (GetPlayerStat(i,'active')=true) then begin
  219.             if (InGameSup[i]=true) then begin
  220.                 t:=GetPlayerStat(i,'Team');
  221.                 ResVar(i);
  222.                 Command('/setteam5 '+inttostr(i));
  223.                 ResVar(ID);
  224.                 PlayerInMix[ID] := true;                                //Zamiana
  225.                 Move[ID]:=true;
  226.                 for b := 1 to (Mix*2) do if (MixList[b]='') then begin
  227.                     MixList[b] := GetPlayerStat(ID,'Name');
  228.                     break;
  229.                 end;
  230.                 Command('/setteam'+inttostr(t)+' '+inttostr(id));
  231.                 WriteConsole(0,'Successfully changed players: '+GetPlayerStat(ID,'name')+' and '+GetPlayerStat(i,'name')+'.',GOOD);
  232.                 break;
  233.             end;
  234.         end;
  235.     end;
  236. end;
  237.  
  238. Procedure MixR(ID:byte);
  239. var i,t:byte; c,b,a:integer;
  240. begin
  241.     if (PlayerInMix[ID] = false) then begin
  242.         c:=0;
  243.         for i := 1 to (mix*2) do if (MixList[i]='') then inc(c,1);
  244.         if (c>0) then begin
  245.             if (matchon=true) then Move[ID] := true;
  246.             PlayerInMix[ID] := true;    a:=0; b:=0;
  247.             for t := 1 to 32 do if (GetPlayerStat(t,'Active')=true) and (PlayerInMix[t]=true) then begin
  248.                 if (GetPlayerStat(t,'Team')=1) then inc(a,1);
  249.                 if (GetPlayerStat(t,'Team')=2) then inc(b,1);
  250.             end;
  251.             if (a<=b) then begin
  252.                 if ((b=1) and (a=1)) or ((a=0) and (b=0)) then begin
  253.                     if (GetPlayerStat(ID,'Team')=5) then Command('/setteam2 '+inttostr(ID));
  254.                 end else if (a<b) then if (GetPlayerStat(ID,'Team')<>1) then Command('/setteam1 '+inttostr(ID));
  255.             end else if (GetPlayerStat(ID,'Team')<>2) then Command('/setteam2 '+inttostr(ID));
  256.             for i := 1 to (mix*2) do if (MixList[i]='') then begin//By Dominik
  257.                 MixList[i] := GetPlayerStat(ID,'Name');
  258.                 dec(c,1);
  259.                 break;
  260.             end;
  261.             if (Mix=1) then WriteConsole(0,iif(Mix=1,iif(MixList[1]<>'',MixList[1]+',','-=1=-')+' '+iif(MixList[2]<>'',MixList[2],'-=2=-'),''),GOOD) else if (Mix=2) then WriteConsole(0,iif(Mix=2,iif(MixList[1]<>'',MixList[1]+',','-=1=-')+' '+iif(MixList[2]<>'',MixList[2]+',','-=2=-')+' '+iif(MixList[3]<>'',MixList[3]+',','-=3=-')+' '+iif(MixList[4]<>'',MixList[4],'-=4=-'),''),GOOD) else if (Mix=3) then WriteConsole(0,iif(Mix=3,iif(MixList[1]<>'',MixList[1]+',','-=1=-')+' '+iif(MixList[2]<>'',MixList[2]+',','-=2=-')+' '+iif(MixList[3]<>'',MixList[3]+',','-=3=-')+' '+iif(Mix=3,iif(MixList[4]<>'',MixList[4]+',','-=4=-')+' '+iif(MixList[5]<>'',MixList[5]+',','-=5=-')+' '+iif(MixList[6]<>'',MixList[6],'-=6=-'),''),''),GOOD) else if (Mix=4) then WriteConsole(0,iif(Mix=4,iif(MixList[1]<>'',MixList[1]+',','-=1=-')+' '+iif(MixList[2]<>'',MixList[2]+',','-=2=-')+' '+iif(MixList[3]<>'',MixList[3]+',','-=3=-')+' '+iif(MixList[4]<>'',MixList[4]+',','-=4=-')+' '+iif(Mix=4,iif(MixList[5]<>'',MixList[5]+',','-=5=-')+' '+iif(MixList[6]<>'',MixList[6]+',','-=6=-')+' '+iif(MixList[7]<>'',MixList[7]+',','-=7=-')+' '+iif(MixList[8]<>'',MixList[8],'-=8=-'),''),''),GOOD);
  262.             if (c=0) then begin
  263.                 for i := 1 to 32 do if (GetPlayerStat(i,'Active')=true) then if (PlayerInMix[i] = false) and (GetPlayerStat(i,'team')<>5) then Command('/setteam5 '+inttostr(i));
  264.                 matchon := true;
  265.                 Anty := 1;
  266.                 Command('/restart');
  267.                 DrawTextEx(0,51,'The match started!',140,GOOD,0.075,180,2);
  268.             end;
  269.         end else WriteConsole(ID,'Now takes the game '+inttostr(Mix)+'vs'+inttostr(Mix)+'. There are no places to join!',BAD);
  270.     end else WriteConsole(ID,'You have been already added to the game.',BAD);
  271. end;
  272.  
  273. Procedure MixON(ID, Typ:byte);
  274. var i:byte; c:integer;
  275. begin
  276.     if (Mix=0) then begin
  277.         Mix := Typ;
  278.         MixR(ID);
  279.         for i := 1 to 32 do if (GetPlayerStat(i, 'Active')=true) then if (i<>ID) then WriteConsole(i,'Enter !add to join!',GOOD);
  280.     end else
  281.     begin
  282.         c := 0;
  283.         for i := 1 to (mix*2) do if (MixList[i]='') then inc(c,1);
  284.         if (c=0) then WriteConsole(ID,'Now takes the game '+inttostr(Mix)+'vs'+inttostr(Mix)+'!'+iif(PlayerInMix[id]=true,'',' Enter !sub to join the queue.'),BAD) else WriteConsole(ID,'Takes already match '+inttostr(Mix)+'vs'+inttostr(Mix)+'!'+iif(PlayerInMix[id]=true,'',' Write !add to join the game.'),BAD);
  285.     end;
  286. end;
  287.  
  288. procedure OnJoinGame(ID, Team: byte);
  289. begin
  290.     ResVar(ID);
  291.     DrawTextEx(ID,52,'!mix - Play Match!',350,GOOD,0.200,30,340);
  292. end;
  293.  
  294. Procedure OnJoinTeam(ID, Team: byte);
  295. var i: byte; c:integer;
  296. begin
  297.     if (Team=1) or (Team=2) then if (matchon=true) then begin
  298.         if (PlayerInMix[ID] = false) then begin
  299.             Command('/setteam5 '+inttostr(ID));
  300.             c:=0;
  301.             for i := 1 to (mix*2) do if (MixList[i] = '') then inc(c,1);            //Daj info graczowi jak dolaczyc ponnownie
  302.             if (c<>0) then WriteConsole(ID,' ---> Write !add to join game. <---',BAD) else WriteConsole(ID,' ---> Write !sub to join the queue. <---',BAD);
  303.             prewteam[ID] := 5;
  304.             exit;
  305.         end else
  306.         begin
  307.             if (mixteams=false) then if (Move[ID]=false) then begin
  308.                 if (prewteam[ID]<>Team) then begin
  309.                     Move[id] := true;
  310.                     Command('/setteam'+inttostr(prewteam[ID])+' '+inttostr(id));
  311.                     prewteam[ID] := prewteam[ID];
  312.                     WriteConsole(ID,' ---> You can not change the team during the match. <---',BAD);
  313.                     WriteConsole(ID,' ---> Use !sub to turn into a team with other players. <---',BAD);
  314.                     exit;
  315.                 end;
  316.             end else if (move[id]=true) then begin
  317.                 Move[id] := false;
  318.                 prewteam[ID] := GetPlayerStat(id,'team');
  319.                 exit;
  320.             end;
  321.         end;
  322.     end;
  323.     if (Team=5) then begin
  324.         if (PlayerInMix[ID] = true) then begin
  325.             ResVar(ID);                                                 //Usun gracza z listy i zresetuj zmienne
  326.             for i := 1 to (Mix*2) do if (MixList[i] = GetPlayerStat(ID,'Name')) then MixList[i] := '';
  327.  
  328.             c:=0;
  329.             for i := 1 to 8 do if (MixList[i] = '') then inc(c,1);      //Sprawdz czy mix aktywny
  330.             if (c=8) then begin
  331.                 Mix:=0;
  332.                 matchon:=false;
  333.             end;
  334.  
  335.             SubCheck(ID,1,false,1);         //Dodaj innego
  336.  
  337.             if (voter[id] = true) then begin
  338.                 if (Votes > 0) then dec(Votes,1);               //Jesli glosowal, usun jego glos
  339.                 if (Votes2 > 0) then dec(Votes2,1);
  340.                 if (Votes3 > 0) then dec(Votes3,1);
  341.                 if (Votes4 > 0) then dec(Votes4,1);
  342.                 CheckVotes();
  343.             end;
  344.  
  345.             c:=0;
  346.             for i := 1 to (mix*2) do if (MixList[i] = '') then inc(c,1);    //Daj info graczowi jak dolaczyc ponnownie
  347.             if (c<>0) then WriteConsole(ID,' ---> Write !add to join game. <---',BAD) else WriteConsole(ID,' ---> Write !sub to join the queue. <---',BAD);
  348.         end;
  349.     end;
  350.     prewteam[ID] := GetPlayerStat(id,'team');
  351. end;
  352.  
  353. procedure OnPlayerSpeak(ID: byte; Text: string);
  354. var i:byte; mapy: TStringArray; c:integer;
  355. begin   //!del !add !off !status !p !up !bal
  356.     if regExpMatch('^!(balance|bal|teams)$',lowercase(Text)) then begin
  357.         if (PlayerInMix[ID] = true) then begin
  358.             a:=AlphaPlayers;
  359.             b:=BravoPlayers;
  360.             Balance();
  361.         end else WriteConsole(ID,'You must participate in the game to balance teams.',BAD);
  362.     end;
  363.  
  364.     if regExpMatch('^!(sub)$',lowercase(Text)) then begin
  365.         if (Mix<>0) then begin
  366.             if (PlayerInMix[ID] = true) then begin
  367.                 if (InGameSup[ID] = false) then begin
  368.                     InGameSup[ID] := true;                                                  //Dodanie do kolejki aby sie zmienic w grze
  369.                     WriteConsole(ID,'You have been added to the queue to change.',GOOD);
  370.                 end else WriteConsole(ID,'You`re already in the queue to change!',BAD);
  371.                 SubCheck(ID,0,true,1);
  372.             end else
  373.             begin
  374.                 if (SupWait[ID] = false) then begin
  375.                     SupWait[ID] := true;                                //dodaj do kolejki
  376.                     WriteConsole(ID,'You have been added to the queue.',GOOD);
  377.                 end else WriteConsole(ID,'You`re already to play match!',BAD);
  378.                 SubCheck(ID,0,true,2);
  379.             end;
  380.         end else WriteConsole(ID,'Currently not take any match!',BAD);
  381.     end;
  382.  
  383.     if regExpMatch('^!(delsub)$',lowercase(Text)) then begin
  384.         if (InGameSup[ID] = true) or (SupWait[ID] = true) then begin
  385.             InGameSup[ID] := false;
  386.             SupWait[ID] := false;
  387.             WriteConsole(ID,'You have been removed from the queue.',GOOD);
  388.         end else WriteConsole(ID,'You`re not in the queue!',BAD);
  389.     end;
  390.  
  391.     if regExpMatch('^!(ranmap)$',lowercase(Text)) then if (PlayerInMix[ID] = true) then begin
  392.         mapy := Explode(ReadFile('mapslist.txt'),chr(13)+chr(10));
  393.         Command('/map '+mapy[Random(0,GetArrayLength(mapy)-1)]);
  394.         Anty:=1;
  395.     end else WriteConsole(ID,'You can`t change the map not being in while of the match.',BAD);
  396.  
  397.     if MaskCheck(lowercase(Text),'!map *') then if (PlayerInMix[ID] = true) then begin
  398.         delete(Text,1,5);
  399.         if (Text<>'') then begin
  400.             mapy := Explode(ReadFile('mapslist.txt'),chr(13)+chr(10));
  401.             for i:= 1 to (GetArrayLength(mapy)-1) do begin
  402.                 if (ContainsString(lowercase(mapy[i-1]),lowercase(Text))=true) then begin
  403.                     if (mapy[i-1] <> '') then begin
  404.                         Command('/map '+mapy[i-1]);
  405.                         Anty:=1;
  406.                     end else WriteConsole(ID,'No maps found!',BAD);
  407.                     break;
  408.                 end;
  409.             end;
  410.         end else WriteConsole(ID,'You must enter the name of map or a part thereof.',BAD);
  411.     end else WriteConsole(ID,'You can`t change the map not being in while the match.',BAD);
  412.  
  413.     if regExpMatch('^!(mix|cmdmix|mixcmd|cmdsmix|mixcmds)$',lowercase(Text)) then begin
  414.         WriteConsole(ID,'While Match:',BAD);
  415.         WriteConsole(ID,'            !del    - Exit from the match, !ub - Unbanlast.        ',BAD);
  416.         WriteConsole(ID,'            !p      - Enable pause,        !up - Disable pause.    ',BAD);
  417.         WriteConsole(ID,'            !bal    - Balance teams,       !mixteams - Mixed teams.',BAD);
  418.         WriteConsole(ID,'            !off !r - Votes per: Disable match | Restart match.    ',BAD);
  419.         WriteConsole(ID,'            !map <name> - Change map name, !ranmap - Randommap.    ',BAD);
  420.         WriteConsole(ID,'            !nextmap    - Vote for nextmap.                        ',BAD);
  421.         WriteConsole(ID,'Normally:',GOOD);
  422.         WriteConsole(ID,'            !add - Add to the match, !status - Match status.       ',GOOD);
  423.         WriteConsole(ID,'            !sub - Add queue, !delsub - Exit from queue.           ',GOOD);
  424.         WriteConsole(ID,'            !1v1 !2v2 - Beginning game 1v1 or 2v2.                 ',GOOD);
  425.         WriteConsole(ID,'            !3v3 !4v4 - Beginning game 3v3 or 4v4.                 ',GOOD);
  426.         WriteConsole(ID,'Script Creator: dominikk26                                         ',$FFCCFF);
  427.     end;
  428.  
  429.     if regExpMatch('^!(1v1)$',lowercase(Text)) then MixON(ID,1);
  430.     if regExpMatch('^!(2v2)$',lowercase(Text)) then MixON(ID,2);
  431.     if regExpMatch('^!(3v3)$',lowercase(Text)) then MixON(ID,3);
  432.     if regExpMatch('^!(4v4)$',lowercase(Text)) then MixON(ID,4);
  433.  
  434.     if regExpMatch('^!(add)$',lowercase(Text)) then if (Mix <> 0) then MixR(ID) else WriteConsole(ID,'Currently not take none match!',BAD);
  435.  
  436.     if regExpMatch('^!(del)$',lowercase(Text)) then if (Mix <> 0) then Command('/setteam5 '+inttostr(ID)) else WriteConsole(ID,'Currently not take none match!',BAD);
  437.  
  438.     if regExpMatch('^!(off)$',lowercase(Text)) then if (PlayerInMix[ID] = true) then begin
  439.         if (Voterr=false) then begin
  440.             if (VoterM = false) then begin
  441.                 if (VoteN=false) then begin
  442.                     if (voter[id] = false) then begin
  443.                         c:=0;
  444.                         for i := 1 to (mix*2) do if (MixList[i] <> '') then inc(c,1);
  445.                         if (Voteo=false) then begin
  446.                             Voteo := true;
  447.                             Time := 15;
  448.                         end else inc(Time,5);
  449.                         voter[id] := true;
  450.                         inc(Votes,1);
  451.                         DrawTextEx(0,51,'Vote to OFF - '+inttostr(Votes)+'/'+inttostr(iif(c>=mix,mix,c))+' ('+inttostr(time)+'s)',140,GOOD,0.075,180,2);
  452.                         CheckVotes();
  453.                     end else WriteConsole(0,'You have already voted!',BAD);
  454.                 end else WriteConsole(ID,'Takes vote per next one map.',BAD);
  455.             end else WriteConsole(ID,'Currently, the vote per mixing teams.',BAD);
  456.         end else WriteConsole(ID,'Takes vote per restarting the match.',BAD);
  457.     end else WriteConsole(ID,'You can`t disable match, when you don`t participate in match.',BAD);
  458.  
  459.     if regExpMatch('^!(r|reset|restart)$',lowercase(Text)) then if (PlayerInMix[ID] = true) then begin
  460.         if (Voteo = false) then begin
  461.             if (VoterM = false) then begin
  462.                 if (VoteN=false) then begin
  463.                     if (voter[id] = false) then begin
  464.                         c:=0;
  465.                         for i := 1 to (mix*2) do if (MixList[i] <> '') then inc(c,1);
  466.                         if (Voterr=false) then begin
  467.                             Voterr := true;
  468.                             Time := 15;
  469.                         end else inc(Time,5);
  470.                         voter[id] := true;
  471.                         inc(Votes2,1);
  472.                         DrawTextEx(0,51,'Vote to restart - '+inttostr(Votes2)+'/'+inttostr(iif(c>=mix,mix,c))+' ('+inttostr(time)+'s)',140,GOOD,0.075,180,2);
  473.                         CheckVotes();
  474.                     end else WriteConsole(0,'You have already voted!',BAD);
  475.                 end else WriteConsole(ID,'Takes vote per nextmap.',BAD);
  476.             end else WriteConsole(ID,'Currently, the vote per mixing teams.',BAD);
  477.         end else WriteConsole(ID,'Currently, the vote for the off match.',BAD);
  478.     end else WriteConsole(ID,'You can`t restart the game if you don`t participate in match!',BAD);
  479.  
  480.     if regExpMatch('^!(ub|unbanlast)$',lowercase(Text)) then if (PlayerInMix[ID] = true) then Command('/unbanlast') else WriteConsole(ID,'You can`t unban players if you don`t participate in match!',BAD);
  481.  
  482.     if regExpMatch('^!(status)$',lowercase(Text)) then begin
  483.         if (Mix<>0) then begin
  484.             WriteConsole(ID,'Match ON '+inttostr(Mix)+'vs'+inttostr(Mix)+': ',GOOD);
  485.             if (Mix=1) then WriteConsole(0,iif(Mix=1,iif(MixList[1]<>'',MixList[1]+',','-=1=-')+' '+iif(MixList[2]<>'',MixList[2],'-=2=-'),''),GOOD) else if (Mix=2) then WriteConsole(0,iif(Mix=2,iif(MixList[1]<>'',MixList[1]+',','-=1=-')+' '+iif(MixList[2]<>'',MixList[2]+',','-=2=-')+' '+iif(MixList[3]<>'',MixList[3]+',','-=3=-')+' '+iif(MixList[4]<>'',MixList[4],'-=4=-'),''),GOOD) else if (Mix=3) then WriteConsole(0,iif(Mix=3,iif(MixList[1]<>'',MixList[1]+',','-=1=-')+' '+iif(MixList[2]<>'',MixList[2]+',','-=2=-')+' '+iif(MixList[3]<>'',MixList[3]+',','-=3=-')+' '+iif(Mix=3,iif(MixList[4]<>'',MixList[4]+',','-=4=-')+' '+iif(MixList[5]<>'',MixList[5]+',','-=5=-')+' '+iif(MixList[6]<>'',MixList[6],'-=6=-'),''),''),GOOD) else if (Mix=4) then WriteConsole(0,iif(Mix=4,iif(MixList[1]<>'',MixList[1]+',','-=1=-')+' '+iif(MixList[2]<>'',MixList[2]+',','-=2=-')+' '+iif(MixList[3]<>'',MixList[3]+',','-=3=-')+' '+iif(MixList[4]<>'',MixList[4]+',','-=4=-')+' '+iif(Mix=4,iif(MixList[5]<>'',MixList[5]+',','-=5=-')+' '+iif(MixList[6]<>'',MixList[6]+',','-=6=-')+' '+iif(MixList[7]<>'',MixList[7]+',','-=7=-')+' '+iif(MixList[8]<>'',MixList[8],'-=8=-'),''),''),GOOD);
  486.         end else WriteConsole(ID,'Match OFF.',GOOD);
  487.     end;
  488.  
  489.     if regExpMatch('^!(p|pause|pauza|stop)$',lowercase(Text)) then if (PlayerInMix[ID] = true) then begin
  490.         if (pause=0) then begin
  491.             Command('/pause');
  492.             WriteConsole(0,GetPlayerStat(ID,'name')+' turned on the paused!',GOOD);
  493.             WriteConsole(0,'Pause is automatically turned off after 1:30 min.',GOOD);
  494.             pause:=91;
  495.         end else WriteConsole(ID,'Pause is already switched on!',BAD);
  496.     end else WriteConsole(ID,'You can`t give pause without being in the course of the match.',BAD);
  497.  
  498.     if regExpMatch('^!(up|unpause|unpauze|play)$',lowercase(Text)) then if (PlayerInMix[ID] = true) then begin
  499.         if (pause>0) then begin
  500.             if (pause<=4) then WriteConsole(ID,'Takes off pause.',BAD) else pause:=4;
  501.         end else WriteConsole(ID,'Pause is not switched on!',BAD);
  502.     end else WriteConsole(ID,'You can`t cancel without being paused during the match.',BAD);
  503.  
  504.     if regExpMatch('^!(mixt|mixteam|mixteams|mt)$',lowercase(Text)) then if (PlayerInMix[id]=true) then begin
  505.         if (Voteo = false) then begin
  506.             if (Voterr=false) then begin
  507.                 if (VoteN=false) then begin
  508.                     if (voter[id] = false) then begin
  509.                         c:=0;
  510.                         for i := 1 to (mix*2) do if (MixList[i] <> '') then inc(c,1);
  511.                         if (Voterm=false) then begin
  512.                             Voterm := true;
  513.                             Time := 15;
  514.                         end else inc(Time,5);
  515.                         voter[id] := true;
  516.                         inc(Votes3,1);
  517.                         DrawTextEx(0,51,'Vote to mix teams - '+inttostr(Votes3)+'/'+inttostr(iif(c>=mix,mix,c))+' ('+inttostr(time)+'s)',140,GOOD,0.075,180,2);
  518.                         CheckVotes();
  519.                     end else WriteConsole(0,'You have already voted!',BAD);
  520.                 end else WriteConsole(ID,'Takes vote per nextmap.',BAD);
  521.             end else WriteConsole(ID,'Takes vote per restarting the match.',BAD);
  522.         end else WriteConsole(ID,'Currently, the vote for the off match.',BAD);
  523.     end else WriteConsole(ID,'You can`t vote per mixing teams without being in the course of the match.',BAD);
  524.    
  525.     if regExpMatch('^!(next|nextmap|votemap|nextvote)$',lowercase(Text)) then if (PlayerInMix[ID] = true) then begin
  526.         if (Voteo = false) then begin
  527.             if (VoterM = false) then begin
  528.                 if (Voterr=false) then begin
  529.                     if (voter[id] = false) then begin
  530.                         c:=0;
  531.                         for i := 1 to (mix*2) do if (MixList[i] <> '') then inc(c,1);
  532.                         if (VoteN=false) then begin
  533.                             VoteN := true;
  534.                             Time := 15;
  535.                         end else inc(Time,5);
  536.                         voter[id] := true;
  537.                         inc(Votes4,1);
  538.                         DrawTextEx(0,51,'Vote to nextmap - '+inttostr(Votes4)+'/'+inttostr(iif(c>=mix,mix,c))+' ('+inttostr(time)+'s)',140,GOOD,0.075,180,2);
  539.                         DrawTextEx(0,55,'                ('+NextMap+')',140,GOOD,0.075,180,16);
  540.                         CheckVotes();
  541.                     end else WriteConsole(0,'You have already voted!',BAD);
  542.                 end else WriteConsole(ID,'Takes vote per restarting the match.',BAD);
  543.             end else WriteConsole(ID,'Currently, the vote per mixing teams.',BAD);
  544.         end else WriteConsole(ID,'Currently, the vote for the off match.',BAD);
  545.     end else WriteConsole(ID,'You can`t vote for nextmap, without being in the match.',BAD);
  546. end;
  547.  
  548. procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
  549. var i: byte; c: integer;
  550. begin
  551.     if (PlayerInMix[ID] = true) then begin
  552.  
  553.         for i := 1 to 8 do if (MixList[i] = GetPlayerStat(ID,'Name')) then MixList[i] := '';    //Usun z listy
  554.  
  555.         c:=0;
  556.         for i := 1 to 8 do if (MixList[i] = '') then inc(c,1); 
  557.         if (c=8) then begin                 //By Dominik
  558.             Mix:=0;                         //Wylacz mix gdy brak graczy
  559.             matchon:=false;
  560.         end;
  561.  
  562.         SubCheck(ID,1,false,1);                     //Dodaj innego
  563.  
  564.         if (voter[id] = true) then begin
  565.             if (Votes > 0) then dec(Votes,1);               //Jesli glosowal, usun jego glos
  566.             if (Votes2 > 0) then dec(Votes2,1);
  567.             if (Votes3 > 0) then dec(Votes3,1);
  568.             if (Votes4 > 0) then dec(Votes4,1);
  569.             CheckVotes();
  570.         end;
  571.     end;
  572.     ResVar(ID);                                     //Reset zmiennych
  573.  
  574.     if (Mix=1) then WriteConsole(0,iif(Mix=1,iif(MixList[1]<>'',MixList[1]+',','-=1=-')+' '+iif(MixList[2]<>'',MixList[2],'-=2=-'),''),GOOD) else if (Mix=2) then WriteConsole(0,iif(Mix=2,iif(MixList[1]<>'',MixList[1]+',','-=1=-')+' '+iif(MixList[2]<>'',MixList[2]+',','-=2=-')+' '+iif(MixList[3]<>'',MixList[3]+',','-=3=-')+' '+iif(MixList[4]<>'',MixList[4],'-=4=-'),''),GOOD) else if (Mix=3) then WriteConsole(0,iif(Mix=3,iif(MixList[1]<>'',MixList[1]+',','-=1=-')+' '+iif(MixList[2]<>'',MixList[2]+',','-=2=-')+' '+iif(MixList[3]<>'',MixList[3]+',','-=3=-')+' '+iif(Mix=3,iif(MixList[4]<>'',MixList[4]+',','-=4=-')+' '+iif(MixList[5]<>'',MixList[5]+',','-=5=-')+' '+iif(MixList[6]<>'',MixList[6],'-=6=-'),''),''),GOOD) else if (Mix=4) then WriteConsole(0,iif(Mix=4,iif(MixList[1]<>'',MixList[1]+',','-=1=-')+' '+iif(MixList[2]<>'',MixList[2]+',','-=2=-')+' '+iif(MixList[3]<>'',MixList[3]+',','-=3=-')+' '+iif(MixList[4]<>'',MixList[4]+',','-=4=-')+' '+iif(Mix=4,iif(MixList[5]<>'',MixList[5]+',','-=5=-')+' '+iif(MixList[6]<>'',MixList[6]+',','-=6=-')+' '+iif(MixList[7]<>'',MixList[7]+',','-=7=-')+' '+iif(MixList[8]<>'',MixList[8],'-=8=-'),''),''),GOOD);
  575. end;
  576.  
  577. procedure AppOnIdle(Ticks: integer);
  578. var i: byte; c:integer;
  579. begin
  580.     DrawTextEx(0,49,'MIX '+iif((mix<>0),'ON','OFF')+'!',140,iif((mix<>0),GOOD,BAD),0.075,705,2);    //Mix on off prawy rog 553 dol 545
  581.     if (mix<>0) then DrawTextEx(0,50,'('+inttostr(mix)+'vs'+inttostr(mix)+')',140,iif((mix<>0),GOOD,BAD),0.075,719,13);
  582.    
  583.     if (Time>0) then begin
  584.         dec(time,1);
  585.  
  586.         c:=0;
  587.         for i := 1 to (mix*2) do if (MixList[i] <> '') then inc(c,1);
  588.  
  589.         if (Votes<>0) then DrawTextEx(0,51,'Vote to OFF - '+inttostr(Votes)+'/'+inttostr(iif(c>=mix,mix,c))+' ('+inttostr(time)+'s)',140,GOOD,0.075,180,2);
  590.         if (Time=0) then begin
  591.             Voteo := false;
  592.             Votes := 0;
  593.             for i := 1 to 32 do if (GetPlayerStat(i, 'Active')=true) then voter[i] := false;
  594.             DrawTextEx(0,51,'Vote to OFF - Failure!',140,BAD,0.075,180,2);
  595.         end;
  596.         if (Votes2<>0) then DrawTextEx(0,51,'Vote to Restart - '+inttostr(Votes2)+'/'+inttostr(iif(c>=mix,mix,c))+' ('+inttostr(time)+'s)',140,GOOD,0.075,180,2);
  597.         if (Time=0) then begin
  598.             Voterr := false;
  599.             Votes2 := 0;
  600.             for i := 1 to 32 do if (GetPlayerStat(i, 'Active')=true) then voter[i] := false;
  601.             DrawTextEx(0,51,'Vote to Reset - Failure!',140,BAD,0.075,180,2);
  602.         end;
  603.         if (Votes3<>0) then DrawTextEx(0,51,'Vote to mix teams - '+inttostr(Votes3)+'/'+inttostr(iif(c>=mix,mix,c))+' ('+inttostr(time)+'s)',140,GOOD,0.075,180,2);
  604.         if (Time=0) then begin
  605.             Voterm := false;
  606.             Votes3 := 0;
  607.             for i := 1 to 32 do if (GetPlayerStat(i, 'Active')=true) then voter[i] := false;
  608.             DrawTextEx(0,51,'Vote to mix teams - Failure!',140,BAD,0.075,180,2);
  609.         end;
  610.         if (Votes4<>0) then begin
  611.             DrawTextEx(0,51,'Vote to nextmap - '+inttostr(Votes4)+'/'+inttostr(iif(c>=mix,mix,c))+' ('+inttostr(time)+'s)',140,GOOD,0.075,180,2);
  612.             DrawTextEx(0,55,'               ('+NextMap+')',140,GOOD,0.075,180,16);
  613.         end;
  614.         if (Time=0) then begin
  615.             VoteN := false;
  616.             Votes4 := 0;
  617.             for i := 1 to 32 do if (GetPlayerStat(i, 'Active')=true) then voter[i] := false;
  618.             DrawTextEx(0,51,'Vote to nextmap - Failure!',140,BAD,0.075,180,2);  DrawTextEx(0,55,'',140,GOOD,0.075,180,16);
  619.         end;
  620.     end;
  621.  
  622.     if (pause > 0) then begin
  623.         dec(pause,1);
  624.         if (pause = 3) then WriteConsole(0,'Unpausing!',GOOD);
  625.         if (pause > 0) and (pause < 4) then WriteConsole(0,inttostr(pause)+'...', GOOD) else begin
  626.             if (pause = 0) then begin
  627.                 WriteConsole(0,'GO GO GO!',GOOD);
  628.                 Command('/unpause');
  629.             end;
  630.         end;
  631.     end;
  632. end;
  633.  
  634. procedure SerRes();
  635. var i:byte;
  636. begin
  637.     Mix := 0;
  638.     for i := 1 to 32 do if (GetPlayerStat(i, 'Active')=true) then begin
  639.         ResVar(i);
  640.         prewteam[i] := GetPlayerStat(i,'Team');
  641.     end;
  642.     for i := 1 to 8 do MixList[i] := '';
  643.     Votes := 0;
  644.     Votes2 := 0;
  645.     Votes3 := 0;
  646.     Votes4 := 0;
  647.     Voteo := false;
  648.     Voterr := false;
  649.     VoterM := false;
  650.     VoteN := false;
  651.     matchon := false;
  652.     Anty:=0;
  653.     mixteams:=false;
  654. end;
  655.  
  656. procedure OnMapChange(NewMap: String);
  657. begin
  658.     if (Anty<>1) then SerRes();
  659.     Anty:=0;
  660. end;
  661.  
  662. procedure ActivateServer();
  663. begin
  664.     SerRes();
  665. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement