Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Savage's Hide 'n Seek 0.7
- //Core Version: 2.8.1
- {Description: The minimum number of players required to play is 3.
- Server will choose the Seeker randomly.
- Seeker has to seek and kill hiders.
- Last alive player will become a Seeker.}
- const
- HnSlogo = '{HnS} ';
- Color1 = $F0E68C; //Used for basic messages//Khaki
- Color2 = $FF0000; //Used for warning messages//Red
- Color3 = $6495ed; //Used for BigText//Cornflower Blue
- Color4 = $458b74; //Used for additional messages//Aquamarine
- Color5 = $ffd700; //Used for additional messages//Gold
- const_SeekerTeam = 1;
- const_HidersTeam = 2;
- const_Timer1 = 10; //Time for collecting players/choosing seeker//Seconds
- const_Timer2 = 20; //Time for seeker to choose map//Seconds
- const_Timer3 = 10; //Time for hiders to hide(Added 10s for map change)//Seconds
- const_GameTimer = 450; //Game duration//Seconds
- var
- GV_SeekerID: Byte;
- GV_SeekerHWID: String;
- GV_Timer1, GV_Timer2, GV_Timer3, GV_GameTimer: Word;
- GV_UnlockSeekerTeam, GV_DoNotCheckTeamEvent: Boolean;
- GV_EnableAFK: array[1..32] of Boolean;
- function CountPlayersInTeam(TeamID: Byte): Byte;{Used to fix triple spec bug}
- var
- i: Byte;
- begin
- for i := 1 to 32 do
- if (Players[i].Active) and (Players[i].Team=TeamID) then
- Inc(Result, 1);
- end;
- procedure ChooseSeeker;
- var
- i, total: Byte;
- Hiders: array[1..32] of Byte;
- begin
- for i := 1 to 32 do
- if (Players[i].Active) and (Players[i].Team=const_HidersTeam) and (Players[i].HWID<>GV_SeekerHWID) then begin
- Inc(total, 1);
- Hiders[total] := i;
- end;
- if total<>0 then begin
- GV_UnlockSeekerTeam := true;
- Players[Hiders[Random(1, total+1)]].Team := const_SeekerTeam;
- GV_UnlockSeekerTeam := false;
- end else
- begin
- Players.WriteConsole(HnSlogo+'Server was unable to choose Seeker. Multiple HWIDs, Bots or no Players on Server.', Color2);
- WriteLn(HnSlogo+'Server was unable to choose Seeker. Multiple HWIDs, Bots or no Players on Server.');
- end;
- end;
- procedure GiveWeapon(PlayerID, PrimaryWType, SecondaryWType: Byte);
- var
- NewPrimary, NewSecondary: TNewWeapon;
- begin
- NewPrimary := TNewWeapon.Create;
- NewSecondary := TNewWeapon.Create;
- try
- NewPrimary.WType := PrimaryWType;
- NewSecondary.WType := SecondaryWType;
- Players[PlayerID].ForceWeapon(NewPrimary, NewSecondary);
- finally
- NewPrimary.Free;
- NewSecondary.Free;
- end;
- end;
- procedure OnJoin(Player: TActivePlayer; Team: TTeam);
- begin
- Player.WriteConsole(HnSlogo+'Welcome to Savage''s Hide ''n Seek. !help - How to play, informations and commands.', Color1);
- if Player.HWID=GV_SeekerHWID then
- GV_SeekerID := Player.ID;
- end;
- procedure OnLeave(Player: TActivePlayer; Kicked: Boolean);
- begin
- if GV_GameTimer<>0 then
- if Player.ID=GV_SeekerID then begin
- GV_GameTimer := 0;
- Players.WriteConsole(HnSlogo+'Seeker has left. Choosing new one...', Color2);
- if Game.Teams[const_HidersTeam].Count>2 then
- ChooseSeeker
- else Players.WriteConsole(HnSlogo+'Need 1 more player.', Color2);
- end else
- if Player.Team=const_HidersTeam then
- if Game.Teams[const_HidersTeam].Count=1 then begin
- GV_GameTimer := 0;
- Players.WriteConsole(HnSlogo+'Need 1 more hider.', Color2);
- end;
- if Player.ID=GV_SeekerID then
- GV_SeekerID := 0;
- GV_EnableAFK[Player.ID] := False;
- end;
- function OnBeforeJoinTeam(Player: TActivePlayer; Team, OldTeam: TTeam): ShortInt;
- begin
- if (Team.ID<>5) and (Team.ID<>const_HidersTeam) and (Team.ID<>const_SeekerTeam) then begin
- Player.WriteConsole(HnSlogo+'Team "'+IntToStr(Team.ID)+'" is locked.', Color2);
- Result := -1;
- end else
- Result := Team.ID;
- end;
- procedure OnJoinTeam(Player: TActivePlayer; Team: TTeam);
- begin
- if GV_DoNotCheckTeamEvent then
- Exit;
- if GV_GameTimer=0 then begin
- {Seeker Team}
- if Team.ID=const_SeekerTeam then
- if GV_UnlockSeekerTeam then begin
- GV_SeekerHWID := Player.HWID;
- GV_SeekerID := Player.ID;
- 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);
- Player.WriteConsole(HnSlogo+'Note that You won''t be chosen next time.', Color2);
- GV_Timer2 := const_Timer2;
- end else
- if (Player.HWID<>GV_SeekerHWID) or ((GV_Timer2=0) and (GV_Timer3=0)) then
- Player.Team := const_HidersTeam;
- //Seeker Team
- {Hiders Team}
- if Team.ID=const_HidersTeam then
- if Game.Teams[const_SeekerTeam].Count=0 then begin
- if (GV_Timer1=0) and (GV_Timer2=0) and (GV_Timer3=0) then
- if Team.Count>2 then
- GV_Timer1 := const_Timer1
- else Players.WriteConsole(HnSlogo+'Need '+IntToStr(3-Team.Count)+' more '+iif(3-Team.Count=1, 'player.', 'players.'), Color1);
- end else
- if (GV_Timer2=0) and (GV_Timer3=0) then
- if Team.Count>1 then
- GV_Timer2 := const_Timer2
- else Players.WriteConsole(HnSlogo+'Need 1 more hider.', Color1);
- //Hiders Team
- end else
- if Team.ID<>5 then begin
- Player.WriteConsole(HnSlogo+'Wait until current game will end.', Color2);
- Player.Team := 5;
- end else
- if Player.ID=GV_SeekerID then begin
- GV_GameTimer := 0;
- Players.WriteConsole(HnSlogo+'Seeker has left. Choosing new one...', Color2);
- if Game.Teams[const_HidersTeam].Count>2 then
- ChooseSeeker
- else Players.WriteConsole(HnSlogo+'Need 1 more player.', Color2);
- end else
- if Game.Teams[const_HidersTeam].Count=1 then begin
- GV_GameTimer := 0;
- Players.WriteConsole(HnSlogo+'Need 1 more hider.', Color2);
- end;
- end;
- procedure Clock(Ticks: Integer);
- var
- i: Byte;
- begin
- {Informations}
- if Ticks mod(3600*3) = 0 then
- Players.WriteConsole(HnSlogo+'!help - How to play, informations and commands.', Color1);
- //Informations
- for i := 1 to 32 do
- if GV_EnableAFK[i] then
- Players[i].BigText(4, 'AFK: ON', 180, Color4, 0.05, 5, 380);
- if GV_GameTimer>0 then begin
- Dec(GV_GameTimer, 1);
- Players.BigText(3, 'Time|Hiders Left: '+IntToStr(GV_GameTimer)+'s|'+IntToStr(Game.Teams[const_HidersTeam].Count), 180, Color3, 0.1, 300, 0);
- if Players[GV_SeekerID].Primary.WType <> 7 then
- GiveWeapon(GV_SeekerID, 7, 7);
- if GV_GameTimer=0 then begin
- GV_DoNotCheckTeamEvent := True;
- Players[GV_SeekerID].Team := const_HidersTeam;
- GV_DoNotCheckTeamEvent := False;
- Players.WriteConsole(HnSlogo+'Seeker couldn''t make it on time. Choosing new one from survivors...', Color2);
- ChooseSeeker;
- end;
- end;
- if GV_Timer3>0 then begin
- Dec(GV_Timer3, 1);
- Players.BigText(3, 'Hide ''n Seek: '+IntToStr(GV_Timer3)+'s', 180, Color3, 0.1, 300, 80);
- if GV_SeekerID<>0 then
- if Players[GV_SeekerID].Active then
- Players[GV_SeekerID].BigText(2, chr(149), 180, $000000, 25, -1250, -2500);
- if GV_Timer3=0 then begin
- GV_DoNotCheckTeamEvent := True;
- for i := 1 to 32 do
- if (Players[i].Team = 5) and (not GV_EnableAFK[i]) then
- Players[i].Team := const_HidersTeam;
- GV_DoNotCheckTeamEvent := False;
- if Game.Teams[const_SeekerTeam].Count=0 then begin
- Players.WriteConsole(HnSlogo+'Seeker has left. Choosing new one...', Color2);
- if Game.Teams[const_HidersTeam].Count>2 then
- ChooseSeeker
- else Players.WriteConsole(HnSlogo+'Need '+IntToStr(3-Game.Teams[const_HidersTeam].Count)+' more '+iif(3-Game.Teams[const_HidersTeam].Count=1, 'player.', 'players.'), Color2);
- end else
- if Game.Teams[const_HidersTeam].Count>1 then begin
- GV_GameTimer := const_GameTimer;
- Players[GV_SeekerID].Say('Ready or not, here I come!');
- GiveWeapon(GV_SeekerID, 7, 7);
- end else
- Players.WriteConsole(HnSlogo+'Need '+IntToStr(2-Game.Teams[const_HidersTeam].Count)+' more '+iif(2-Game.Teams[const_HidersTeam].Count=1, 'hider.', 'hiders.'), Color2);
- end;
- end;
- if GV_Timer2>0 then begin
- Dec(GV_Timer2, 1);
- Players.BigText(3, 'Choosing Map: '+IntToStr(GV_Timer2)+'s', 180, Color3, 0.1, 300, 80);
- if GV_Timer2=0 then
- if Game.Teams[const_SeekerTeam].Count=0 then begin
- Players.WriteConsole(HnSlogo+'Seeker has left. Choosing new one...', Color2);
- if Game.Teams[const_HidersTeam].Count>2 then
- ChooseSeeker
- else Players.WriteConsole(HnSlogo+'Need '+IntToStr(3-Game.Teams[const_HidersTeam].Count)+' more '+iif(3-Game.Teams[const_HidersTeam].Count=1, 'player.', 'players.'), Color2);
- end else
- if Game.Teams[const_HidersTeam].Count>1 then begin
- Players.WriteConsole(HnSlogo+'Choosing random map...', Color1);
- Map.SetMap(Game.MapsList[Random(0, Game.MapsList.MapsCount)]);
- GV_Timer3 := const_Timer3+10;
- end else
- Players.WriteConsole(HnSlogo+'Need '+IntToStr(2-Game.Teams[const_HidersTeam].Count)+' more '+iif(2-Game.Teams[const_HidersTeam].Count=1, 'hider.', 'hiders.'), Color2);
- end;
- if GV_Timer1>0 then begin
- Dec(GV_Timer1, 1);
- Players.BigText(3, 'Choosing Seeker: '+IntToStr(GV_Timer1)+'s', 180, Color3, 0.1, 300, 80);
- if GV_Timer1=0 then
- if Game.Teams[const_HidersTeam].Count>2 then
- ChooseSeeker
- else Players.WriteConsole(HnSlogo+'Need '+IntToStr(3-Game.Teams[const_HidersTeam].Count)+' more '+iif(3-Game.Teams[const_HidersTeam].Count=1, 'player.', 'players.'), Color2);
- end;
- end;
- function OnDamage(Shooter, Victim: TActivePlayer; Damage: Single; BulletId: Byte): Single;
- begin
- if (Shooter.Team=const_SeekerTeam) and (GV_GameTimer<>0) and (Shooter.ID<>Victim.ID) then
- Result := Damage;
- end;
- procedure OnKill(Killer, Victim: TActivePlayer; BulletId: Byte);
- var
- i: ShortInt;
- AliveHidersCount, LastAliveHiderID: Byte;
- begin
- for i := 0 to Game.Teams[const_HidersTeam].Count - 1 do
- if (Game.Teams[const_HidersTeam].Player[i].Alive) and (Game.Teams[const_HidersTeam].Player[i].ID<>Victim.ID) then begin
- Inc(AliveHidersCount, 1);
- LastAliveHiderID := Game.Teams[const_HidersTeam].Player[i].ID;
- end;
- if AliveHidersCount = 1 then begin
- GV_GameTimer := 0;
- GV_UnlockSeekerTeam := true;
- Players[LastAliveHiderID].Team := const_SeekerTeam;
- GV_UnlockSeekerTeam := false;
- Killer.Team := const_HidersTeam;
- end;
- end;
- procedure OnAfterRespawn(Player: TActivePlayer);
- begin
- if (GV_GameTimer<>0) and (Player.ID<>GV_SeekerID) and (CountPlayersInTeam(Player.Team)=Game.Teams[Player.Team].Count) then
- Player.Team := 5;
- end;
- procedure OnWeaponChange(Player: TActivePlayer; Primary, Secondary: TPlayerWeapon);
- begin
- if Player.ID<>GV_SeekerID then
- GiveWeapon(Player.ID, 255, 255)
- else
- GiveWeapon(GV_SeekerID, 7, 7);
- end;
- function DisableVoteMap(Player: TActivePlayer; Map: string): Boolean;
- begin
- Result := True;
- end;
- procedure OnPlayerSpeak(Player: TActivePlayer; Text: String);
- var
- MapID: Integer;
- begin
- if Text[1] = '!' then begin
- Delete(Text, 1, 1);
- Text := LowerCase(Text);
- if Copy(Text, 1, 4) = 'map ' then
- if Player.Team = const_SeekerTeam then begin
- if GV_Timer2<>0 then begin
- MapID := Game.MapsList.GetMapIdByName(Copy(Text, 5, Length(Text)));
- if MapID=-1 then
- Players.WriteConsole(HnSlogo+'Map "'+Copy(Text, 5, Length(Text))+'" isn''t available.', Color2)
- else
- if File.Exists('maps/'+Game.MapsList[MapID]+'.pms') then begin
- GV_Timer2 := 0;
- Map.SetMap(Game.MapsList[MapID]);
- GV_Timer3 := const_Timer3+10;
- end else
- Players.WriteConsole(HnSlogo+'Error: Map "'+Copy(Text, 5, Length(Text))+'" file not found.', Color2);
- end else
- Player.WriteConsole(HnSlogo+'You can''t choose now the map.', Color2);
- end else
- Player.WriteConsole(HnSlogo+'This command is available only for Seeker.', Color2);
- case Text of
- 'help','cmds','commands' : begin
- Player.WriteConsole(HnSlogo+'Savage''s Hide ''n Seek help:', Color4);
- Player.WriteConsole('E-mail: igor090795@gmail.com', Color5);
- Player.WriteConsole('Admins: Savage, Ghostie, Mellouki.', Color5);
- Player.WriteConsole('The minimum number of players required to play is 3.', Color5);
- Player.WriteConsole('Server will choose the Seeker randomly.', Color5);
- Player.WriteConsole('Seeker has to seek and kill hiders.', Color5);
- Player.WriteConsole('Last alive player will become a Seeker.', Color5);
- Player.WriteConsole('!maphelp - Commands for Seeker to select the map.', Color1);
- Player.WriteConsole('!mlr - MapListReader commands.', Color1);
- Player.WriteConsole('!whois - Show connected Admins.', Color1);
- Player.WriteConsole('!admin - Call an Admin.', Color1);
- Player.WriteConsole('!<admin nick> - Call specified Admin.', Color1);
- Player.WriteConsole('!afkon - Turn OFF auto-join.', Color1);
- Player.WriteConsole('!afkoff - Turn ON auto-join.', Color1);
- end;
- 'map' : Player.WriteConsole(HnSlogo+'Current map name is "'+Game.CurrentMap+'".', Color1);
- 'seek','seeker' : Player.Team := const_SeekerTeam;
- 'j','join','hide','hider' : Player.Team := const_HidersTeam;
- 's','5','spec' : Player.Team := 5;
- 'maphelp' : begin
- Player.WriteConsole(HnSlogo+'Commands for Seeker to select the map:', Color4);
- Player.WriteConsole('!random - Chooses random map from maps list.', Color1);
- Player.WriteConsole('!map <map name> - Choose map manually from maps list.', Color1);
- Player.WriteConsole('!stay - Play current map.', Color1);
- end;
- 'mlr' : begin
- Player.WriteConsole(HnSlogo+'MapListReader commands:', Color4);
- Player.WriteConsole('/maplist - Show MapList.', Color1);
- Player.WriteConsole('/smaplist - Show sorted MapList.', Color1);
- Player.WriteConsole('/searchmap <pattern> - Show all maps containing searched pattern.', Color1);
- Player.WriteConsole('/showmapid - Show map index from MapList in SearchResult, do it before searching.', Color1);
- Player.WriteConsole('/page <number> - Change page to <number>, type "/page 0" to close.', Color1);
- Player.WriteConsole('You can also hold "Crouch"(forward) or "Jump"(back) key to change page.', Color1);
- Player.WriteConsole('Admin commands:', Color5);
- Player.WriteConsole('/createsortedmaplist - Create sorted MapList if current one is outdated.', Color1);
- Player.WriteConsole('/addmap <map name> - Add map to MapList. (Default Soldat command)', Color1);
- Player.WriteConsole('/delmap <map name> - Remove map from MapList. (Default Soldat command)', Color1);
- end;
- 'random' : if Player.Team = const_SeekerTeam then begin
- if GV_Timer2<>0 then begin
- GV_Timer2 := 0;
- Map.SetMap(Game.MapsList[Random(0, Game.MapsList.MapsCount)]);//Sprawdz czy ta mapa istnieje
- GV_Timer3 := const_Timer3+10;
- end else
- Player.WriteConsole(HnSlogo+'You can''t choose now the map.', Color2);
- end else
- Player.WriteConsole(HnSlogo+'This command is available only for Seeker.', Color2);
- 'stay' : if Player.Team = const_SeekerTeam then begin
- if GV_Timer2<>0 then begin
- if Game.MapsList.GetMapIdByName(Game.CurrentMap)<>-1 then begin
- GV_Timer2 := 0;
- GV_Timer3 := const_Timer3;
- end else
- Player.WriteConsole(HnSlogo+'Current map isn''t available.', Color2);
- end else
- Player.WriteConsole(HnSlogo+'You can''t choose now the map.', Color2);
- end else
- Player.WriteConsole(HnSlogo+'This command is available only for Seeker.', Color2);
- 'afkon' : begin
- GV_EnableAFK[Player.ID] := True;
- Player.WriteConsole(HnSlogo+'AFK: ON', Color4);
- end;
- 'afkoff' : begin
- GV_EnableAFK[Player.ID] := False;
- Player.WriteConsole(HnSlogo+'AFK: OFF', Color4);
- end;
- end;
- end;
- end;
- procedure Init;
- var
- i: Byte;
- begin
- for i := 1 to 32 do begin
- if Players[i].Active then begin
- Players[i].WriteConsole(HnSlogo+'Script has been recompiled.', Color1);
- if Players[i].Team<>5 then
- Players[i].Team := 5;
- end;
- Players[i].OnSpeak := @OnPlayerSpeak;
- Players[i].OnDamage := @OnDamage;
- Players[i].OnKill := @OnKill;
- Players[i].OnAfterRespawn := @OnAfterRespawn;
- Players[i].OnWeaponChange := @OnWeaponChange;
- Players[i].OnVoteMapStart := @DisableVoteMap;
- end;
- for i := 0 to 5 do begin
- Game.Teams[i].OnBeforeJoin := @OnBeforeJoinTeam;
- Game.Teams[i].OnJoin := @OnJoinTeam;
- end;
- Game.OnJoin := @OnJoin;
- Game.OnLeave := @OnLeave;
- Game.OnClockTick := @Clock;
- end;
- begin
- Init;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement