Author Topic: function GetTeamArray(const Team: byte): Array of byte;  (Read 1673 times)

0 Members and 1 Guest are viewing this topic.

Offline Swompie

  • Camper
  • ***
  • Posts: 390
function GetTeamArray(const Team: byte): Array of byte;
« on: April 18, 2010, 07:12:10 am »
Author: Ofc. me (Swompie)
Server/Core Version: 2.6.5+

Returns the players IDs of a team in an array of byte.

Code: (pascal) [Select]
function GetTeamArray(const Team: byte): Array of byte;
var i, x: integer;
begin
  i := 1;
  x := 0;
  while i < 32 do begin
    if GetPlayerStat(i, 'Active') = true then
      if GetPlayerStat(i, 'Team') = Team then begin
        SetArrayLength(Result, x + 1);
        Result[x] := i;
        x := x + 1;
      end;
    i := i + 1;
  end;
end;
« Last Edit: August 04, 2010, 03:15:33 am by Swompie »

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: function GetTeamArray(const Team: byte): Array of byte;
« Reply #1 on: April 27, 2010, 01:35:18 pm »
Lol.. You like.. Totally copied me :O

Code: (pascal) [Select]
//Custom Functions
//By Squiddy ~ And HackTank
//Thanks, Hack! Helped a loooooot! :D

Function IDByTeam(Team: Byte): Array of Byte;
 Var S, Len: Byte;
  Begin
   SetArrayLength(Result,0);
    For S := 1 To 32 Do if GetPlayerStat(S,'Active') = True Then if GetPlayerStat(S,'Team') = Team Then Begin
    Len := GetArrayLength(Result);
   SetArrayLength(Result, Len + 1);
  Result[Len] := S;
 end;
end;
www.soldatx.com.br - The brazilian Soldat community.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: function GetTeamArray(const Team: byte): Array of byte;
« Reply #2 on: April 27, 2010, 01:41:02 pm »
Hehe such a simple script, it was bound more than one person made it. I think I even made it once time in my history of scripting. Probably long lost now though xD

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: function GetTeamArray(const Team: byte): Array of byte;
« Reply #3 on: August 04, 2010, 03:13:03 am »
Hehe such a simple script, it was bound more than one person made it. I think I even made it once time in my history of scripting. Probably long lost now though xD
Well, I was abit bored so I made this, I was sure such a thing has been done long time ago already, but maybe not as good as this >_>
Maybe someone will need it somwhere sometime (some-words ftw ;P)

Btw. Squiddy, my script looks moar coowl!  ;D



A small update:
Removed the GetArrayLength(Result) and replaced it with the variable x which already holds the array length and changed two other small things.
« Last Edit: August 04, 2010, 03:16:17 am by Swompie »