const color=$FFFCD822; color_charlie=$DEDE53; color_delta=$52DF52; color_info=$5598fd; var Timer: integer; Flagger: integer; Last_Flagger: integer; BlueFlagX,BlueFlagY,RedFlagX,RedFlagY: single; Team: integer; Last_Team: integer; Passes: integer; Passer: integer; i: integer; Charlie_Score: integer; Delta_Score: integer; Temp: string; Total: integer; Temp_Num: integer; First_Swapper: integer; Waiting: integer; type tPlayer = record score, teamkill, self_pass, held, double_pass, team, waiting, swap: integer; end; var Players: array[1..32] of tPlayer; function reset_round(): integer; begin KillObject(1); Flagger := -1; Last_Flagger := -1; Last_Team := -1; Team := -1; Last_Team := -1; Passes := 0; Passer := -1; for i := 1 to 32 do begin if GetPlayerStat(i, 'active') then Command('/kill '+inttostr(i)); end; if Charlie_Score = Delta_Score then begin WriteConsole(0,'Charlie '+inttostr(Charlie_Score)+' - '+inttostr(Delta_Score)+' Delta',color_info); DrawText(0,'Charlie '+inttostr(Charlie_Score)+' - '+inttostr(Delta_Score)+' Delta',150,color_info,0.20,200,240); end else begin if Charlie_Score > Delta_Score then begin WriteConsole(0,'Charlie '+inttostr(Charlie_Score)+' - '+inttostr(Delta_Score)+' Delta',color_charlie); DrawText(0,'Charlie '+inttostr(Charlie_Score)+' - '+inttostr(Delta_Score)+' Delta',150,color_charlie,0.20,200,240); end else begin WriteConsole(0,'Charlie '+inttostr(Charlie_Score)+' - '+inttostr(Delta_Score)+' Delta',color_delta); DrawText(0,'Charlie '+inttostr(Charlie_Score)+' - '+inttostr(Delta_Score)+' Delta',150,color_delta,0.20,200,240); end; end; for i := 1 to 32 do begin if GetPlayerStat(i, 'active') then if Players[i].waiting = 1 then if DeltaPlayers = CharliePlayers then begin Players[i].team := 3; Players[i].waiting := 0; Command('/setteam3 '+ InttoStr(i)); end else begin if DeltaPlayers > CharliePlayers then begin Players[i].team := 3; Players[i].waiting := 0; Command('/setteam3 '+ InttoStr(i)); end else begin Players[i].team := 4; Players[i].waiting := 0; Command('/setteam4 '+ InttoStr(i)); end; end; end; if (Charlie_Score = 10) OR (Delta_Score = 10) then begin Charlie_Score := 0; Delta_Score := 0; SetTeamScore(2, 0); SetTeamScore(1, 0); end; end; procedure OnPlayerSpeak(ID: Byte; Text: string); begin if Text='!play' then begin if Players[ID].waiting = 0 then begin if GetPlayerStat(ID, 'Team') = 5 then begin Players[ID].waiting := 1; Waiting := Waiting+1; end; end; if (DeltaPlayers > 0) OR (CharliePlayers > 0) then begin WriteConsole(ID,'Please wait for the round to end',color_info); end else begin if Waiting > 1 then begin for i := 1 to 32 do begin if GetPlayerStat(i, 'active') then if Players[i].waiting = 1 then if DeltaPlayers = CharliePlayers then begin Players[i].team := 3; Players[i].waiting := 0; if Delta_Score > Charlie_Score then begin Command('/setteam3 '+ InttoStr(i)); end else begin Command('/setteam4 '+ InttoStr(i)); end; end else begin if DeltaPlayers > CharliePlayers then begin Players[i].team := 3; Players[i].waiting := 0; Command('/setteam3 '+ InttoStr(i)); end else begin Players[i].team := 4; Players[i].waiting := 0; Command('/setteam4 '+ InttoStr(i)); end; end; end; end else begin WriteConsole(ID,'Please wait for another player to join',color_info); end; end; end; if Text='!c' then Command('/setteam3 '+ InttoStr(ID)); if Text='!d' then Command('/setteam4 '+ InttoStr(ID)); if Text='!restart' then Command('/restart'); if Text='!swap' then begin if First_Swapper = 0 then begin First_Swapper := ID; WriteConsole(0,GetPlayerStat(ID, 'Name')+' wants to swap team, type !swap to swap with him',color_info); end else begin if GetPlayerStat(First_Swapper, 'Team') = GetPlayerStat(ID, 'Team') then begin WriteConsole(0,'Unable to swap to player from the same team',color_info); end else begin if GetPlayerStat(First_Swapper, 'Team') = 3 then begin Players[First_Swapper].swap := 1; Players[ID].swap := 1; Command('/setteam4 '+ InttoStr(First_Swapper)); Command('/setteam3 '+ InttoStr(ID)); WriteConsole(0,'Successfuly swapped '+GetPlayerStat(First_Swapper, 'Name')+' with '+GetPlayerStat(ID, 'Name'),color_info); First_Swapper := 0; end else begin Players[First_Swapper].swap := 1; Players[ID].swap := 1; Command('/setteam3 '+ InttoStr(First_Swapper)); Command('/setteam4 '+ InttoStr(ID)); WriteConsole(0,'Successfuly swapped '+GetPlayerStat(First_Swapper, 'Name')+' with '+GetPlayerStat(ID, 'Name'),color_info); First_Swapper := 0; end; end; end; end; if Text='!stats' then begin WriteConsole(0,'+----------------------------------------------+',color_info); Total := Length('+----------------------------------------------+'); Temp := '| '+GetPlayerStat(ID, 'Name')+' Stats'; Temp_Num := Total-Length(Temp); for i:=2 to Temp_num do begin Temp:= Temp+' '; end; Temp := Temp+'| '; WriteConsole(0,Temp,color_info); Temp := ''; Temp := '| Score: '+inttostr(Players[ID].score); Temp_Num := Total-Length(Temp); for i:=2 to Temp_num do begin Temp:= Temp+' '; end; Temp := Temp+'|'; WriteConsole(0,Temp,color_info); Temp := ''; Temp := '| Score against own team: '+inttostr(Players[ID].teamkill); Temp_Num := Total-Length(Temp); for i:=2 to Temp_num do begin Temp:= Temp+' '; end; Temp := Temp+'|'; WriteConsole(0,Temp,color_info); Temp := ''; Temp := '| Didnt throw the flag at time: '+inttostr(Players[ID].held); Temp_Num := Total-Length(Temp); for i:=2 to Temp_num do begin Temp:= Temp+' '; end; Temp := Temp+'|'; WriteConsole(0,Temp,color_info); Temp := ''; Temp := '| Tried to pass himself: '+inttostr(Players[ID].self_pass); Temp_Num := Total-Length(Temp); for i:=2 to Temp_num do begin Temp:= Temp+' '; end; Temp := Temp+'|'; WriteConsole(0,Temp,color_info); Temp := ''; Temp := '| Tried to catch a flag that wasnt for him: '+inttostr(Players[ID].double_pass); Temp_Num := Total-Length(Temp); for i:=2 to Temp_num do begin Temp:= Temp+' '; end; Temp := Temp+'|'; WriteConsole(0,Temp,color_info); Temp := ''; WriteConsole(0,'+----------------------------------------------+',color_info); end; end; procedure OnJoinGame(ID, Team: byte); begin if NumPlayers < 2 then begin Command('/setteam5 '+ InttoStr(ID)); Players[ID].team := 5; DrawText(ID,'Please wait for players...',500,color_info,0.20,150,240); end else begin Command('/setteam5 '+ InttoStr(ID)); Players[ID].team := 5; DrawText(ID,'Type !play to start',500,color_info,0.20,150,240); end; end; procedure OnJoinTeam(ID, Team: byte); begin if Players[ID].swap = 1 then begin Players[ID].swap := 0; Players[ID].team := Team; Command('/setteam'+InttoStr(Team)+' '+ InttoStr(ID)); end else begin if Team <> Players[ID].team then if Team <> 5 then Command('/setteam'+InttoStr(Players[ID].team)+' '+ InttoStr(ID)); end; end; procedure OnFlagGrab(ID, TeamFlag: byte; GrabbedInBase: boolean); begin; Flagger := ID; Team := GetPlayerStat(Flagger, 'Team'); Timer := 3; DrawText(Flagger,inttostr(Timer)+'s',200,color_info,0.20,380,340); if Team = Last_Team then begin Passes := Passes+1; Passer := Last_Flagger; end else begin Passes := 0; end; if Passes > 2 then begin Players[Flagger].double_pass := Players[Flagger].double_pass+1; WriteConsole(0,'['+inttostr(Players[Flagger].double_pass)+'] '+GetPlayerStat(Flagger, 'Name')+' is working for the enemy team',color); if Last_Team = 3 then begin Delta_Score := Delta_Score+1; SetTeamScore(2, Delta_Score); end else begin Charlie_Score := Charlie_Score+1; SetTeamScore(1, Charlie_Score); end; reset_round(); end; if Flagger = Last_Flagger then begin Players[Flagger].self_pass := Players[Flagger].self_pass+1; WriteConsole(0,'['+inttostr(Players[Flagger].self_pass)+'] '+GetPlayerStat(Flagger, 'Name')+' tried to make a pass to himself...',color); if Last_Team = 3 then begin Delta_Score := Delta_Score+1; SetTeamScore(2, Delta_Score); end else begin Charlie_Score := Charlie_Score+1; SetTeamScore(1, Charlie_Score); end; reset_round(); end; Last_Flagger := Flagger; Last_Team := Team; end; //Y: 30 = under the line //X > 0 = delta //X < 0 = charlie procedure AppOnIdle(Ticks: integer); begin; GetFlagsXY(BlueFlagX,BlueFlagY,RedFlagX,RedFlagY); if RedFlagY > 60 then begin if RedFlagX > 0 then begin //delta base //charlie +1 if Last_Team = 4 then begin Players[Last_Flagger].teamkill := Players[Last_Flagger].teamkill+1; WriteConsole(0,'['+inttostr(Players[Last_Flagger].teamkill)+'] '+GetPlayerStat(Last_Flagger, 'Name')+' is playing against his own team +1 for Charlie Team',color_delta); if GetPlayerStat(Last_Flagger, 'Kills') > 0 then begin SetScore(Last_Flagger, GetPlayerStat(Last_Flagger, 'Kills')-1); end; Charlie_Score := Charlie_Score+1; SetTeamScore(1, Charlie_Score); end else begin if Passes = 1 then begin Players[Passer].score := Players[Passer].score+1; Players[Last_Flagger].score := Players[Last_Flagger].score+1; WriteConsole(0,'['+inttostr(Players[Last_Flagger].score)+' - '+inttostr(Players[Passer].score)+' ] '+GetPlayerStat(Last_Flagger, 'Name')+' and '+GetPlayerStat(Passer, 'Name')+' scored! +2 for Charlie Team',color_charlie); SetScore(Last_Flagger, GetPlayerStat(Last_Flagger, 'Kills')+1); SetScore(Passer, GetPlayerStat(Passer, 'Kills')+1); Charlie_Score := Charlie_Score+2; SetTeamScore(1, Charlie_Score); end else begin Players[Last_Flagger].score := Players[Last_Flagger].score+1; WriteConsole(0,'['+inttostr(Players[Last_Flagger].score)+'] '+GetPlayerStat(Last_Flagger, 'Name')+' scored! +1 for Charlie Team',color_charlie); SetScore(Last_Flagger, GetPlayerStat(Last_Flagger, 'Kills')+1); Charlie_Score := Charlie_Score+1; SetTeamScore(1, Charlie_Score); end; end; reset_round(); end else begin //charlie base //delta +1 if Last_Team = 3 then begin Players[Last_Flagger].teamkill := Players[Last_Flagger].teamkill+1; WriteConsole(0,'['+inttostr(Players[Last_Flagger].teamkill)+'] '+GetPlayerStat(Last_Flagger, 'Name')+' is playing against his own team +1 for Delta Team',color_charlie); if GetPlayerStat(Last_Flagger, 'Kills') > 0 then begin SetScore(Last_Flagger, GetPlayerStat(Last_Flagger, 'Kills')-1); end; Delta_Score := Delta_Score+1; SetTeamScore(2, Delta_Score); end else begin if Passes = 1 then begin Players[Passer].score := Players[Passer].score+1; Players[Last_Flagger].score := Players[Last_Flagger].score+1; WriteConsole(0,'['+inttostr(Players[Last_Flagger].score)+' - '+inttostr(Players[Passer].score)+' ] '+GetPlayerStat(Last_Flagger, 'Name')+' and '+GetPlayerStat(Passer, 'Name')+' scored! +2 for Charlie Team',color_delta); SetScore(Last_Flagger, GetPlayerStat(Last_Flagger, 'Kills')+1); SetScore(Passer, GetPlayerStat(Passer, 'Kills')+1); Delta_Score := Delta_Score+2; SetTeamScore(2, Delta_Score); end else begin Players[Last_Flagger].score := Players[Last_Flagger].score+1; WriteConsole(0,'['+inttostr(Players[Last_Flagger].score)+'] '+GetPlayerStat(Last_Flagger, 'Name')+' scored! +1 for Delta Team',color_delta); SetScore(Last_Flagger, GetPlayerStat(Last_Flagger, 'Kills')+1); Delta_Score := Delta_Score+1; SetTeamScore(2, Delta_Score); end; end; reset_round(); end; end; if Timer > 0 then begin Timer := Timer - 1; if GetPlayerStat(Flagger, 'Flagger') then DrawText(Flagger,inttostr(Timer)+'s',200,color_info,0.20,380,340); end; if Timer = 0 then begin if GetPlayerStat(Flagger, 'Flagger') then begin WriteConsole(Flagger,'You held the flag too long',color_info); Players[Last_Flagger].held := Players[Last_Flagger].held+1; if Last_Team = 3 then begin Delta_Score := Delta_Score+1; SetTeamScore(2, Delta_Score); WriteConsole(0,'['+inttostr(Players[Flagger].held)+'] '+GetPlayerStat(Flagger, 'Name')+' was too stupid to throw the flag +1 for Delta Team',color_charlie); if GetPlayerStat(Flagger, 'Kills') > 0 then SetScore(Flagger, GetPlayerStat(Flagger, 'Kills')-1); end else begin Charlie_Score := Charlie_Score+1; SetTeamScore(1, Charlie_Score); WriteConsole(0,'['+inttostr(Players[Flagger].held)+'] '+GetPlayerStat(Flagger, 'Name')+' was too stupid to throw the flag +1 for Charlie Team',color_delta); if GetPlayerStat(Flagger, 'Kills') > 0 then SetScore(Flagger, GetPlayerStat(Flagger, 'Kills')-1); end; reset_round(); Timer := -1; end; end; end;