Author Topic: Hide and Seek Script, Some Problems  (Read 7840 times)

0 Members and 1 Guest are viewing this topic.

Offline MrHamsTR

  • Soldier
  • **
  • Posts: 209
  • One day, everything will end..
Hide and Seek Script, Some Problems
« on: January 01, 2013, 03:13:34 pm »
HnS.pas

Code: [Select]
//Hide 'n Seek v2.5 Coded by Iq-Unlimited.
// Improved by la la
// -Out Mapper Killer
// -Team Change Killer
// -Suicide Msg
//tPlayer Record that has all the variables in it for neatness


const


  //Game constants
  cGame_nMaxHumanPlayers = 32; //maximum number of human players Soldat supports

  cPlayerID_First = 1; //first index player index number
  cPlayerID_Last = cGame_nMaxHumanPlayers; //last player index number

type
  trPlayer = record
    Alive : Boolean;
    Offmapping : Boolean;
Counts : Integer;
  end;
 
type tPlayer = record
it, Counting, NotPlaying, seeker, First, JustLeft: boolean;
X, Y: single;
count, score: integer;
end;

var
//All the boolean variables, there's a ton in this script isn't there lol.
hns, Mapbugs, last, pubserver, pop, pop2: boolean;
//Maxplayers...
Maxplayer, delay: byte;
//Color...
Color: longint;
ranmap: TStringArray;
//And the tPlayer array. It's the best one :D
Player: array [1..32] of tPlayer;
  aPlayers: array [1..32] of trPlayer;



function arrayHi( tester: TStringArray ): integer;
begin
result := GetArrayLength( tester ) - 1;
end;

function xsplit(const source: string; const delimiter: string):TStringArray;
var
i,x,d:integer;
s:string;
begin
d:=length(delimiter);
x:=0;
i:=1;
SetArrayLength(Result,1);
while(i<=length(source)) do begin
s:=Copy(source,i,d);   
    if(s=delimiter) then begin
    i:=i+d;
    inc(x,1);
    SetArrayLength(result,x+1);
    end else begin       
    result[x]:= result[x]+copy(s,1,1);
    inc(i,1);
  end;
end;
if Result[ArrayHi(Result)]='' then SetArrayLength(result,x);
end;

//ChooseRandomPlayer function chooses 1 random active player and returns that number.
function ChooseRandomPlayer(Max: byte): byte;
var
i, Ran: byte;
begin
for i := 1 to 255 do begin
Ran := Random(1, Max);
if GetPlayerStat(Ran, 'Active') then begin
result := Ran;
exit;
end;
end;
end;

//ClearWeapons does just that, clears your weapons.
procedure ClearWeapons(ID: byte);
begin
ForceWeapon(ID, 255, 255, 0);
end;

//Custom Choose Random Map function.
function RandomMap: string;
begin
result := ranmap[Random(0,ArrayHigh(ranmap))];
end;

//StartGame procedure, isit: byte is the player who will be it.
procedure StartGame(isit: byte);
var
i: byte;
begin
//hns := false is there to stop the OnJoinTeam out of range errors.
hns := false;
//Unset a bunch of variables that people might or might not have.
for i := 1 to MaxPlayer do begin
if getplayerstat(i,'active') then begin
Player[i].it := false;
Player[i].Counting := false;
Player[i].seeker := false;
Player[i].NotPlaying := false;
Player[i].First := false;
end;
end;
//player who is supposed to be it is now it.
Player[isit].it := true;
//Set people to their teams, seeker to alpha, all others to delta.
for i := 1 to MaxPlayer do begin
if getplayerstat(i,'active') then begin
if GetPlayerStat(i, 'Active') then begin
if not Player[i].it then begin
Command('/setteam4 ' + inttostr(i));
end else begin
Command('/setteam1 ' + inttostr(i));
WriteConsole(i, 'Ebesin!',Color);
end;
end;
end;
end;
//Set some variables
last := false;
hns := true;
//if mapbugs then wait 1 second before changing map.
if Mapbugs then sleep(1000);
Command('/map ' + RandomMap);
end;


//Stops the game and removes all variables
procedure StopGame();
var
i: byte;
begin
for i := 1 to MaxPlayer do begin
if getplayerstat(i,'active') then begin
Player[i].it := false;
Player[i].Counting := false;
Player[i].seeker := false;
Player[i].First := false;
Player[i].NotPlaying := false;
Player[i].X := 0;
Player[i].Y := 0;
Player[i].count := 0;
Player[i].score := 0;
hns := false;
last := false;
end;
end;
//:( you stopped teh games!
WriteConsole(0, 'Game Stopped :(',Color);
end;

procedure ActivateServer();
var
  i:Integer;
begin
  for i:=1 to 32 do begin 
    aPlayers[i].Alive := False;
    aPlayers[i].Offmapping := False;
aPlayers[i].Counts := 0;
  end;



//Set some default variables
hns := false;
pop := false;
pop2 := false;
//Initialize the rest from hns.ini :D
Color := strtoint(ReadINI('scripts/' + ScriptName + '/hns.ini','Colors','Color','$FFFFFF'));
Maxplayer := strtoint(ReadINI('scripts/' + ScriptName + '/hns.ini','Settings','Maxplayers','32'));
if ReadINI('scripts/' + ScriptName + '/hns.ini','Settings','Pubserver','false') = 'true' then pubserver := true else pubserver := false;
if ReadINI('scripts/' + ScriptName + '/hns.ini','Settings','Mapbugs','false') = 'true' then Mapbugs := true else Mapbugs := false;
pubserver := true;
ranmap := xsplit(ReadFile('mapslist.txt'),chr(13)+chr(10));
end;

procedure AppOnIdle(Ticks: integer);
var
i: byte;
begin
if BravoPlayers = 1 then  // to fix the problem when the round finish the team changes counts too
for i:=1 to 32 do begin   
aPlayers[i].Alive := False;
aPlayers[i].Counts := 0;
end;

for i:=1 to 32 do begin 
if GetPlayerStat(i, 'Team') = 5 then begin // if player team is spec then reset his count
aPlayers[i].Counts := 0;
aPlayers[i].Alive := False;
end;
if (GetPlayerStat(i,'Active') = True) and aPlayers[i].Offmapping then
begin

if aPlayers[i].Counts = 1  then   //first time violating rule well you get a Warning
begin   
WriteConsole(0, GetPlayerStat(i, 'Name') + ' Went out off the map or changed team!',$FF8000);   //Shame to Out Maper in public
WriteConsole(0,' This is Your "Only" Warning',$FF8000);   // More Shame
aPlayers[i].Counts := 3;
end;

if aPlayers[i].Counts = 2  then   //Second time eh, not clever player Dies
begin 
WriteConsole(0, GetPlayerStat(i, 'Name') + ' Went out off the map or changed team!',$FF8000);   //Shame to Out Maper in public
WriteConsole(0,' You Got Warned before, so die!',$FF8000);   // More Shame

Command('/kill ' + inttostr(i));   //DIE OutMAPER
aPlayers[i].Offmapping := False;
aPlayers[i].Counts := 0; // he died so reset the counter.
end;
end;
end;


//if not hns and pubserver is enabled then do this, im too lazy to comment it, it's pretty obvious.
if ((not hns) and (pubserver)) then begin
if NumPlayers = 1 then if not pop then begin
WriteConsole(0, '2 more players to start Hide ''n Seek.',Color);
pop := true;
exit;
end;
if NumPlayers = 2 then if not pop2 then begin
WriteConsole(0, '1 more player to start Hide ''n Seek.',Color);
pop2 := true;
exit;
end;
if NumPlayers = 3 then begin
StartGame(ChooseRandomPlayer(3));
pop2 := false;
pop := false;
exit;
end;
if NumPlayers = 0 then if pop then begin
pop := false;
pop2 := false;
exit;
end;
end;
//if hns = true then begin
if hns then begin
for i := 1 to MaxPlayer do begin
if getplayerstat(i,'active') then begin
//If you're counting you get a black screen and you're frozen in place until the time runs out.
if Player[i].Counting then begin
DrawText(i,'||',200,RGB(0,0,0),40,-2500,-500);
end;
//if the count isnt 0 then deincriment it by 1.
if Player[i].count <> 0 then begin
WriteConsole(0, inttostr(Player[i].count),Color);
Player[i].count := Player[i].count - 1;
end;
//if count = 0 then unfreeze the seekah!
if Player[i].count = 0 then begin
if Player[i].Counting then begin
                                        Command('/setteam1 ' + IntToStr(i));
WriteConsole(0, 'Ready or not, here I come!',Color);
Player[i].seeker := true;
Player[i].Counting := false;
ForceWeapon(i, 7, 7, -1);
end;
end;
end;
end;
//if theres only 1 or less people in the server then stop the game.
if NumPlayers <= 2 then if not pubserver then StopGame() else begin
pop := false;
pop2 := false;
StopGame();
exit;
end;
//If therte are too many seekers reset the game.
if AlphaPlayers >= 2 then begin
WriteConsole(0, 'ERROR: Too many seekers! Restarting...',Color);
StartGame(ChooseRandomPlayer(3));
exit;
end;
//If there are no alphaplayers then reset the game.
if AlphaPlayers = 0 then begin
sleep(1000);
StartGame(ChooseRandomPlayer(3));
exit;
end;
//If there are no bravoplayers start a new round.
if BravoPlayers = 0 then begin
for i := 1 to MaxPlayer do if Player[i].First then begin
last := false;
StartGame(i);
exit;
end;
end;
//the last bravo player wins and gets 1 point!
if BravoPlayers = 1 then begin
if not last then begin
for i := 1 to MaxPlayer do if GetPlayerStat(i, 'Team') = 4 then if not Player[i].JustLeft then begin
Player[i].score := Player[i].score + 1;
WriteConsole(0, GetPlayerStat(i, 'Name') + ' is the last to be caught and has won the round!',Color);
last := true;
Player[i].First := true;
sleep(1000);
Command('/kill ' + inttostr(i));
break;
end;
end;
end;
end;
if delay <> 0 then begin
if delay <> 1 then delay := delay - 1 else begin
delay := delay - 1;
exit;
end;
WriteConsole(0,'Oyun baslıyor: ' + inttostr(delay) + '.',Color);
end;
if delay = 1 then begin
for i := 1 to MaxPlayer do begin
if getplayerstat(i,'active') then begin
if Player[i].it then begin
GetPlayerXY(i,Player[i].X,Player[i].Y);
Player[i].Counting := true;
Player[i].count := 10;
exit;
end;
end;
end;
end;
end;
procedure OnMapChange(NewMap: string);
var
i: byte;
begin

  for i:=1 to 32 do begin
    aPlayers[i].Alive := False;   
    aPlayers[i].Offmapping := False;
aPlayers[i].Counts := 0;
  end;
 
//onmapchange !start message
for i := 1 to MaxPlayer do begin
if getplayerstat(i,'active') then begin
if (Player[i].it and (not Player[i].counting) and (not Player[i].seeker)) then begin
delay := 11;
end;
end;
end;
end;


procedure OnJoinGame(ID, Team: byte);
begin
//if a game is going then set the new player to spec.
if hns then begin
Player[ID].NotPlaying := true;
Player[ID].score := 0;
Command('/setteam5 ' + inttostr(ID));
end;
end;

procedure OnJoinTeam(ID, Team: byte);
begin
if hns then begin
//if you're counting or a seeker stay in alpha
if ((Player[ID].it) or (Player[ID].Counting) or (Player[ID].seeker)) then if GetPlayerStat(ID, 'Team') <> 1 then Command('/setteam1 ' + inttostr(ID));
//if you're out then stay in spec.
if (Player[ID].NotPlaying) then if GetPlayerStat(ID, 'Team') <> 5 then Command('/setteam5 ' + inttostr(ID));
//if anything else stay in bravo.
if (((not Player[ID].it) and (not Player[ID].Counting) and (not Player[ID].seeker)) and (not Player[ID].NotPlaying)) then if GetPlayerStat(ID, 'Team') <> 4 then Command('/setteam4 ' + inttostr(ID));
//Player[ID].JustLeft := false;
end;
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
var
i, j: byte;
begin
//if the first person to get caught leaves it chooses a new random player.
if Player[ID].First then begin
Player[ID].First := false;
for i := 1 to 32 do begin
j := ChooseRandomPlayer(3);
if j <> ID then begin
Player[j].First := true;
WriteConsole(0, 'The first to get caught has left the game! Choosing random person...',Color);
break;
end else continue;
end;
for i := 1 to MaxPlayer do if Player[i].First then WriteConsole(0, GetPlayerStat(i, 'Name') + ' is now going to be it!',Color);
end;
//if the seeker leaves then start a new round.
if ((Player[ID].it) or (Player[ID].Counting) or (Player[ID].seeker)) then begin
for i:=1 to 32 do begin 
aPlayers[i].Alive := False;
aPlayers[i].Offmapping := False;
aPlayers[i].Counts := 0;
end;
WriteConsole(0, 'The seeker has left! Lamer! Resetting game...',Color);
Player[ID].count := 0;
Player[ID].seeker := false;
Player[ID].it := false;
for i := 1 to 32 do begin
j := ChooseRandomPlayer(3);
if j <> ID then begin
StartGame(j);
break;
end else continue;
end;
end;
Player[ID].it := false;
Player[ID].seeker := false;
Player[ID].count := 0;
Player[ID].First := false;
Player[ID].NotPlaying := true;
//Player[ID].JustLeft := true;
end;

function OnCommand(ID: Byte; Text: string): boolean;
var
i: byte;
begin
Result := false;
//all teh commands
case Lowercase(Text) of
'/startgame': begin
StartGame(ChooseRandomPlayer(3));
for i:=1 to 32 do begin   
aPlayers[i].Counts := 0;
aPlayers[i].Alive := False;
aPlayers[i].Offmapping := False;
end;
end;
'/swapteams':
for i:=1 to 32 do begin   
aPlayers[i].Counts := 0;
aPlayers[i].Alive := False;
aPlayers[i].Offmapping := False;
end;
'/stopgame': StopGame();
'/pubserver': begin
if pubserver then begin
pubserver := false;
WriteConsole(ID, 'Pubserver mode disabled',Color);
end else begin
pubserver := true;
WriteConsole(ID, 'Pubserver mode enabled',Color);
end;
end;
'/reloadini': begin
Color := strtoint(ReadINI('scripts/' + ScriptName + '/hns.ini','Colors','Color','$FFFFFF'));
Maxplayer := strtoint(ReadINI('scripts/' + ScriptName + '/hns.ini','Settings','Maxplayers','32'));
if ReadINI('scripts/' + ScriptName + '/hns.ini','Settings','Pubserver','false') = 'true' then pubserver := true else pubserver := false;
if ReadINI('scripts/' + ScriptName + '/hns.ini','Settings','Mapbugs','false') = 'true' then Mapbugs := true else Mapbugs := false;
WriteConsole(ID, 'hns.ini Reloaded',Color);
end;
end;
if Lowercase(GetPiece(Text, ' ', 0)) = '/choosefirst' then begin
if GetPiece(Text, ' ', 1) <> '' then for i := 1 to 32 do if Player[i].First then Player[i].First := false;
Player[strtoint(GetPiece(Text, ' ', 1))].First := true;
last := true;
WriteConsole(ID, 'An admin has chosen ' + GetPlayerStat(strtoint(GetPiece(Text, ' ', 1)), 'Name') + ' to be it!',Color);
end;
if Lowercase(GetPiece(Text, ' ', 0)) = '/setteam1' then begin
if GetPiece(Text, ' ', 1) <> '' then begin

aPlayers[ID].Counts := 0;
aPlayers[ID].Alive := False;
aPlayers[ID].Offmapping := False;
end;
end;
if Lowercase(GetPiece(Text, ' ', 0)) = '/setteam2' then begin
if GetPiece(Text, ' ', 1) <> '' then begin

aPlayers[ID].Counts := 0;
aPlayers[ID].Alive := False;
aPlayers[ID].Offmapping := False;
end;
end;
if Lowercase(GetPiece(Text, ' ', 0)) = '/setteam5' then begin
if GetPiece(Text, ' ', 1) <> '' then begin
aPlayers[ID].Counts := 0;
aPlayers[ID].Alive := False;
aPlayers[ID].Offmapping := False;
end;
end;
if Lowercase(GetPiece(Text, ' ', 0)) = '/addscore' then begin
if ((GetPiece(Text, ' ', 1) <> '') and (GetPiece(Text, ' ', 2) <> '')) then begin
try
Player[strtoint(GetPiece(Text, ' ', 1))].score := Player[strtoint(GetPiece(Text, ' ', 1))].score + strtoint(GetPiece(Text, ' ', 2));
WriteConsole(0, 'An admin has added ' + GetPiece(Text, ' ', 2) + ' points to '  + GetPlayerStat(strtoint(GetPiece(Text, ' ', 1)), 'Name') + '''s points!',Color);
except
end;
end;
end;
end;


function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
  Result := false;
if GetPlayerStat(ID, 'Team') = 4 then
       if ((Lowercase(Text) = '/brutalkill') or (Lowercase(Text) = '/kill') or (Lowercase(Text) = '/mercy')) then
   WriteConsole(0, GetPlayerStat(ID, 'Name') + ' Prefers to do Harakiri than let the seeker enjoy his/her death',$FF8000);
end;
       
procedure OnPlayerSpeak(ID: byte; Text: string);
var
i: byte;
begin

//if you want to see the scoreboard type !scores and it'll show.
if Lowercase(Text) = '!scores' then for i := 1 to MaxPlayer do if Player[i].score > 0 then WriteConsole(ID, GetPlayerStat(i, 'Name') + ': ' + inttostr(Player[i].score),Color);
//if you don't want to play this round type !sitout.
if Lowercase(Text) = '!sitout' then begin
if (not Player[ID].it) then begin
Player[ID].NotPlaying := true;
Command('/setteam5 ' + inttostr(ID));
end;
end;
if Lowercase(Text) = '!commands' then begin
WriteConsole(ID, '!start to start the countdown for a game.',Color);
WriteConsole(ID, '!sitout to sit out for 1 round.',Color);
WriteConsole(ID, '!scores to view the amount of wins everyone has.',Color);
end;
if Lowercase(Text) = '!help' then begin
WriteConsole(ID, 'Iq''s HnS (Hide and Seek) Server',Color);
WriteConsole(ID, 'Alpha team is "it", Bravo team hides',Color);
WriteConsole(ID, 'The "it" person has to "tag" people with the M79',Color);
WriteConsole(ID, 'First bravo person tagged will be it next map',Color);
WriteConsole(ID, 'Last bravo person to be found will win the round',Color);
WriteConsole(ID, 'Typing !start will start the match and begin the countdown',Color);
WriteConsole(ID, 'The black screen is normal :^)',Color);
end;
if Lowercase(Text) = '!rules' then begin
WriteConsole(ID, 'No snitching/hinting/luring/any of that crap',Color);
WriteConsole(ID, 'No excessive idiocy, trust me, I hate it.',Color);
WriteConsole(ID, 'Flying off the map IS NOT allowed ANYMORE.',Color);
WriteConsole(ID, 'Throwing the flag to reveal someone''s position is NOT',Color);
WriteConsole(ID, 'Dibs rule applies to single spots, not big chunks of the map',Color);
WriteConsole(ID, 'NO POLYBUGGING',Color);
end;

end;

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
//if youre not seeking and you have a weapon get rid of that shit or if you are a seeker and you dont have an m79 take one.
if hns then begin
if not Player[ID].seeker then if ((PrimaryNum < 50) or (SecondaryNum < 50)) then ClearWeapons(ID);
if Player[ID].seeker then if (PrimaryNum <> 7) then ForceWeapon(ID, 7, 7, -1);
end;
end;

function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
begin
//if you're seeking or counting and you get shot dont take damage else DIE DIE DIE
if hns then if ((Player[Victim].it) or (Player[Victim].seeker) or (Player[Shooter].Counting) or (Player[Victim].Counting)) then Result := -99999 else Result := Damage else result := Damage;
end;

procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
var
first: boolean;
begin
aPlayers[Victim].Alive := False;
  aPlayers[Victim].Counts := 0;
//if hns then begin, blah blah blah.
if hns then begin
//if the seeker kills you gtfo.
if Player[Killer].seeker then begin
Player[Victim].NotPlaying := true;
WriteConsole(Victim, 'You are out!',Color);
Command('/setteam5 ' + inttostr(Victim));
Player[Victim].NotPlaying := true;
first := false;
end;
//if you kill yourself also gtfo.
if Killer = Victim then begin
Player[Victim].NotPlaying := true;
WriteConsole(Victim, 'You are out!',Color);
Command('/setteam5 ' + inttostr(Victim));
Player[Victim].NotPlaying := true;
first := false;
end;
end;
end;


procedure OnPlayerRespawn(ID: byte);
begin
if BravoPlayers > 1 then begin
if AlphaPlayers = 1 then begin
if aPlayers[ID].Alive then begin
if GetPlayerStat(ID, 'Team') <> 5 then begin  // very important to not count the ppl on spec.
aPlayers[ID].Offmapping := True;
if aPlayers[ID].Counts = 3 then
aPlayers[ID].Counts := aPlayers[ID].Counts - 1;
if aPlayers[ID].Counts = 0 then
aPlayers[ID].Counts := aPlayers[ID].Counts + 1; // player violated the rule so this counts how many times he has done it
end
end;
aPlayers[ID].Alive := True;
end;
end;
end;

hns2.pas;

Code: [Select]
//Hide 'n Seek v2.5 Coded by Iq-Unlimited.
// Improved by la la
// -Out Mapper Killer
// -Team Change Killer
// -Suicide Msg
//tPlayer Record that has all the variables in it for neatness


const


  //Game constants
  cGame_nMaxHumanPlayers = 32; //maximum number of human players Soldat supports

  cPlayerID_First = 1; //first index player index number
  cPlayerID_Last = cGame_nMaxHumanPlayers; //last player index number

type
  trPlayer = record
    Alive : Boolean;
    Offmapping : Boolean;
Counts : Integer;
  end;
 
type tPlayer = record
it, Counting, NotPlaying, seeker, First, JustLeft: boolean;
X, Y: single;
count, score: integer;
end;

var
//All the boolean variables, there's a ton in this script isn't there lol.
hns, Mapbugs, last, pubserver, pop, pop2: boolean;
//Maxplayers...
Maxplayer, delay: byte;
//Color...
Color: longint;
ranmap: TStringArray;
//And the tPlayer array. It's the best one :D
Player: array [1..32] of tPlayer;
  aPlayers: array [1..32] of trPlayer;



function arrayHi( tester: TStringArray ): integer;
begin
result := GetArrayLength( tester ) - 1;
end;

function xsplit(const source: string; const delimiter: string):TStringArray;
var
i,x,d:integer;
s:string;
begin
d:=length(delimiter);
x:=0;
i:=1;
SetArrayLength(Result,1);
while(i<=length(source)) do begin
s:=Copy(source,i,d);   
    if(s=delimiter) then begin
    i:=i+d;
    inc(x,1);
    SetArrayLength(result,x+1);
    end else begin       
    result[x]:= result[x]+copy(s,1,1);
    inc(i,1);
  end;
end;
if Result[ArrayHi(Result)]='' then SetArrayLength(result,x);
end;

//ChooseRandomPlayer function chooses 1 random active player and returns that number.
function ChooseRandomPlayer(Max: byte): byte;
var
i, Ran: byte;
begin
for i := 1 to 255 do begin
Ran := Random(1, Max);
if GetPlayerStat(Ran, 'Active') then begin
result := Ran;
exit;
end;
end;
end;

//ClearWeapons does just that, clears your weapons.
procedure ClearWeapons(ID: byte);
begin
ForceWeapon(ID, 255, 255, 0);
end;

//Custom Choose Random Map function.
function RandomMap: string;
begin
result := ranmap[Random(0,ArrayHigh(ranmap))];
end;

//StartGame procedure, isit: byte is the player who will be it.
procedure StartGame(isit: byte);
var
i: byte;
begin
//hns := false is there to stop the OnJoinTeam out of range errors.
hns := false;
//Unset a bunch of variables that people might or might not have.
for i := 1 to MaxPlayer do begin
if getplayerstat(i,'active') then begin
Player[i].it := false;
Player[i].Counting := false;
Player[i].seeker := false;
Player[i].NotPlaying := false;
Player[i].First := false;
end;
end;
//player who is supposed to be it is now it.
Player[isit].it := true;
//Set people to their teams, seeker to alpha, all others to bravo.
for i := 1 to MaxPlayer do begin
if getplayerstat(i,'active') then begin
if GetPlayerStat(i, 'Active') then begin
if not Player[i].it then begin
Command('/setteam2 ' + inttostr(i));
end else begin
Command('/setteam1 ' + inttostr(i));
WriteConsole(i, 'You are it!',Color);
end;
end;
end;
end;
//Set some variables
last := false;
hns := true;
//if mapbugs then wait 1 second before changing map.
if Mapbugs then sleep(1000);
Command('/map ' + RandomMap);
end;


//Stops the game and removes all variables
procedure StopGame();
var
i: byte;
begin
for i := 1 to MaxPlayer do begin
if getplayerstat(i,'active') then begin
Player[i].it := false;
Player[i].Counting := false;
Player[i].seeker := false;
Player[i].First := false;
Player[i].NotPlaying := false;
Player[i].X := 0;
Player[i].Y := 0;
Player[i].count := 0;
Player[i].score := 0;
hns := false;
last := false;
end;
end;
//:( you stopped teh games!
WriteConsole(0, 'Game Stopped :(',Color);
end;

procedure ActivateServer();
var
  i:Integer;
begin
  for i:=1 to 32 do begin 
    aPlayers[i].Alive := False;
    aPlayers[i].Offmapping := False;
aPlayers[i].Counts := 0;
  end;



//Set some default variables
hns := false;
pop := false;
pop2 := false;
//Initialize the rest from hns.ini :D
Color := strtoint(ReadINI('scripts/' + ScriptName + '/hns.ini','Colors','Color','$FFFFFF'));
Maxplayer := strtoint(ReadINI('scripts/' + ScriptName + '/hns.ini','Settings','Maxplayers','32'));
if ReadINI('scripts/' + ScriptName + '/hns.ini','Settings','Pubserver','false') = 'true' then pubserver := true else pubserver := false;
if ReadINI('scripts/' + ScriptName + '/hns.ini','Settings','Mapbugs','false') = 'true' then Mapbugs := true else Mapbugs := false;
pubserver := true;
ranmap := xsplit(ReadFile('mapslist.txt'),chr(13)+chr(10));
end;

procedure AppOnIdle(Ticks: integer);
var
i: byte;
begin
if BravoPlayers = 1 then  // to fix the problem when the round finish the team changes counts too
for i:=1 to 32 do begin   
aPlayers[i].Alive := False;
aPlayers[i].Counts := 0;
end;

for i:=1 to 32 do begin 
if GetPlayerStat(i, 'Team') = 5 then begin // if player team is spec then reset his count
aPlayers[i].Counts := 0;
aPlayers[i].Alive := False;
end;
if (GetPlayerStat(i,'Active') = True) and aPlayers[i].Offmapping then
begin

if aPlayers[i].Counts = 1  then   //first time violating rule well you get a Warning
begin   
WriteConsole(0, GetPlayerStat(i, 'Name') + ' Went out off the map or changed team!',$FF8000);   //Shame to Out Maper in public
WriteConsole(0,' This is Your "Only" Warning',$FF8000);   // More Shame
aPlayers[i].Counts := 3;
end;

if aPlayers[i].Counts = 2  then   //Second time eh, not clever player Dies
begin 
WriteConsole(0, GetPlayerStat(i, 'Name') + ' Went out off the map or changed team!',$FF8000);   //Shame to Out Maper in public
WriteConsole(0,' You Got Warned before, so die!',$FF8000);   // More Shame

Command('/kill ' + inttostr(i));   //DIE OutMAPER
aPlayers[i].Offmapping := False;
aPlayers[i].Counts := 0; // he died so reset the counter.
end;
end;
end;


//if not hns and pubserver is enabled then do this, im too lazy to comment it, it's pretty obvious.
if ((not hns) and (pubserver)) then begin
if NumPlayers = 1 then if not pop then begin
WriteConsole(0, '2 more players to start Hide ''n Seek.',Color);
pop := true;
exit;
end;
if NumPlayers = 2 then if not pop2 then begin
WriteConsole(0, '1 more player to start Hide ''n Seek.',Color);
pop2 := true;
exit;
end;
if NumPlayers = 3 then begin
StartGame(ChooseRandomPlayer(3));
pop2 := false;
pop := false;
exit;
end;
if NumPlayers = 0 then if pop then begin
pop := false;
pop2 := false;
exit;
end;
end;
//if hns = true then begin
if hns then begin
for i := 1 to MaxPlayer do begin
if getplayerstat(i,'active') then begin
//If you're counting you get a black screen and you're frozen in place until the time runs out.
if Player[i].Counting then begin
DrawText(i,'||',200,RGB(0,0,0),40,-2500,-500);
end;
//if the count isnt 0 then deincriment it by 1.
if Player[i].count <> 0 then begin
WriteConsole(0, inttostr(Player[i].count),Color);
Player[i].count := Player[i].count - 1;
end;
//if count = 0 then unfreeze the seekah!
if Player[i].count = 0 then begin
if Player[i].Counting then begin
                                        Command('/setteam1 ' + IntToStr(i));
WriteConsole(0, 'Ready or not, here I come!',Color);
Player[i].seeker := true;
Player[i].Counting := false;
ForceWeapon(i, 7, 7, -1);
end;
end;
end;
end;
//if theres only 1 or less people in the server then stop the game.
if NumPlayers <= 2 then if not pubserver then StopGame() else begin
pop := false;
pop2 := false;
StopGame();
exit;
end;
//If therte are too many seekers reset the game.
if AlphaPlayers >= 2 then begin
WriteConsole(0, 'ERROR: Too many seekers! Restarting...',Color);
StartGame(ChooseRandomPlayer(3));
exit;
end;
//If there are no alphaplayers then reset the game.
if AlphaPlayers = 0 then begin
sleep(1000);
StartGame(ChooseRandomPlayer(3));
exit;
end;
//If there are no bravoplayers start a new round.
if BravoPlayers = 0 then begin
for i := 1 to MaxPlayer do if Player[i].First then begin
last := false;
StartGame(i);
exit;
end;
end;
//the last bravo player wins and gets 1 point!
if BravoPlayers = 1 then begin
if not last then begin
for i := 1 to MaxPlayer do if GetPlayerStat(i, 'Team') = 2 then if not Player[i].JustLeft then begin
Player[i].score := Player[i].score + 1;
WriteConsole(0, GetPlayerStat(i, 'Name') + ' is the last to be caught and has won the round!',Color);
last := true;
Player[i].First := true;
sleep(1000);
Command('/kill ' + inttostr(i));
break;
end;
end;
end;
end;
if delay <> 0 then begin
if delay <> 1 then delay := delay - 1 else begin
delay := delay - 1;
exit;
end;
WriteConsole(0,'Game Starting in: ' + inttostr(delay) + '.',Color);
end;
if delay = 1 then begin
for i := 1 to MaxPlayer do begin
if getplayerstat(i,'active') then begin
if Player[i].it then begin
GetPlayerXY(i,Player[i].X,Player[i].Y);
Player[i].Counting := true;
Player[i].count := 20;
exit;
end;
end;
end;
end;
end;
procedure OnMapChange(NewMap: string);
var
i: byte;
begin

  for i:=1 to 32 do begin
    aPlayers[i].Alive := False;   
    aPlayers[i].Offmapping := False;
aPlayers[i].Counts := 0;
  end;
 
//onmapchange !start message
for i := 1 to MaxPlayer do begin
if getplayerstat(i,'active') then begin
if (Player[i].it and (not Player[i].counting) and (not Player[i].seeker)) then begin
delay := 11;
end;
end;
end;
end;


procedure OnJoinGame(ID, Team: byte);
begin
//if a game is going then set the new player to spec.
if hns then begin
Player[ID].NotPlaying := true;
Player[ID].score := 0;
Command('/setteam5 ' + inttostr(ID));
end;
end;

procedure OnJoinTeam(ID, Team: byte);
begin
if hns then begin
//if you're counting or a seeker stay in alpha
if ((Player[ID].it) or (Player[ID].Counting) or (Player[ID].seeker)) then if GetPlayerStat(ID, 'Team') <> 1 then Command('/setteam1 ' + inttostr(ID));
//if you're out then stay in spec.
if (Player[ID].NotPlaying) then if GetPlayerStat(ID, 'Team') <> 5 then Command('/setteam5 ' + inttostr(ID));
//if anything else stay in bravo.
if (((not Player[ID].it) and (not Player[ID].Counting) and (not Player[ID].seeker)) and (not Player[ID].NotPlaying)) then if GetPlayerStat(ID, 'Team') <> 2 then Command('/setteam2 ' + inttostr(ID));
//Player[ID].JustLeft := false;
end;
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
var
i, j: byte;
begin
//if the first person to get caught leaves it chooses a new random player.
if Player[ID].First then begin
Player[ID].First := false;
for i := 1 to 32 do begin
j := ChooseRandomPlayer(3);
if j <> ID then begin
Player[j].First := true;
WriteConsole(0, 'The first to get caught has left the game! Choosing random person...',Color);
break;
end else continue;
end;
for i := 1 to MaxPlayer do if Player[i].First then WriteConsole(0, GetPlayerStat(i, 'Name') + ' is now going to be it!',Color);
end;
//if the seeker leaves then start a new round.
if ((Player[ID].it) or (Player[ID].Counting) or (Player[ID].seeker)) then begin
for i:=1 to 32 do begin 
aPlayers[i].Alive := False;
aPlayers[i].Offmapping := False;
aPlayers[i].Counts := 0;
end;
WriteConsole(0, 'The seeker has left! Lamer! Resetting game...',Color);
Player[ID].count := 0;
Player[ID].seeker := false;
Player[ID].it := false;
for i := 1 to 32 do begin
j := ChooseRandomPlayer(3);
if j <> ID then begin
StartGame(j);
break;
end else continue;
end;
end;
Player[ID].it := false;
Player[ID].seeker := false;
Player[ID].count := 0;
Player[ID].First := false;
Player[ID].NotPlaying := true;
//Player[ID].JustLeft := true;
end;

function OnCommand(ID: Byte; Text: string): boolean;
var
i: byte;
begin
Result := false;
//all teh commands
case Lowercase(Text) of
'/startgame': begin
StartGame(ChooseRandomPlayer(3));
for i:=1 to 32 do begin   
aPlayers[i].Counts := 0;
aPlayers[i].Alive := False;
aPlayers[i].Offmapping := False;
end;
end;
'/swapteams':
for i:=1 to 32 do begin   
aPlayers[i].Counts := 0;
aPlayers[i].Alive := False;
aPlayers[i].Offmapping := False;
end;
'/stopgame': StopGame();
'/pubserver': begin
if pubserver then begin
pubserver := false;
WriteConsole(ID, 'Pubserver mode disabled',Color);
end else begin
pubserver := true;
WriteConsole(ID, 'Pubserver mode enabled',Color);
end;
end;
'/reloadini': begin
Color := strtoint(ReadINI('scripts/' + ScriptName + '/hns.ini','Colors','Color','$FFFFFF'));
Maxplayer := strtoint(ReadINI('scripts/' + ScriptName + '/hns.ini','Settings','Maxplayers','32'));
if ReadINI('scripts/' + ScriptName + '/hns.ini','Settings','Pubserver','false') = 'true' then pubserver := true else pubserver := false;
if ReadINI('scripts/' + ScriptName + '/hns.ini','Settings','Mapbugs','false') = 'true' then Mapbugs := true else Mapbugs := false;
WriteConsole(ID, 'hns.ini Reloaded',Color);
end;
end;
if Lowercase(GetPiece(Text, ' ', 0)) = '/choosefirst' then begin
if GetPiece(Text, ' ', 1) <> '' then for i := 1 to 32 do if Player[i].First then Player[i].First := false;
Player[strtoint(GetPiece(Text, ' ', 1))].First := true;
last := true;
WriteConsole(ID, 'An admin has chosen ' + GetPlayerStat(strtoint(GetPiece(Text, ' ', 1)), 'Name') + ' to be it!',Color);
end;
if Lowercase(GetPiece(Text, ' ', 0)) = '/setteam1' then begin
if GetPiece(Text, ' ', 1) <> '' then begin

aPlayers[ID].Counts := 0;
aPlayers[ID].Alive := False;
aPlayers[ID].Offmapping := False;
end;
end;
if Lowercase(GetPiece(Text, ' ', 0)) = '/setteam2' then begin
if GetPiece(Text, ' ', 1) <> '' then begin

aPlayers[ID].Counts := 0;
aPlayers[ID].Alive := False;
aPlayers[ID].Offmapping := False;
end;
end;
if Lowercase(GetPiece(Text, ' ', 0)) = '/setteam5' then begin
if GetPiece(Text, ' ', 1) <> '' then begin
aPlayers[ID].Counts := 0;
aPlayers[ID].Alive := False;
aPlayers[ID].Offmapping := False;
end;
end;
if Lowercase(GetPiece(Text, ' ', 0)) = '/addscore' then begin
if ((GetPiece(Text, ' ', 1) <> '') and (GetPiece(Text, ' ', 2) <> '')) then begin
try
Player[strtoint(GetPiece(Text, ' ', 1))].score := Player[strtoint(GetPiece(Text, ' ', 1))].score + strtoint(GetPiece(Text, ' ', 2));
WriteConsole(0, 'An admin has added ' + GetPiece(Text, ' ', 2) + ' points to '  + GetPlayerStat(strtoint(GetPiece(Text, ' ', 1)), 'Name') + '''s points!',Color);
except
end;
end;
end;
end;


function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
  Result := false;
if GetPlayerStat(ID, 'Team') = 2 then
       if ((Lowercase(Text) = '/brutalkill') or (Lowercase(Text) = '/kill') or (Lowercase(Text) = '/mercy')) then
   WriteConsole(0, GetPlayerStat(ID, 'Name') + ' Prefers to do Harakiri than let the seeker enjoy his/her death',$FF8000);
end;
       
procedure OnPlayerSpeak(ID: byte; Text: string);
var
i: byte;
begin

//if you want to see the scoreboard type !scores and it'll show.
if Lowercase(Text) = '!scores' then for i := 1 to MaxPlayer do if Player[i].score > 0 then WriteConsole(ID, GetPlayerStat(i, 'Name') + ': ' + inttostr(Player[i].score),Color);
//if you don't want to play this round type !sitout.
if Lowercase(Text) = '!sitout' then begin
if (not Player[ID].it) then begin
Player[ID].NotPlaying := true;
Command('/setteam5 ' + inttostr(ID));
end;
end;
if Lowercase(Text) = '!commands' then begin
WriteConsole(ID, '!start to start the countdown for a game.',Color);
WriteConsole(ID, '!sitout to sit out for 1 round.',Color);
WriteConsole(ID, '!scores to view the amount of wins everyone has.',Color);
end;
if Lowercase(Text) = '!help' then begin
WriteConsole(ID, 'Iq''s HnS (Hide and Seek) Server',Color);
WriteConsole(ID, 'Alpha team is "it", Bravo team hides',Color);
WriteConsole(ID, 'The "it" person has to "tag" people with the M79',Color);
WriteConsole(ID, 'First bravo person tagged will be it next map',Color);
WriteConsole(ID, 'Last bravo person to be found will win the round',Color);
WriteConsole(ID, 'Typing !start will start the match and begin the countdown',Color);
WriteConsole(ID, 'The black screen is normal :^)',Color);
end;
if Lowercase(Text) = '!rules' then begin
WriteConsole(ID, 'No snitching/hinting/luring/any of that crap',Color);
WriteConsole(ID, 'No excessive idiocy, trust me, I hate it.',Color);
WriteConsole(ID, 'Flying off the map IS NOT allowed ANYMORE.',Color);
WriteConsole(ID, 'Throwing the flag to reveal someone''s position is NOT',Color);
WriteConsole(ID, 'Dibs rule applies to single spots, not big chunks of the map',Color);
WriteConsole(ID, 'NO POLYBUGGING',Color);
end;

end;

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
//if youre not seeking and you have a weapon get rid of that shit or if you are a seeker and you dont have an m79 take one.
if hns then begin
if not Player[ID].seeker then if ((PrimaryNum < 50) or (SecondaryNum < 50)) then ClearWeapons(ID);
if Player[ID].seeker then if (PrimaryNum <> 7) then ForceWeapon(ID, 7, 7, -1);
end;
end;

function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
begin
//if you're seeking or counting and you get shot dont take damage else DIE DIE DIE
if hns then if ((Player[Victim].it) or (Player[Victim].seeker) or (Player[Shooter].Counting) or (Player[Victim].Counting)) then Result := -99999 else Result := Damage else result := Damage;
end;

procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
var
first: boolean;
begin
aPlayers[Victim].Alive := False;
  aPlayers[Victim].Counts := 0;
//if hns then begin, blah blah blah.
if hns then begin
//if the seeker kills you gtfo.
if Player[Killer].seeker then begin
Player[Victim].NotPlaying := true;
WriteConsole(Victim, 'You are out!',Color);
Command('/setteam5 ' + inttostr(Victim));
Player[Victim].NotPlaying := true;
first := false;
end;
//if you kill yourself also gtfo.
if Killer = Victim then begin
Player[Victim].NotPlaying := true;
WriteConsole(Victim, 'You are out!',Color);
Command('/setteam5 ' + inttostr(Victim));
Player[Victim].NotPlaying := true;
first := false;
end;
end;
end;


procedure OnPlayerRespawn(ID: byte);
begin
if BravoPlayers > 1 then begin
if AlphaPlayers = 1 then begin
if aPlayers[ID].Alive then begin
if GetPlayerStat(ID, 'Team') <> 5 then begin  // very important to not count the ppl on spec.
aPlayers[ID].Offmapping := True;
if aPlayers[ID].Counts = 3 then
aPlayers[ID].Counts := aPlayers[ID].Counts - 1;
if aPlayers[ID].Counts = 0 then
aPlayers[ID].Counts := aPlayers[ID].Counts + 1; // player violated the rule so this counts how many times he has done it
end
end;
aPlayers[ID].Alive := True;
end;
end;
end;

HnS.pas and hns2.pas in HnS script folder, I dont know which one working
Codes are here, players joining and seeker was thrown because of the possible cheating
Codes are here, look at, why?
« Last Edit: January 06, 2013, 02:47:30 pm by MrHamsTR »
Is there anybody can write script?
Good, go and play soldat ^^

Offline Mittsu

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 617
Re: Hide and Seek Script, Some Problems
« Reply #1 on: January 01, 2013, 04:18:11 pm »
why do you think the kick has anything to do with the code? Players get kicked for possible cheating because of an old knife bug usually.
Realistic-Soldat.net
<+elerok> soldat is dead
<+AThousandD> shit happens

Offline MrHamsTR

  • Soldier
  • **
  • Posts: 209
  • One day, everything will end..
Re: Hide and Seek Script, Some Problems
« Reply #2 on: January 01, 2013, 04:58:46 pm »
All players and only this server with this script? ^^
Is there anybody can write script?
Good, go and play soldat ^^

Offline Falcon`

  • Flagrunner
  • ****
  • Posts: 792
  • A wanted lagger
Re: Hide and Seek Script, Some Problems
« Reply #3 on: January 01, 2013, 05:22:09 pm »
set Disable_AntiCheat_Kick to 1 in your soldat.ini
If you're not paying for something, you're not the customer; you're the product being sold.
- Andrew Lewis

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

Offline MrHamsTR

  • Soldier
  • **
  • Posts: 209
  • One day, everything will end..
Re: Hide and Seek Script, Some Problems
« Reply #4 on: January 02, 2013, 09:56:33 am »
Yes, I changed to 1 but now; "player" due to the flood was thrown, what is wrong?
Is there anybody can write script?
Good, go and play soldat ^^

Offline Mittsu

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 617
Re: Hide and Seek Script, Some Problems
« Reply #5 on: January 02, 2013, 10:58:29 am »
These kinds of things happen, just soldat bugs
Realistic-Soldat.net
<+elerok> soldat is dead
<+AThousandD> shit happens

Offline MrHamsTR

  • Soldier
  • **
  • Posts: 209
  • One day, everything will end..
Re: Hide and Seek Script, Some Problems
« Reply #6 on: January 02, 2013, 03:29:08 pm »
Eu's script doesn't sharing, they dont help me, I said that.
How can I correct wrongs, I dont know :(
I want well and working servers for hosting :/
But I cant write script then correct them :/ I dont anything about them.
If you are, someone help me, I will be happy :/
Is there anybody can write script?
Good, go and play soldat ^^

Offline Falcon`

  • Flagrunner
  • ****
  • Posts: 792
  • A wanted lagger
Re: Hide and Seek Script, Some Problems
« Reply #7 on: January 03, 2013, 03:18:26 am »
Please check whenever these flood kicks repeat, and if they do, then in what circumstances.
If you're not paying for something, you're not the customer; you're the product being sold.
- Andrew Lewis

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

Offline ExHunter

  • Inactive Soldat Developer
  • Soldier
  • ******
  • Posts: 154
  • Speedy go!
Re: Hide and Seek Script, Some Problems
« Reply #8 on: January 03, 2013, 08:47:22 am »
Code: [Select]
if GetPlayerStat(i, 'X') <> Player[i].X then MovePlayer(i, Player[i].X, Player[i].Y) else if GetPlayerStat(i, 'Y') <> Player[i].Y then MovePlayer(i, Player[i].X, Player[i].Y);
remove that line.

and add a line below

Code: [Select]
WriteConsole(0, 'Ready or not, here I come!',Color);
with that

Code: [Select]
Command('/setteam1 ' + IntToStr(i));
Tell me if that worked (I am not sure).

P.S: I manage the !Hide and Seek EU scripts, I never refused to help you, since you never asked me. We simply do not share the scripts. :)

Offline MrHamsTR

  • Soldier
  • **
  • Posts: 209
  • One day, everything will end..
Re: Hide and Seek Script, Some Problems
« Reply #9 on: January 03, 2013, 10:43:44 am »
I cant find it, can you correct it on original code and paste in message? (new code)
Is there anybody can write script?
Good, go and play soldat ^^

Offline ExHunter

  • Inactive Soldat Developer
  • Soldier
  • ******
  • Posts: 154
  • Speedy go!
Re: Hide and Seek Script, Some Problems
« Reply #10 on: January 03, 2013, 11:40:13 am »
Code: [Select]
//Hide 'n Seek v2.5 Coded by Iq-Unlimited.
// Improved by la la
// -Out Mapper Killer
// -Team Change Killer
// -Suicide Msg
//tPlayer Record that has all the variables in it for neatness


const


  //Game constants
  cGame_nMaxHumanPlayers = 32; //maximum number of human players Soldat supports

  cPlayerID_First = 1; //first index player index number
  cPlayerID_Last = cGame_nMaxHumanPlayers; //last player index number

type
  trPlayer = record
    Alive : Boolean;
    Offmapping : Boolean;
Counts : Integer;
  end;
 
type tPlayer = record
it, Counting, NotPlaying, seeker, First, JustLeft: boolean;
X, Y: single;
count, score: integer;
end;

var
//All the boolean variables, there's a ton in this script isn't there lol.
hns, Mapbugs, last, pubserver, pop, pop2: boolean;
//Maxplayers...
Maxplayer, delay: byte;
//Color...
Color: longint;
ranmap: TStringArray;
//And the tPlayer array. It's the best one :D
Player: array [1..32] of tPlayer;
  aPlayers: array [1..32] of trPlayer;



function arrayHi( tester: TStringArray ): integer;
begin
result := GetArrayLength( tester ) - 1;
end;

function xsplit(const source: string; const delimiter: string):TStringArray;
var
i,x,d:integer;
s:string;
begin
d:=length(delimiter);
x:=0;
i:=1;
SetArrayLength(Result,1);
while(i<=length(source)) do begin
s:=Copy(source,i,d);   
    if(s=delimiter) then begin
    i:=i+d;
    inc(x,1);
    SetArrayLength(result,x+1);
    end else begin       
    result[x]:= result[x]+copy(s,1,1);
    inc(i,1);
  end;
end;
if Result[ArrayHi(Result)]='' then SetArrayLength(result,x);
end;

//ChooseRandomPlayer function chooses 1 random active player and returns that number.
function ChooseRandomPlayer(Max: byte): byte;
var
i, Ran: byte;
begin
for i := 1 to 255 do begin
Ran := Random(1, Max);
if GetPlayerStat(Ran, 'Active') then begin
result := Ran;
exit;
end;
end;
end;

//ClearWeapons does just that, clears your weapons.
procedure ClearWeapons(ID: byte);
begin
ForceWeapon(ID, 255, 255, 0);
end;

//Custom Choose Random Map function.
function RandomMap: string;
begin
result := ranmap[Random(0,ArrayHigh(ranmap))];
end;

//StartGame procedure, isit: byte is the player who will be it.
procedure StartGame(isit: byte);
var
i: byte;
begin
//hns := false is there to stop the OnJoinTeam out of range errors.
hns := false;
//Unset a bunch of variables that people might or might not have.
for i := 1 to MaxPlayer do begin
if getplayerstat(i,'active') then begin
Player[i].it := false;
Player[i].Counting := false;
Player[i].seeker := false;
Player[i].NotPlaying := false;
Player[i].First := false;
end;
end;
//player who is supposed to be it is now it.
Player[isit].it := true;
//Set people to their teams, seeker to alpha, all others to bravo.
for i := 1 to MaxPlayer do begin
if getplayerstat(i,'active') then begin
if GetPlayerStat(i, 'Active') then begin
if not Player[i].it then begin
Command('/setteam2 ' + inttostr(i));
end else begin
Command('/setteam1 ' + inttostr(i));
WriteConsole(i, 'You are it!',Color);
end;
end;
end;
end;
//Set some variables
last := false;
hns := true;
//if mapbugs then wait 1 second before changing map.
if Mapbugs then sleep(1000);
Command('/map ' + RandomMap);
end;


//Stops the game and removes all variables
procedure StopGame();
var
i: byte;
begin
for i := 1 to MaxPlayer do begin
if getplayerstat(i,'active') then begin
Player[i].it := false;
Player[i].Counting := false;
Player[i].seeker := false;
Player[i].First := false;
Player[i].NotPlaying := false;
Player[i].X := 0;
Player[i].Y := 0;
Player[i].count := 0;
Player[i].score := 0;
hns := false;
last := false;
end;
end;
//:( you stopped teh games!
WriteConsole(0, 'Game Stopped :(',Color);
end;

procedure ActivateServer();
var
  i:Integer;
begin
  for i:=1 to 32 do begin 
    aPlayers[i].Alive := False;
    aPlayers[i].Offmapping := False;
aPlayers[i].Counts := 0;
  end;



//Set some default variables
hns := false;
pop := false;
pop2 := false;
//Initialize the rest from hns.ini :D
Color := strtoint(ReadINI('scripts/' + ScriptName + '/hns.ini','Colors','Color','$FFFFFF'));
Maxplayer := strtoint(ReadINI('scripts/' + ScriptName + '/hns.ini','Settings','Maxplayers','32'));
if ReadINI('scripts/' + ScriptName + '/hns.ini','Settings','Pubserver','false') = 'true' then pubserver := true else pubserver := false;
if ReadINI('scripts/' + ScriptName + '/hns.ini','Settings','Mapbugs','false') = 'true' then Mapbugs := true else Mapbugs := false;
pubserver := true;
ranmap := xsplit(ReadFile('mapslist.txt'),chr(13)+chr(10));
end;

procedure AppOnIdle(Ticks: integer);
var
i: byte;
begin
if BravoPlayers = 1 then  // to fix the problem when the round finish the team changes counts too
for i:=1 to 32 do begin   
aPlayers[i].Alive := False;
aPlayers[i].Counts := 0;
end;

for i:=1 to 32 do begin 
if GetPlayerStat(i, 'Team') = 5 then begin // if player team is spec then reset his count
aPlayers[i].Counts := 0;
aPlayers[i].Alive := False;
end;
if (GetPlayerStat(i,'Active') = True) and aPlayers[i].Offmapping then
begin

if aPlayers[i].Counts = 1  then   //first time violating rule well you get a Warning
begin   
WriteConsole(0, GetPlayerStat(i, 'Name') + ' Went out off the map or changed team!',$FF8000);   //Shame to Out Maper in public
WriteConsole(0,' This is Your "Only" Warning',$FF8000);   // More Shame
aPlayers[i].Counts := 3;
end;

if aPlayers[i].Counts = 2  then   //Second time eh, not clever player Dies
begin 
WriteConsole(0, GetPlayerStat(i, 'Name') + ' Went out off the map or changed team!',$FF8000);   //Shame to Out Maper in public
WriteConsole(0,' You Got Warned before, so die!',$FF8000);   // More Shame

Command('/kill ' + inttostr(i));   //DIE OutMAPER
aPlayers[i].Offmapping := False;
aPlayers[i].Counts := 0; // he died so reset the counter.
end;
end;
end;


//if not hns and pubserver is enabled then do this, im too lazy to comment it, it's pretty obvious.
if ((not hns) and (pubserver)) then begin
if NumPlayers = 1 then if not pop then begin
WriteConsole(0, '2 more players to start Hide ''n Seek.',Color);
pop := true;
exit;
end;
if NumPlayers = 2 then if not pop2 then begin
WriteConsole(0, '1 more player to start Hide ''n Seek.',Color);
pop2 := true;
exit;
end;
if NumPlayers = 3 then begin
StartGame(ChooseRandomPlayer(3));
pop2 := false;
pop := false;
exit;
end;
if NumPlayers = 0 then if pop then begin
pop := false;
pop2 := false;
exit;
end;
end;
//if hns = true then begin
if hns then begin
for i := 1 to MaxPlayer do begin
if getplayerstat(i,'active') then begin
//If you're counting you get a black screen and you're frozen in place until the time runs out.
if Player[i].Counting then begin
DrawText(i,'||',200,RGB(0,0,0),40,-2500,-500);
end;
//if the count isnt 0 then deincriment it by 1.
if Player[i].count <> 0 then begin
WriteConsole(0, inttostr(Player[i].count),Color);
Player[i].count := Player[i].count - 1;
end;
//if count = 0 then unfreeze the seekah!
if Player[i].count = 0 then begin
if Player[i].Counting then begin
                                        Command('/setteam1 ' + IntToStr(i));
WriteConsole(0, 'Ready or not, here I come!',Color);
Player[i].seeker := true;
Player[i].Counting := false;
ForceWeapon(i, 7, 7, -1);
end;
end;
end;
end;
//if theres only 1 or less people in the server then stop the game.
if NumPlayers <= 2 then if not pubserver then StopGame() else begin
pop := false;
pop2 := false;
StopGame();
exit;
end;
//If therte are too many seekers reset the game.
if AlphaPlayers >= 2 then begin
WriteConsole(0, 'ERROR: Too many seekers! Restarting...',Color);
StartGame(ChooseRandomPlayer(3));
exit;
end;
//If there are no alphaplayers then reset the game.
if AlphaPlayers = 0 then begin
sleep(1000);
StartGame(ChooseRandomPlayer(3));
exit;
end;
//If there are no bravoplayers start a new round.
if BravoPlayers = 0 then begin
for i := 1 to MaxPlayer do if Player[i].First then begin
last := false;
StartGame(i);
exit;
end;
end;
//the last bravo player wins and gets 1 point!
if BravoPlayers = 1 then begin
if not last then begin
for i := 1 to MaxPlayer do if GetPlayerStat(i, 'Team') = 2 then if not Player[i].JustLeft then begin
Player[i].score := Player[i].score + 1;
WriteConsole(0, GetPlayerStat(i, 'Name') + ' is the last to be caught and has won the round!',Color);
last := true;
Player[i].First := true;
sleep(1000);
Command('/kill ' + inttostr(i));
break;
end;
end;
end;
end;
if delay <> 0 then begin
if delay <> 1 then delay := delay - 1 else begin
delay := delay - 1;
exit;
end;
WriteConsole(0,'Game Starting in: ' + inttostr(delay) + '.',Color);
end;
if delay = 1 then begin
for i := 1 to MaxPlayer do begin
if getplayerstat(i,'active') then begin
if Player[i].it then begin
GetPlayerXY(i,Player[i].X,Player[i].Y);
Player[i].Counting := true;
Player[i].count := 20;
exit;
end;
end;
end;
end;
end;
procedure OnMapChange(NewMap: string);
var
i: byte;
begin

  for i:=1 to 32 do begin
    aPlayers[i].Alive := False;   
    aPlayers[i].Offmapping := False;
aPlayers[i].Counts := 0;
  end;
 
//onmapchange !start message
for i := 1 to MaxPlayer do begin
if getplayerstat(i,'active') then begin
if (Player[i].it and (not Player[i].counting) and (not Player[i].seeker)) then begin
delay := 11;
end;
end;
end;
end;


procedure OnJoinGame(ID, Team: byte);
begin
//if a game is going then set the new player to spec.
if hns then begin
Player[ID].NotPlaying := true;
Player[ID].score := 0;
Command('/setteam5 ' + inttostr(ID));
end;
end;

procedure OnJoinTeam(ID, Team: byte);
begin
if hns then begin
//if you're counting or a seeker stay in alpha
if ((Player[ID].it) or (Player[ID].Counting) or (Player[ID].seeker)) then if GetPlayerStat(ID, 'Team') <> 1 then Command('/setteam1 ' + inttostr(ID));
//if you're out then stay in spec.
if (Player[ID].NotPlaying) then if GetPlayerStat(ID, 'Team') <> 5 then Command('/setteam5 ' + inttostr(ID));
//if anything else stay in bravo.
if (((not Player[ID].it) and (not Player[ID].Counting) and (not Player[ID].seeker)) and (not Player[ID].NotPlaying)) then if GetPlayerStat(ID, 'Team') <> 2 then Command('/setteam2 ' + inttostr(ID));
//Player[ID].JustLeft := false;
end;
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
var
i, j: byte;
begin
//if the first person to get caught leaves it chooses a new random player.
if Player[ID].First then begin
Player[ID].First := false;
for i := 1 to 32 do begin
j := ChooseRandomPlayer(3);
if j <> ID then begin
Player[j].First := true;
WriteConsole(0, 'The first to get caught has left the game! Choosing random person...',Color);
break;
end else continue;
end;
for i := 1 to MaxPlayer do if Player[i].First then WriteConsole(0, GetPlayerStat(i, 'Name') + ' is now going to be it!',Color);
end;
//if the seeker leaves then start a new round.
if ((Player[ID].it) or (Player[ID].Counting) or (Player[ID].seeker)) then begin
for i:=1 to 32 do begin 
aPlayers[i].Alive := False;
aPlayers[i].Offmapping := False;
aPlayers[i].Counts := 0;
end;
WriteConsole(0, 'The seeker has left! Lamer! Resetting game...',Color);
Player[ID].count := 0;
Player[ID].seeker := false;
Player[ID].it := false;
for i := 1 to 32 do begin
j := ChooseRandomPlayer(3);
if j <> ID then begin
StartGame(j);
break;
end else continue;
end;
end;
Player[ID].it := false;
Player[ID].seeker := false;
Player[ID].count := 0;
Player[ID].First := false;
Player[ID].NotPlaying := true;
//Player[ID].JustLeft := true;
end;

function OnCommand(ID: Byte; Text: string): boolean;
var
i: byte;
begin
Result := false;
//all teh commands
case Lowercase(Text) of
'/startgame': begin
StartGame(ChooseRandomPlayer(3));
for i:=1 to 32 do begin   
aPlayers[i].Counts := 0;
aPlayers[i].Alive := False;
aPlayers[i].Offmapping := False;
end;
end;
'/swapteams':
for i:=1 to 32 do begin   
aPlayers[i].Counts := 0;
aPlayers[i].Alive := False;
aPlayers[i].Offmapping := False;
end;
'/stopgame': StopGame();
'/pubserver': begin
if pubserver then begin
pubserver := false;
WriteConsole(ID, 'Pubserver mode disabled',Color);
end else begin
pubserver := true;
WriteConsole(ID, 'Pubserver mode enabled',Color);
end;
end;
'/reloadini': begin
Color := strtoint(ReadINI('scripts/' + ScriptName + '/hns.ini','Colors','Color','$FFFFFF'));
Maxplayer := strtoint(ReadINI('scripts/' + ScriptName + '/hns.ini','Settings','Maxplayers','32'));
if ReadINI('scripts/' + ScriptName + '/hns.ini','Settings','Pubserver','false') = 'true' then pubserver := true else pubserver := false;
if ReadINI('scripts/' + ScriptName + '/hns.ini','Settings','Mapbugs','false') = 'true' then Mapbugs := true else Mapbugs := false;
WriteConsole(ID, 'hns.ini Reloaded',Color);
end;
end;
if Lowercase(GetPiece(Text, ' ', 0)) = '/choosefirst' then begin
if GetPiece(Text, ' ', 1) <> '' then for i := 1 to 32 do if Player[i].First then Player[i].First := false;
Player[strtoint(GetPiece(Text, ' ', 1))].First := true;
last := true;
WriteConsole(ID, 'An admin has chosen ' + GetPlayerStat(strtoint(GetPiece(Text, ' ', 1)), 'Name') + ' to be it!',Color);
end;
if Lowercase(GetPiece(Text, ' ', 0)) = '/setteam1' then begin
if GetPiece(Text, ' ', 1) <> '' then begin

aPlayers[ID].Counts := 0;
aPlayers[ID].Alive := False;
aPlayers[ID].Offmapping := False;
end;
end;
if Lowercase(GetPiece(Text, ' ', 0)) = '/setteam2' then begin
if GetPiece(Text, ' ', 1) <> '' then begin

aPlayers[ID].Counts := 0;
aPlayers[ID].Alive := False;
aPlayers[ID].Offmapping := False;
end;
end;
if Lowercase(GetPiece(Text, ' ', 0)) = '/setteam5' then begin
if GetPiece(Text, ' ', 1) <> '' then begin
aPlayers[ID].Counts := 0;
aPlayers[ID].Alive := False;
aPlayers[ID].Offmapping := False;
end;
end;
if Lowercase(GetPiece(Text, ' ', 0)) = '/addscore' then begin
if ((GetPiece(Text, ' ', 1) <> '') and (GetPiece(Text, ' ', 2) <> '')) then begin
try
Player[strtoint(GetPiece(Text, ' ', 1))].score := Player[strtoint(GetPiece(Text, ' ', 1))].score + strtoint(GetPiece(Text, ' ', 2));
WriteConsole(0, 'An admin has added ' + GetPiece(Text, ' ', 2) + ' points to '  + GetPlayerStat(strtoint(GetPiece(Text, ' ', 1)), 'Name') + '''s points!',Color);
except
end;
end;
end;
end;


function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
  Result := false;
if GetPlayerStat(ID, 'Team') = 2 then
       if ((Lowercase(Text) = '/brutalkill') or (Lowercase(Text) = '/kill') or (Lowercase(Text) = '/mercy')) then
   WriteConsole(0, GetPlayerStat(ID, 'Name') + ' Prefers to do Harakiri than let the seeker enjoy his/her death',$FF8000);
end;
       
procedure OnPlayerSpeak(ID: byte; Text: string);
var
i: byte;
begin

//if you want to see the scoreboard type !scores and it'll show.
if Lowercase(Text) = '!scores' then for i := 1 to MaxPlayer do if Player[i].score > 0 then WriteConsole(ID, GetPlayerStat(i, 'Name') + ': ' + inttostr(Player[i].score),Color);
//if you don't want to play this round type !sitout.
if Lowercase(Text) = '!sitout' then begin
if (not Player[ID].it) then begin
Player[ID].NotPlaying := true;
Command('/setteam5 ' + inttostr(ID));
end;
end;
if Lowercase(Text) = '!commands' then begin
WriteConsole(ID, '!start to start the countdown for a game.',Color);
WriteConsole(ID, '!sitout to sit out for 1 round.',Color);
WriteConsole(ID, '!scores to view the amount of wins everyone has.',Color);
end;
if Lowercase(Text) = '!help' then begin
WriteConsole(ID, 'Iq''s HnS (Hide and Seek) Server',Color);
WriteConsole(ID, 'Alpha team is "it", Bravo team hides',Color);
WriteConsole(ID, 'The "it" person has to "tag" people with the M79',Color);
WriteConsole(ID, 'First bravo person tagged will be it next map',Color);
WriteConsole(ID, 'Last bravo person to be found will win the round',Color);
WriteConsole(ID, 'Typing !start will start the match and begin the countdown',Color);
WriteConsole(ID, 'The black screen is normal :^)',Color);
end;
if Lowercase(Text) = '!rules' then begin
WriteConsole(ID, 'No snitching/hinting/luring/any of that crap',Color);
WriteConsole(ID, 'No excessive idiocy, trust me, I hate it.',Color);
WriteConsole(ID, 'Flying off the map IS NOT allowed ANYMORE.',Color);
WriteConsole(ID, 'Throwing the flag to reveal someone''s position is NOT',Color);
WriteConsole(ID, 'Dibs rule applies to single spots, not big chunks of the map',Color);
WriteConsole(ID, 'NO POLYBUGGING',Color);
end;

end;

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
//if youre not seeking and you have a weapon get rid of that shit or if you are a seeker and you dont have an m79 take one.
if hns then begin
if not Player[ID].seeker then if ((PrimaryNum < 50) or (SecondaryNum < 50)) then ClearWeapons(ID);
if Player[ID].seeker then if (PrimaryNum <> 7) then ForceWeapon(ID, 7, 7, -1);
end;
end;

function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
begin
//if you're seeking or counting and you get shot dont take damage else DIE DIE DIE
if hns then if ((Player[Victim].it) or (Player[Victim].seeker) or (Player[Shooter].Counting) or (Player[Victim].Counting)) then Result := -99999 else Result := Damage else result := Damage;
end;

procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
var
first: boolean;
begin
aPlayers[Victim].Alive := False;
  aPlayers[Victim].Counts := 0;
//if hns then begin, blah blah blah.
if hns then begin
//if the seeker kills you gtfo.
if Player[Killer].seeker then begin
Player[Victim].NotPlaying := true;
WriteConsole(Victim, 'You are out!',Color);
Command('/setteam5 ' + inttostr(Victim));
Player[Victim].NotPlaying := true;
first := false;
end;
//if you kill yourself also gtfo.
if Killer = Victim then begin
Player[Victim].NotPlaying := true;
WriteConsole(Victim, 'You are out!',Color);
Command('/setteam5 ' + inttostr(Victim));
Player[Victim].NotPlaying := true;
first := false;
end;
end;
end;


procedure OnPlayerRespawn(ID: byte);
begin
if BravoPlayers > 1 then begin
if AlphaPlayers = 1 then begin
if aPlayers[ID].Alive then begin
if GetPlayerStat(ID, 'Team') <> 5 then begin  // very important to not count the ppl on spec.
aPlayers[ID].Offmapping := True;
if aPlayers[ID].Counts = 3 then
aPlayers[ID].Counts := aPlayers[ID].Counts - 1;
if aPlayers[ID].Counts = 0 then
aPlayers[ID].Counts := aPlayers[ID].Counts + 1; // player violated the rule so this counts how many times he has done it
end
end;
aPlayers[ID].Alive := True;
end;
end;
end;

Tell me if it works.

Offline MrHamsTR

  • Soldier
  • **
  • Posts: 209
  • One day, everything will end..
Re: Hide and Seek Script, Some Problems
« Reply #11 on: January 04, 2013, 10:14:35 am »
No, it didn't work :(
Is there anybody can write script?
Good, go and play soldat ^^

Offline ExHunter

  • Inactive Soldat Developer
  • Soldier
  • ******
  • Posts: 154
  • Speedy go!
Re: Hide and Seek Script, Some Problems
« Reply #12 on: January 04, 2013, 06:44:29 pm »
Is the player that gets flood kicked the seeker?
when does it occur - while the counting down?

Offline rOy

  • Soldier
  • **
  • Posts: 120
Re: Hide and Seek Script, Some Problems
« Reply #13 on: January 04, 2013, 08:34:15 pm »
Hey

In the file server.ini
change to ACBanTime=0

In the file soldat.ini
change to Disable_AntiCheat_Kick=1

Good luck ;D

Offline MrHamsTR

  • Soldier
  • **
  • Posts: 209
  • One day, everything will end..
Re: Hide and Seek Script, Some Problems
« Reply #14 on: January 05, 2013, 06:25:27 am »
Yes counting down, server kicked the seeker.
Is there anybody can write script?
Good, go and play soldat ^^

Offline rOy

  • Soldier
  • **
  • Posts: 120
Re: Hide and Seek Script, Some Problems
« Reply #15 on: January 06, 2013, 12:22:09 am »
Yes counting down, server kicked the seeker.

Works for you?
I tested it and seeker not kicked.

Offline LeoN46

  • Major(1)
  • Posts: 1
Re: Hide and Seek Script, Some Problems
« Reply #16 on: January 06, 2013, 02:10:49 pm »
I'm having the same problem.Please help

Offline MrHamsTR

  • Soldier
  • **
  • Posts: 209
  • One day, everything will end..
Re: Hide and Seek Script, Some Problems
« Reply #17 on: January 06, 2013, 02:43:08 pm »
Leon46, for minimap; in soldat.ini set disable_minimap:1 to 0
« Last Edit: January 06, 2013, 02:48:15 pm by MrHamsTR »
Is there anybody can write script?
Good, go and play soldat ^^

Offline MrHamsTR

  • Soldier
  • **
  • Posts: 209
  • One day, everything will end..
Re: Hide and Seek Script, Some Problems
« Reply #18 on: January 06, 2013, 02:58:47 pm »
I want hiders be delta, not bravo or charlie, same as EU Hide and Seek; players in delta.
And I want counting down be seeing drawtext, not writing on console, players see that on his screen with red?
Is there anybody can write script?
Good, go and play soldat ^^

Offline MrHamsTR

  • Soldier
  • **
  • Posts: 209
  • One day, everything will end..
Re: Hide and Seek Script, Some Problems
« Reply #19 on: January 10, 2013, 03:24:32 pm »
I want hiders be delta, not bravo or charlie, same as EU Hide and Seek; players in delta.
And I want counting down be seeing drawtext, not writing on console, players see that on his screen with red?

LOL
Isn't there anybody can correct it to what I want?
Is there anybody can write script?
Good, go and play soldat ^^