Author Topic: Enemy Team Count - useful R/S script  (Read 3408 times)

0 Members and 1 Guest are viewing this topic.

Offline Avarax

  • Veteran
  • *****
  • Posts: 1529
    • Official Hexer & MMod site
Enemy Team Count - useful R/S script
« on: January 11, 2009, 06:15:28 pm »
Script Name: Enemy Team Count
Script Description: Displays number of alive enemies on the screen.
Original Author(s): Avarax
Core Version: 2.6.3
Code:



Code: [Select]
//Enemy count display script by Avarax.

const
  DefaultColor = $CFFF00;
  DefaultX = 40;
  DefaultY = 380;
 
type
  tPlayer = record
              X,Y: integer;
              Color: longint;
              Display,cd: boolean;
            end;

var
  Active,Alive: array[1..2] of byte;
  player: array[1..32] of tPlayer;

procedure OnJoinTeam(ID, Team: byte);
begin
  WriteConsole(ID,'This server uses Ava''s enemy count display script.',DefaultColor);
  WriteConsole(ID,'To display commands, use /cmd.',DefaultColor);
end;

procedure ActivateServer();
var i: byte;
begin
  for i:=1 to 32 do begin
    player[i].color:=DefaultColor;
    player[i].X:=DefaultX;
    player[i].Y:=DefaultY;
    player[i].display:=true;
    player[i].cd:=true;
  end;
end;

procedure CountPlayers();
var i: byte;
begin
  Active[1]:=0;
  Alive[1]:=0;
  Active[2]:=0;
  Alive[2]:=0;
  for i:=1 to 32 do begin
    If GetPlayerStat(i,'Active') = true then
      case GetPlayerStat(i,'Team') of
        1: begin Active[1]:=Active[1]+1; If GetPlayerStat(i,'Alive') = true then Alive[1]:=Alive[1]+1; end;
        2: begin Active[2]:=Active[2]+1; If GetPlayerStat(i,'Alive') = true then Alive[2]:=Alive[2]+1; end;
      end;
  end;
end;

procedure DisplayPlayers();
var i: byte;
begin
  for i:=1 to 32 do
    If (GetPlayerStat(i,'Active') = true) and (player[i].display = true) then begin
      If player[i].cd then
        player[i].cd:=false
      else
        case GetPlayerStat(i,'Team') of
          1: DrawText(i,'Bravo: ' + inttostr(Alive[2]) + '/' + inttostr(Active[2]),200,player[i].color,0.08,player[i].X,player[i].Y);
          2: DrawText(i,'Alpha: ' + inttostr(Alive[1]) + '/' + inttostr(Active[1]),200,player[i].color,0.08,player[i].X,player[i].Y);
        end;
    end;
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
    inc(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;
end;

procedure AppOnIdle(Ticks: integer);
begin
  CountPlayers;
  DisplayPlayers;
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
var temp: TStringArray;
    color: array[1..3] of integer;
begin
  case lowercase(copy(text,1,4)) of
    '/cmd': begin
              WriteConsole(ID,'.------------Enemy count script commands------------.',player[ID].color);
              WriteConsole(ID,'| /cmd     : Shows these commands                   |',player[ID].color);
              WriteConsole(ID,'| /posx #  : Sets X position for msgs to #          |',player[ID].color);
              WriteConsole(ID,'| /posy #  : Sets Y position for msgs to #          |',player[ID].color);
              WriteConsole(ID,'| /cl R G B: Sets red, green & blue values for msgs |',player[ID].color);
              WriteConsole(ID,'| /display : Dis/Enables msgs (default = on)        |',player[ID].color);
              WriteConsole(ID,'''-----------------Script by Avarax------------------''',player[ID].color);     
            end;
    '/dis': case player[ID].display of
              true: begin player[ID].display:=false; WriteConsole(ID,'Enemy count message is now disabled.',player[ID].color); end;
              false:begin player[ID].display:=true; WriteConsole(ID,'Enemy count message is now enabled.',player[ID].color); end;
            end;
    '/cl ': begin
              temp:=xsplit(text,' ');
              case GetArrayLength(temp) of
                1: WriteConsole(ID,'Red, green & blue values missing (0-255)',player[ID].color);
                2: WriteConsole(ID,'Green & blue values missing (0-255)',player[ID].color);
                3: WriteConsole(ID,'Blue value missing (0-255)',player[ID].color);
                4: begin
                     try
                       color[1]:=strtoint(temp[1]);
                       If (color[1] < 0) or (color[1] > 255) then begin
                         WriteConsole(ID,'Color values must be numbers between 0 and 255',$FF0000)
                         exit;
                       end
                       else
                         WriteConsole(ID,'New red value: ' + inttostr(color[1]),$FF0000);
                       color[2]:=strtoint(temp[2]);
                       If (color[2] < 0) or (color[2] > 255) then begin
                         WriteConsole(ID,'Color values must be numbers between 0 and 255',$00FF00)
                         exit;
                       end
                       else
                         WriteConsole(ID,'New green value: ' + inttostr(color[2]),$00FF00);
                       color[3]:=strtoint(temp[3]);
                       If (color[3] < 0) or (color[3] > 255) then begin
                         WriteConsole(ID,'Color values must be numbers between 0 and 255',$0000FF)
                         exit;
                       end
                       else
                         WriteConsole(ID,'New blue value: ' + inttostr(color[3]),$0000FF);
                       player[ID].color:=RGB(color[1],color[2],color[3]);
                       WriteConsole(ID,'YOUR NEW COLOR.',player[ID].color);
                     except
                       WriteConsole(ID,'Color values must be numbers between 0 and 255',player[ID].color);
                     end;
                   end;
              end;
            end;
    '/pos':begin
            temp:=xsplit(lowercase(text),' ');
            case temp[0] of
              '/posx':try
                        player[ID].X:=strtoint(temp[1]);
                        WriteConsole(ID,'New coordinates: ' + inttostr(player[ID].X) + '|' + inttostr(player[ID].Y),player[ID].color);
                      except
                        WriteConsole(ID,'Please use numbers as X/Y values',player[ID].color);
                      end;
              '/posy':try
                        player[ID].Y:=strtoint(temp[1]);
                        WriteConsole(ID,'New coordinates: ' + inttostr(player[ID].X) + '|' + inttostr(player[ID].Y),player[ID].color);
                      except
                        WriteConsole(ID,'Please use numbers as X/Y values',player[ID].color);
                      end;
            end;
          end;
  end;
  result:=false;
end;

procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
  player[Killer].cd:=true;
  player[Victim].cd:=true;
end;


Commands:
/cmd: Displays commands
/display: Dis- or enables the on screen message
/cl R G B: Sets RGB values for the on screen message
/posx: Sets X coordinate for on screen message
/posy: Sets Y coordinate for on screen message

Feel free to use the message configurating commands in your own scripts.
I like to have one Martini
Two at the very most
Three I'm under the table
Four I'm under the host

Offline Krack

  • Soldier
  • **
  • Posts: 105
  • Krack Kills
Re: Enemy Team Count - useful R/S script
« Reply #1 on: January 11, 2009, 06:21:56 pm »
Good "Nice To Have" thing.

Good work.
Viva Soldat

Offline ZomgProniss

  • Camper
  • ***
  • Posts: 318
  • Known ingame as Proniss
Re: Enemy Team Count - useful R/S script
« Reply #2 on: January 11, 2009, 06:23:46 pm »
i would get it but idk how to put it into my games =\

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Enemy Team Count - useful R/S script
« Reply #3 on: January 11, 2009, 09:39:48 pm »
Nice job, the setting of the pos reminds me of my cs script, had something just like that :P
i would get it but idk how to put it into my games =\
its a server-side script

Offline Bolt

  • Major
  • *
  • Posts: 64
  • {MLP}
    • http://www.darkdemon.org/bolt/
Re: Enemy Team Count - useful R/S script
« Reply #4 on: January 12, 2009, 05:16:48 am »
Very nice idea, it's be great to see some of the popular R/S servers using this.

Offline PKS|Shooter

  • Soldier
  • **
  • Posts: 130
  • Dont fuck with us!
    • PKS - La Familia
Re: Enemy Team Count - useful R/S script
« Reply #5 on: January 12, 2009, 02:35:29 pm »
MY Idea ;D ty ava

Offline ZomgProniss

  • Camper
  • ***
  • Posts: 318
  • Known ingame as Proniss
Re: Enemy Team Count - useful R/S script
« Reply #6 on: January 12, 2009, 02:51:26 pm »
Nice job, the setting of the pos reminds me of my cs script, had something just like that :P
i would get it but idk how to put it into my games =\
its a server-side script
sorry but i dont really know any thing about scripting


and hey does this work in dm and/or tdm?

Offline Vyka

  • Major
  • *
  • Posts: 59
Re: Enemy Team Count - useful R/S script
« Reply #7 on: January 13, 2009, 04:10:42 pm »
you can't put it to "game". (i mean game with bots, non with ppl on server)

Avarax wrote it, now, somebody from server staff can install it (ofc. on server). If script is installed, you can use it, just read main post.

Offline rayanaga

  • Soldier
  • **
  • Posts: 143
  • ~Fur flying~
    • Kryonex
Re: Enemy Team Count - useful R/S script
« Reply #8 on: January 15, 2009, 03:31:17 pm »
Sure beats having that little console line that says how many players are left.

Good job ava.
[kY] Kryonex - Your local zombie fanatics.
http://www.kryonex.com/

Offline PKS|Shooter

  • Soldier
  • **
  • Posts: 130
  • Dont fuck with us!
    • PKS - La Familia
Re: Enemy Team Count - useful R/S script
« Reply #9 on: January 18, 2009, 01:19:05 am »
ehm ava? i have some problem



my server(s) runs under ubuntu.

Offline Avarax

  • Veteran
  • *****
  • Posts: 1529
    • Official Hexer & MMod site
Re: Enemy Team Count - useful R/S script
« Reply #10 on: January 19, 2009, 06:46:06 am »
Did that happen multiple times? Does it happen under a certain occasion?
I like to have one Martini
Two at the very most
Three I'm under the table
Four I'm under the host

Offline PKS|Shooter

  • Soldier
  • **
  • Posts: 130
  • Dont fuck with us!
    • PKS - La Familia
Re: Enemy Team Count - useful R/S script
« Reply #11 on: January 21, 2009, 12:16:14 pm »
like all 1 hour or so there is a msg like your scripts crashed please contact an admin. the scripts are going to recompile or sth like that

Offline Mr

  • Inactive Soldat Developer
  • Soldier
  • ******
  • Posts: 166
Re: Enemy Team Count - useful R/S script
« Reply #12 on: January 25, 2009, 06:51:25 am »
The scriptcore sometimes leaks memory, and you don't have enough. Shut down other applications which need much memory, but are not used, and the problem should be solved.