Advertisement
Guest User

Untitled

a guest
Feb 15th, 2017
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 16.34 KB | None | 0 0
  1. //Savage's Hide 'n Seek 0.7
  2. //Core Version: 2.8.1
  3. {Description: The minimum number of players required to play is 3.
  4. Server will choose the Seeker randomly.
  5. Seeker has to seek and kill hiders.
  6. Last alive player will become a Seeker.}
  7.  
  8. const
  9.     HnSlogo = '{HnS} ';
  10.    
  11.     Color1 = $F0E68C; //Used for basic messages//Khaki
  12.     Color2 = $FF0000; //Used for warning messages//Red
  13.     Color3 = $6495ed; //Used for BigText//Cornflower Blue
  14.     Color4 = $458b74; //Used for additional messages//Aquamarine
  15.     Color5 = $ffd700; //Used for additional messages//Gold
  16.    
  17.     const_SeekerTeam = 1;
  18.     const_HidersTeam = 2;
  19.    
  20.     const_Timer1 = 10; //Time for collecting players/choosing seeker//Seconds
  21.     const_Timer2 = 20; //Time for seeker to choose map//Seconds
  22.     const_Timer3 = 10; //Time for hiders to hide(Added 10s for map change)//Seconds
  23.     const_GameTimer = 450; //Game duration//Seconds
  24.    
  25. var
  26.     GV_SeekerID: Byte;
  27.     GV_SeekerHWID: String;
  28.     GV_Timer1, GV_Timer2, GV_Timer3, GV_GameTimer: Word;
  29.     GV_UnlockSeekerTeam, GV_DoNotCheckTeamEvent: Boolean;
  30.     GV_EnableAFK: array[1..32] of Boolean;
  31.    
  32. function CountPlayersInTeam(TeamID: Byte): Byte;{Used to fix triple spec bug}
  33. var
  34.     i: Byte;
  35. begin
  36.     for i := 1 to 32 do
  37.     if (Players[i].Active) and (Players[i].Team=TeamID) then
  38.     Inc(Result, 1);
  39. end;
  40.  
  41. procedure ChooseSeeker;
  42. var
  43.     i, total: Byte;
  44.     Hiders: array[1..32] of Byte;
  45. begin
  46.     for i := 1 to 32 do
  47.     if (Players[i].Active) and (Players[i].Team=const_HidersTeam) and (Players[i].HWID<>GV_SeekerHWID) then begin
  48.         Inc(total, 1);
  49.         Hiders[total] := i;
  50.     end;
  51.    
  52.     if total<>0 then begin
  53.         GV_UnlockSeekerTeam := true;
  54.         Players[Hiders[Random(1, total+1)]].Team := const_SeekerTeam;
  55.         GV_UnlockSeekerTeam := false;
  56.     end else
  57.     begin
  58.         Players.WriteConsole(HnSlogo+'Server was unable to choose Seeker. Multiple HWIDs, Bots or no Players on Server.', Color2);
  59.         WriteLn(HnSlogo+'Server was unable to choose Seeker. Multiple HWIDs, Bots or no Players on Server.');
  60.     end;
  61. end;
  62.  
  63. procedure GiveWeapon(PlayerID, PrimaryWType, SecondaryWType: Byte);
  64. var
  65.     NewPrimary, NewSecondary: TNewWeapon;
  66. begin
  67.     NewPrimary := TNewWeapon.Create;
  68.     NewSecondary := TNewWeapon.Create;
  69.     try
  70.         NewPrimary.WType := PrimaryWType;
  71.         NewSecondary.WType := SecondaryWType;
  72.         Players[PlayerID].ForceWeapon(NewPrimary, NewSecondary);
  73.         finally
  74.         NewPrimary.Free;
  75.         NewSecondary.Free;
  76.     end;
  77. end;
  78.  
  79. procedure OnJoin(Player: TActivePlayer; Team: TTeam);
  80. begin
  81.     Player.WriteConsole(HnSlogo+'Welcome to Savage''s Hide ''n Seek. !help - How to play, informations and commands.', Color1);
  82.    
  83.     if Player.HWID=GV_SeekerHWID then
  84.     GV_SeekerID := Player.ID;
  85. end;
  86.  
  87. procedure OnLeave(Player: TActivePlayer; Kicked: Boolean);
  88. begin
  89.     if GV_GameTimer<>0 then
  90.     if Player.ID=GV_SeekerID then begin
  91.         GV_GameTimer := 0;
  92.         Players.WriteConsole(HnSlogo+'Seeker has left. Choosing new one...', Color2);
  93.         if Game.Teams[const_HidersTeam].Count>2 then
  94.         ChooseSeeker
  95.         else Players.WriteConsole(HnSlogo+'Need 1 more player.', Color2);
  96.     end else
  97.     if Player.Team=const_HidersTeam then
  98.     if Game.Teams[const_HidersTeam].Count=1 then begin
  99.         GV_GameTimer := 0;
  100.         Players.WriteConsole(HnSlogo+'Need 1 more hider.', Color2);
  101.     end;
  102.    
  103.     if Player.ID=GV_SeekerID then
  104.     GV_SeekerID := 0;
  105.    
  106.     GV_EnableAFK[Player.ID] := False;
  107. end;
  108.  
  109. function OnBeforeJoinTeam(Player: TActivePlayer; Team, OldTeam: TTeam): ShortInt;
  110. begin
  111.     if (Team.ID<>5) and (Team.ID<>const_HidersTeam) and (Team.ID<>const_SeekerTeam) then begin
  112.         Player.WriteConsole(HnSlogo+'Team "'+IntToStr(Team.ID)+'" is locked.', Color2);
  113.         Result := -1;
  114.     end else
  115.     Result := Team.ID;
  116. end;
  117.  
  118. procedure OnJoinTeam(Player: TActivePlayer; Team: TTeam);
  119. begin
  120. if GV_DoNotCheckTeamEvent then
  121. Exit;
  122.    
  123.     if GV_GameTimer=0 then begin
  124. {Seeker Team}
  125.         if Team.ID=const_SeekerTeam then
  126.         if GV_UnlockSeekerTeam then begin
  127.             GV_SeekerHWID := Player.HWID;
  128.             GV_SeekerID := Player.ID;
  129.             Player.WriteConsole(HnSlogo+'You''ve been chosen as a Seeker. You have '+IntToStr(const_Timer2)+'s to select the map (!maphelp) or it will be decided by Server.', Color1);
  130.             Player.WriteConsole(HnSlogo+'Note that You won''t be chosen next time.', Color2);
  131.             GV_Timer2 := const_Timer2;
  132.         end else
  133.         if (Player.HWID<>GV_SeekerHWID) or ((GV_Timer2=0) and (GV_Timer3=0)) then
  134.         Player.Team := const_HidersTeam;
  135. //Seeker Team
  136.  
  137. {Hiders Team}
  138.         if Team.ID=const_HidersTeam then
  139.         if Game.Teams[const_SeekerTeam].Count=0 then begin
  140.             if (GV_Timer1=0) and (GV_Timer2=0) and (GV_Timer3=0) then
  141.             if Team.Count>2 then
  142.             GV_Timer1 := const_Timer1
  143.             else Players.WriteConsole(HnSlogo+'Need '+IntToStr(3-Team.Count)+' more '+iif(3-Team.Count=1, 'player.', 'players.'), Color1);
  144.         end else
  145.         if (GV_Timer2=0) and (GV_Timer3=0) then
  146.         if Team.Count>1 then
  147.         GV_Timer2 := const_Timer2
  148.         else Players.WriteConsole(HnSlogo+'Need 1 more hider.', Color1);
  149. //Hiders Team
  150.     end else
  151.     if Team.ID<>5 then begin
  152.         Player.WriteConsole(HnSlogo+'Wait until current game will end.', Color2);
  153.         Player.Team := 5;
  154.     end else
  155.     if Player.ID=GV_SeekerID then begin
  156.         GV_GameTimer := 0;
  157.         Players.WriteConsole(HnSlogo+'Seeker has left. Choosing new one...', Color2);
  158.         if Game.Teams[const_HidersTeam].Count>2 then
  159.         ChooseSeeker
  160.         else Players.WriteConsole(HnSlogo+'Need 1 more player.', Color2);
  161.     end else
  162.     if Game.Teams[const_HidersTeam].Count=1 then begin
  163.         GV_GameTimer := 0;
  164.         Players.WriteConsole(HnSlogo+'Need 1 more hider.', Color2);
  165.     end;
  166. end;
  167.  
  168. procedure Clock(Ticks: Integer);
  169. var
  170.     i: Byte;
  171. begin
  172. {Informations}
  173.     if Ticks mod(3600*3) = 0 then
  174.     Players.WriteConsole(HnSlogo+'!help - How to play, informations and commands.', Color1);
  175. //Informations
  176.    
  177.     for i := 1 to 32 do
  178.     if GV_EnableAFK[i] then
  179.     Players[i].BigText(4, 'AFK: ON', 180, Color4, 0.05, 5, 380);
  180.    
  181.     if GV_GameTimer>0 then begin
  182.         Dec(GV_GameTimer, 1);
  183.         Players.BigText(3, 'Time|Hiders Left: '+IntToStr(GV_GameTimer)+'s|'+IntToStr(Game.Teams[const_HidersTeam].Count), 180, Color3, 0.1, 300, 0);
  184.         if Players[GV_SeekerID].Primary.WType <> 7 then
  185.         GiveWeapon(GV_SeekerID, 7, 7);
  186.         if GV_GameTimer=0 then begin
  187.             GV_DoNotCheckTeamEvent := True;
  188.             Players[GV_SeekerID].Team := const_HidersTeam;
  189.             GV_DoNotCheckTeamEvent := False;
  190.             Players.WriteConsole(HnSlogo+'Seeker couldn''t make it on time. Choosing new one from survivors...', Color2);
  191.             ChooseSeeker;
  192.         end;
  193.     end;
  194.    
  195.     if GV_Timer3>0 then begin
  196.         Dec(GV_Timer3, 1);
  197.         Players.BigText(3, 'Hide ''n Seek: '+IntToStr(GV_Timer3)+'s', 180, Color3, 0.1, 300, 80);
  198.         if GV_SeekerID<>0 then
  199.         if Players[GV_SeekerID].Active then
  200.         Players[GV_SeekerID].BigText(2, chr(149), 180, $000000, 25, -1250, -2500);
  201.         if GV_Timer3=0 then begin
  202.             GV_DoNotCheckTeamEvent := True;
  203.             for i := 1 to 32 do
  204.             if (Players[i].Team = 5) and (not GV_EnableAFK[i]) then
  205.             Players[i].Team := const_HidersTeam;
  206.             GV_DoNotCheckTeamEvent := False;
  207.             if Game.Teams[const_SeekerTeam].Count=0 then begin
  208.                 Players.WriteConsole(HnSlogo+'Seeker has left. Choosing new one...', Color2);
  209.                 if Game.Teams[const_HidersTeam].Count>2 then
  210.                 ChooseSeeker
  211.                 else Players.WriteConsole(HnSlogo+'Need '+IntToStr(3-Game.Teams[const_HidersTeam].Count)+' more '+iif(3-Game.Teams[const_HidersTeam].Count=1, 'player.', 'players.'), Color2);
  212.             end else
  213.             if Game.Teams[const_HidersTeam].Count>1 then begin
  214.                 GV_GameTimer := const_GameTimer;
  215.                 Players[GV_SeekerID].Say('Ready or not, here I come!');
  216.                 GiveWeapon(GV_SeekerID, 7, 7);
  217.             end else
  218.             Players.WriteConsole(HnSlogo+'Need '+IntToStr(2-Game.Teams[const_HidersTeam].Count)+' more '+iif(2-Game.Teams[const_HidersTeam].Count=1, 'hider.', 'hiders.'), Color2);
  219.         end;
  220.     end;
  221.    
  222.     if GV_Timer2>0 then begin
  223.         Dec(GV_Timer2, 1);
  224.         Players.BigText(3, 'Choosing Map: '+IntToStr(GV_Timer2)+'s', 180, Color3, 0.1, 300, 80);
  225.         if GV_Timer2=0 then
  226.         if Game.Teams[const_SeekerTeam].Count=0 then begin
  227.             Players.WriteConsole(HnSlogo+'Seeker has left. Choosing new one...', Color2);
  228.             if Game.Teams[const_HidersTeam].Count>2 then
  229.             ChooseSeeker
  230.             else Players.WriteConsole(HnSlogo+'Need '+IntToStr(3-Game.Teams[const_HidersTeam].Count)+' more '+iif(3-Game.Teams[const_HidersTeam].Count=1, 'player.', 'players.'), Color2);
  231.         end else
  232.         if Game.Teams[const_HidersTeam].Count>1 then begin
  233.             Players.WriteConsole(HnSlogo+'Choosing random map...', Color1);
  234.             Map.SetMap(Game.MapsList[Random(0, Game.MapsList.MapsCount)]);
  235.             GV_Timer3 := const_Timer3+10;
  236.         end else
  237.         Players.WriteConsole(HnSlogo+'Need '+IntToStr(2-Game.Teams[const_HidersTeam].Count)+' more '+iif(2-Game.Teams[const_HidersTeam].Count=1, 'hider.', 'hiders.'), Color2);
  238.     end;
  239.    
  240.     if GV_Timer1>0 then begin
  241.         Dec(GV_Timer1, 1);
  242.         Players.BigText(3, 'Choosing Seeker: '+IntToStr(GV_Timer1)+'s', 180, Color3, 0.1, 300, 80);
  243.         if GV_Timer1=0 then
  244.         if Game.Teams[const_HidersTeam].Count>2 then
  245.         ChooseSeeker
  246.         else Players.WriteConsole(HnSlogo+'Need '+IntToStr(3-Game.Teams[const_HidersTeam].Count)+' more '+iif(3-Game.Teams[const_HidersTeam].Count=1, 'player.', 'players.'), Color2);
  247.     end;
  248. end;
  249.  
  250. function OnDamage(Shooter, Victim: TActivePlayer; Damage: Single; BulletId: Byte): Single;
  251. begin
  252.     if (Shooter.Team=const_SeekerTeam) and (GV_GameTimer<>0) and (Shooter.ID<>Victim.ID) then
  253.     Result := Damage;
  254. end;
  255.  
  256. procedure OnKill(Killer, Victim: TActivePlayer; BulletId: Byte);
  257. var
  258.     i: ShortInt;
  259.     AliveHidersCount, LastAliveHiderID: Byte;
  260. begin
  261.     for i := 0 to Game.Teams[const_HidersTeam].Count - 1 do
  262.     if (Game.Teams[const_HidersTeam].Player[i].Alive) and (Game.Teams[const_HidersTeam].Player[i].ID<>Victim.ID) then begin
  263.         Inc(AliveHidersCount, 1);
  264.         LastAliveHiderID := Game.Teams[const_HidersTeam].Player[i].ID;
  265.     end;
  266.    
  267.     if AliveHidersCount = 1 then begin
  268.         GV_GameTimer := 0;
  269.         GV_UnlockSeekerTeam := true;
  270.         Players[LastAliveHiderID].Team := const_SeekerTeam;
  271.         GV_UnlockSeekerTeam := false;
  272.         Killer.Team := const_HidersTeam;
  273.     end;
  274. end;
  275.  
  276. procedure OnAfterRespawn(Player: TActivePlayer);
  277. begin
  278.     if (GV_GameTimer<>0) and (Player.ID<>GV_SeekerID) and (CountPlayersInTeam(Player.Team)=Game.Teams[Player.Team].Count) then
  279.     Player.Team := 5;
  280. end;
  281.  
  282. procedure OnWeaponChange(Player: TActivePlayer; Primary, Secondary: TPlayerWeapon);
  283. begin
  284.     if Player.ID<>GV_SeekerID then
  285.     GiveWeapon(Player.ID, 255, 255)
  286.     else
  287.     GiveWeapon(GV_SeekerID, 7, 7);
  288. end;
  289.  
  290. function DisableVoteMap(Player: TActivePlayer; Map: string): Boolean;
  291. begin
  292.     Result := True;
  293. end;
  294.  
  295. procedure OnPlayerSpeak(Player: TActivePlayer; Text: String);
  296. var
  297.     MapID: Integer;
  298. begin
  299.     if Text[1] = '!' then begin
  300.         Delete(Text, 1, 1);
  301.         Text := LowerCase(Text);
  302.        
  303.         if Copy(Text, 1, 4) = 'map ' then
  304.         if Player.Team = const_SeekerTeam then begin
  305.             if GV_Timer2<>0 then begin
  306.                 MapID := Game.MapsList.GetMapIdByName(Copy(Text, 5, Length(Text)));
  307.                 if MapID=-1 then
  308.                 Players.WriteConsole(HnSlogo+'Map "'+Copy(Text, 5, Length(Text))+'" isn''t available.', Color2)
  309.                 else
  310.                 if File.Exists('maps/'+Game.MapsList[MapID]+'.pms') then begin
  311.                     GV_Timer2 := 0;
  312.                     Map.SetMap(Game.MapsList[MapID]);
  313.                     GV_Timer3 := const_Timer3+10;
  314.                 end else
  315.                 Players.WriteConsole(HnSlogo+'Error: Map "'+Copy(Text, 5, Length(Text))+'" file not found.', Color2);
  316.             end else
  317.             Player.WriteConsole(HnSlogo+'You can''t choose now the map.', Color2);
  318.         end else
  319.         Player.WriteConsole(HnSlogo+'This command is available only for Seeker.', Color2);
  320.        
  321.         case Text of
  322.             'help','cmds','commands'    :   begin
  323.                                                 Player.WriteConsole(HnSlogo+'Savage''s Hide ''n Seek help:', Color4);
  324.                                                 Player.WriteConsole('E-mail: igor090795@gmail.com', Color5);
  325.                                                 Player.WriteConsole('Admins: Savage, Ghostie, Mellouki.', Color5);
  326.                                                 Player.WriteConsole('The minimum number of players required to play is 3.', Color5);
  327.                                                 Player.WriteConsole('Server will choose the Seeker randomly.', Color5);
  328.                                                 Player.WriteConsole('Seeker has to seek and kill hiders.', Color5);
  329.                                                 Player.WriteConsole('Last alive player will become a Seeker.', Color5);
  330.                                                 Player.WriteConsole('!maphelp - Commands for Seeker to select the map.', Color1);
  331.                                                 Player.WriteConsole('!mlr - MapListReader commands.', Color1);
  332.                                                 Player.WriteConsole('!whois - Show connected Admins.', Color1);
  333.                                                 Player.WriteConsole('!admin - Call an Admin.', Color1);
  334.                                                 Player.WriteConsole('!<admin nick> - Call specified Admin.', Color1);
  335.                                                 Player.WriteConsole('!afkon - Turn OFF auto-join.', Color1);
  336.                                                 Player.WriteConsole('!afkoff - Turn ON auto-join.', Color1);
  337.                                             end;
  338.                                            
  339.             'map'                       :   Player.WriteConsole(HnSlogo+'Current map name is "'+Game.CurrentMap+'".', Color1);
  340.            
  341.             'seek','seeker'             :   Player.Team := const_SeekerTeam;
  342.             'j','join','hide','hider'   :   Player.Team := const_HidersTeam;
  343.             's','5','spec'              :   Player.Team := 5;
  344.            
  345.             'maphelp'                   :   begin
  346.                                                 Player.WriteConsole(HnSlogo+'Commands for Seeker to select the map:', Color4);
  347.                                                 Player.WriteConsole('!random - Chooses random map from maps list.', Color1);
  348.                                                 Player.WriteConsole('!map <map name> - Choose map manually from maps list.', Color1);
  349.                                                 Player.WriteConsole('!stay - Play current map.', Color1);
  350.                                             end;
  351.                            
  352.             'mlr'                       :   begin
  353.                                                 Player.WriteConsole(HnSlogo+'MapListReader commands:', Color4);
  354.                                                 Player.WriteConsole('/maplist - Show MapList.', Color1);
  355.                                                 Player.WriteConsole('/smaplist - Show sorted MapList.', Color1);
  356.                                                 Player.WriteConsole('/searchmap <pattern> - Show all maps containing searched pattern.', Color1);
  357.                                                 Player.WriteConsole('/showmapid - Show map index from MapList in SearchResult, do it before searching.', Color1);
  358.                                                 Player.WriteConsole('/page <number> - Change page to <number>, type "/page 0" to close.', Color1);
  359.                                                 Player.WriteConsole('You can also hold "Crouch"(forward) or "Jump"(back) key to change page.', Color1);
  360.                                                 Player.WriteConsole('Admin commands:', Color5);
  361.                                                 Player.WriteConsole('/createsortedmaplist - Create sorted MapList if current one is outdated.', Color1);
  362.                                                 Player.WriteConsole('/addmap <map name> - Add map to MapList. (Default Soldat command)', Color1);
  363.                                                 Player.WriteConsole('/delmap <map name> - Remove map from MapList. (Default Soldat command)', Color1);
  364.                                             end;
  365.                            
  366.             'random'                    :   if Player.Team = const_SeekerTeam then begin
  367.                                                 if GV_Timer2<>0 then begin
  368.                                                     GV_Timer2 := 0;
  369.                                                     Map.SetMap(Game.MapsList[Random(0, Game.MapsList.MapsCount)]);//Sprawdz czy ta mapa istnieje
  370.                                                     GV_Timer3 := const_Timer3+10;
  371.                                                 end else
  372.                                                 Player.WriteConsole(HnSlogo+'You can''t choose now the map.', Color2);
  373.                                             end else
  374.                                             Player.WriteConsole(HnSlogo+'This command is available only for Seeker.', Color2);
  375.                            
  376.             'stay'                      :   if Player.Team = const_SeekerTeam then begin
  377.                                                 if GV_Timer2<>0 then begin
  378.                                                     if Game.MapsList.GetMapIdByName(Game.CurrentMap)<>-1 then begin
  379.                                                         GV_Timer2 := 0;
  380.                                                         GV_Timer3 := const_Timer3;
  381.                                                     end else
  382.                                                     Player.WriteConsole(HnSlogo+'Current map isn''t available.', Color2);
  383.                                                 end else
  384.                                                 Player.WriteConsole(HnSlogo+'You can''t choose now the map.', Color2);
  385.                                             end else
  386.                                             Player.WriteConsole(HnSlogo+'This command is available only for Seeker.', Color2);
  387.                        
  388.             'afkon'                     :   begin
  389.                                                 GV_EnableAFK[Player.ID] := True;
  390.                                                 Player.WriteConsole(HnSlogo+'AFK: ON', Color4);
  391.                                             end;
  392.                                            
  393.             'afkoff'                    :   begin
  394.                                                 GV_EnableAFK[Player.ID] := False;
  395.                                                 Player.WriteConsole(HnSlogo+'AFK: OFF', Color4);
  396.                                             end;
  397.         end;
  398.     end;
  399. end;
  400.  
  401. procedure Init;
  402. var
  403.     i: Byte;
  404. begin
  405.     for i := 1 to 32 do begin
  406.         if Players[i].Active then begin
  407.             Players[i].WriteConsole(HnSlogo+'Script has been recompiled.', Color1);
  408.             if Players[i].Team<>5 then
  409.             Players[i].Team := 5;
  410.         end;
  411.         Players[i].OnSpeak := @OnPlayerSpeak;
  412.         Players[i].OnDamage := @OnDamage;
  413.         Players[i].OnKill := @OnKill;
  414.         Players[i].OnAfterRespawn := @OnAfterRespawn;
  415.         Players[i].OnWeaponChange := @OnWeaponChange;
  416.         Players[i].OnVoteMapStart := @DisableVoteMap;
  417.     end;
  418.    
  419.     for i := 0 to 5 do begin
  420.         Game.Teams[i].OnBeforeJoin := @OnBeforeJoinTeam;
  421.         Game.Teams[i].OnJoin := @OnJoinTeam;
  422.     end;
  423.    
  424.     Game.OnJoin := @OnJoin;
  425.     Game.OnLeave := @OnLeave;
  426.     Game.OnClockTick := @Clock;
  427. end;
  428.  
  429. begin
  430.     Init;
  431. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement