0 Members and 1 Guest are viewing this topic.
constconstQUEUE_LIMIT = 6;QUEUE_ON = 1;var queue: array[1..QUEUE_LIMIT] of string; queueoff: array[1..32] of string; i,j,pos,fromlist,off,offint: integer;procedure ActivateServer();begin pos:=1; offint:=0;end;function OnRequestGame(IP: string;state: integer):integer;begin off:=0; for i:=1 to 32 do if queueoff[i] = IP then off:= 1; if((State=5)and(pos<=QUEUE_LIMIT)and(QUEUE_ON=1)and(off=0)) then begin  queue[pos]:=IP;  pos:=pos+1;  command('/maxplayers '+inttostr(MaxPlayers+1));  state:=1; end; result:=state;end;function GetPos(IP:string):byte;begin for i:=1 to pos-1 do begin  if IP = queue[i] then begin   Result:= i;   break;  end; end;end;procedure OnJoinTeam(IP, Nickname: string;Team: byte);begin for i:=1 to pos-1 do if queue[i] = IP then begin  command('/setteam5 '+inttostr(IPtoID(IP)));  SayToPlayer(NametoID(Nickname),'Hi, please wait to play');  SayToPlayer(NametoID(Nickname),'Your place on queue: '+inttostr(GetPos(IP))); end;end;function IDtoIP(PlayerID: integer):string;begin case PlayerID of  1: Result:= Player_IP_1;  2: Result:= Player_IP_2;  3: Result:= Player_IP_3;  4: Result:= Player_IP_4;  5: Result:= Player_IP_5;  6: Result:= Player_IP_6;  7: Result:= Player_IP_7;  8: Result:= Player_IP_8;  9: Result:= Player_IP_9;  10: Result:= Player_IP_10;  11: Result:= Player_IP_11;  12: Result:= Player_IP_12;  13: Result:= Player_IP_13;  14: Result:= Player_IP_14;  15: Result:= Player_IP_15;  16: Result:= Player_IP_16;  17: Result:= Player_IP_17;  18: Result:= Player_IP_18;  19: Result:= Player_IP_19;  20: Result:= Player_IP_20;  21: Result:= Player_IP_21;  22: Result:= Player_IP_22;  23: Result:= Player_IP_23;  24: Result:= Player_IP_24;  25: Result:= Player_IP_25;  26: Result:= Player_IP_26;  27: Result:= Player_IP_27;  28: Result:= Player_IP_28;  29: Result:= Player_IP_29;  30: Result:= Player_IP_30;  31: Result:= Player_IP_31;  32: Result:= Player_IP_32; end;end;procedure OnLeaveGame(IP: string; Nickname: string;Team: byte);begin if QUEUE_ON=1 then begin  fromlist:=0;  for i:=1 to pos-1 do if IDtoIP(NametoID(Nickname)) = queue[i] then begin   fromlist:=1;   command('/maxplayers '+inttostr(MaxPlayers-1));   for j:=i+1 to pos-1 do queue[j-1]:= queue[j];   queue[pos-1]:='';   pos:=pos-1;  end;  if((queue[1]<>'')and(fromlist=0)) then begin   command('/setteam'+inttostr(Team)+' '+inttostr(IPtoID(queue[1])));  //command('/setteam'+iif(BravoPlayers>AlphaPlayers,1,2)+' '+inttostr(IPtoID(queue[1]))); //makes teams more equal, but works only for ctf/inf   command('/maxplayers '+inttostr(MaxPlayers-1));   for i:=2 to pos-1 do queue[i-1]:= queue[i];   queue[pos-1]:='';   pos:=pos-1;  end; end;end;procedure OnCommand(ID: integer;Text: string);begin if Copy(Text,1,9) = '/qoffadd ' then begin   if(Length(Text)>15)then begin    offint:=offint+1;    queueoff[offint]:= Copy(Text,10,Length(Text)-9);    SaytoPlayer(ID, queueoff[offint]+' was added to queueoff list');   end    else if((IDtoName(strtoint(Copy(Text,10,Length(Text)-9)))<>'') and (strtoint(Copy(Text,10,Length(Text)-9))<=32)) then begin     offint:=offint+1;     queueoff[offint]:= IDtoIP(strtoint(Copy(Text,10,Length(Text)-9)));     SaytoPlayer(ID, IDtoName(strtoint(Copy(Text,10,Length(Text)-9)))+' was added to queueoff list');    end    else SaytoPlayer(ID, 'there''s no player with such ID'); end; if Text = '/qoffshow' then begin  if offint <> 0 then begin for i:=1 to offint do SaytoPlayer(ID, inttostr(i)+': '+ queueoff[i]+iif(IPtoID(queueoff[i])=32,' [not on server]',' ID: '+inttostr(IPtoID(queueoff[i])))); end   else SaytoPlayer(ID, 'queueoff list is empty'); end; if Copy(Text,1,9) = '/qoffdel ' then begin  if strtoint(Copy(Text,10,Length(Text)-9)) <= offint then begin   SaytoPlayer(ID, queueoff[strtoint(Copy(Text,10,Length(Text)-9))]+ ' was deleted from queueoff list');   for i:=strtoint(Copy(Text,10,Length(Text)-9))+1 to offint do queueoff[i-1]:= queueoff[i];   queueoff[offint]:='';   offint:=offint-1;  end   else SaytoPlayer(ID, 'there''s no such position on queueoff list'); end; if Text = '/qoffclear' then begin  SaytoPlayer(ID, 'queueoff list was cleared');  for i:=1 to offint do queueoff[i]:='';  offint:=0; end; if Text = '/qclear' then begin  for i:=1 to pos-1 do begin   KickPlayer(IPtoID(queue[i]));   queue[i]:='';   command('/maxplayers '+inttostr(MaxPlayers-1));  end;  pos:=1; end; if Text = '/qshow' then begin  if pos<>1 then begin for i:=1 to pos-1 do SayToPlayer(ID,inttostr(i)+': '+queue[i]+' nick: '+IDtoName(IPtoID(queue[i]))); end   else SaytoPlayer(ID, 'queue list is empty'); end;end;procedure OnPlayerSpeak(Name,Text: string);begin if Text = '!queue' then begin  if GetPos(IDtoIP(NametoID(Name))) = 0 then begin SayToPlayer(NametoID(Name),'You''re not on queue'); end   else SayToPlayer(NametoID(Name),'Your place on queue: '+inttostr(GetPos(IDtoIP(NametoID(Name))))); end;end;