Author Topic: Team-Related Functions/Script  (Read 1845 times)

0 Members and 1 Guest are viewing this topic.

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Team-Related Functions/Script
« on: May 01, 2010, 10:55:39 am »
Script Name: Team-Related Funcs-Script
Script Description Team Related Functions Script Made By Squiddy And HackTank
Author: Squiddy
Compile Test: Passed
Core Version: 2.6.5
Hosted by: Soldat Central - http://soldatcentral.com/

Full Description:
This Script has 5 Custom-Functions that Squiddy and HackTank
created.

With GetTeamPlayers(), you can see how many players there are in
a team. Usage: /getplayers <Team>

With IDByTeam(), you can get everyone's ID in a team.

With NamesByTeam(), you can get everyone's names in a team.
Usage: /getnames <Team>

With InvertTeams(), you can invert two teams. Usage: /invert
<Team1> <Team2>

With TeamNameByID(), you can get a team name by it's ID.

Everything created by:
Squiddy~ [Brazil];
HackTank [United States of America].

Thanks Hack! Helped a lot!

If you're going to use it, then credit it.


//~~~~~~~~~~~~~~~~~~


UPDATE!!

02/05/2010 ~~ Fixed Functions:
~ Active();
~ GetTeamPlayers();

~~Thanks to: Gizd, and the guys who helped :)



(Size 1.47 KB)
- http://soldatcentral.com/index.php?page=script&f=190 -


** Script hosted by Soldat Central! Please visit the author's script page and Rate this script **
« Last Edit: May 02, 2010, 08:04:16 pm by squiddy »
www.soldatx.com.br - The brazilian Soldat community.

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Team-Related Functions/Script
« Reply #1 on: May 01, 2010, 02:49:01 pm »
You share those credits like you've created an epic function only 0.00001% of population could make.

Offline freestyler

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 326
Re: Team-Related Functions/Script
« Reply #2 on: May 01, 2010, 05:22:56 pm »
Code: [Select]
Function Active(ID: Byte): Boolean; //Checks if Player is active, it's just faster than GetPlayerStat().
 Begin
  Result := False;
 if GetPlayerStat(ID,'Active') = True Then Result := True;
end;
How is this faster than GetPlayerStat? You use less time typing it? This uses server's memory for nothing (I know the difference is tiny, but still - what is the point of making shorter commands if the length of name of function doesn't matter for the script engine?).

Quote
With GetTeamPlayers(), you can see how many players there are in
a team. Usage: /getplayers <Team>
How about DeathmatchPlayers, AlphaPlayers, BravoPlayers, CharliePlayers, DeltaPlayers and Spectators (built-in variables)? This one is useless. You could change the whole 32-iterations loop into one case Team of (0 to 5).

For booleans, you don't need to compare them to another boolean, so instead of if A = true then you can use if A then (the first one is equal to if true = true then). Use if not A then instead of if A = false then.

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Team-Related Functions/Script
« Reply #3 on: May 02, 2010, 01:02:59 am »
Quote
if GetPlayerStat(ID,'Active') = True Then Result := True;

Result := GetPlayerStat(ID,'Active');

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Team-Related Functions/Script
« Reply #4 on: May 02, 2010, 10:45:41 am »
In regards to the Active function:
Sometimes you need to convert a variant into the appropriate type (for instance you cannot simply do if (GetPlayerStat(Id, 'Active'), you must have = true, which I would guess forces it to implicitly convert into a boolean). I think it should be slightly slower though if using this function, since it has to go through another function, but I cannot say with certainty without some data.

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Team-Related Functions/Script
« Reply #5 on: May 02, 2010, 11:18:34 am »
Quote
In regards to the Active function:
[...]

I just put it in 'coz its faster to type.

In regards to the other answers:

I don't really care. Does the same thing. What you all typed is just to make it prettier. It's not like it's gonna mess the whole Script up.

Quote
How about DeathmatchPlayers, AlphaPlayers, BravoPlayers, CharliePlayers, DeltaPlayers and Spectators (built-in variables)? This one is useless. You could change the whole 32-iterations loop into one case Team of (0 to 5).

Do GetTeamPlayers(0) to see if it doesn't return how many players have no team.

GetTeamPlayers(0) returns all players that doesn't have a team.
GetTeamPlayers(1) returns all players in Alpha Team.
GetTeamPlayers(2) returns all players in Bravo Team.
GetTeamPlayers(3) returns all players in Charlie Team.
GetTeamPlayers(4) returns all players in Delta Team.
GetTeamPlayers(5) returns all players in Spectator Group.

If you wanna prove it, go "/addbot0 Kruger", and then "/getplayers 0"..

It doesn't need Case of.
www.soldatx.com.br - The brazilian Soldat community.

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Team-Related Functions/Script
« Reply #6 on: May 02, 2010, 03:19:12 pm »
Do GetTeamPlayers(0) to see if it doesn't return how many players have no team.

GetTeamPlayers(0) returns all players that doesn't have a team.
GetTeamPlayers(1) returns all players in Alpha Team.
GetTeamPlayers(2) returns all players in Bravo Team.
GetTeamPlayers(3) returns all players in Charlie Team.
GetTeamPlayers(4) returns all players in Delta Team.
GetTeamPlayers(5) returns all players in Spectator Group.

If you wanna prove it, go "/addbot0 Kruger", and then "/getplayers 0"..

It doesn't need Case of.
Code: [Select]
case Team of
  0: result:= DeathmatchPlayers;
  1: result:= AlphaPlayers;
  2: result:= BravoPlayers;
  3: result:= CharliePlayers;
  4: result:= DeltaPlayers;
  5: result:= Spectators;
end;

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Team-Related Functions/Script
« Reply #7 on: May 02, 2010, 03:38:50 pm »
Quote
I don't really care. Does the same thing.
Wrong. Script should be done in the fastest and most efficient way.

Quote
It doesn't need Case of.
Gizd's method using case of is waaaay faster than your.
« Last Edit: May 02, 2010, 03:42:44 pm by tk »

Offline freestyler

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 326
Re: Team-Related Functions/Script
« Reply #8 on: May 02, 2010, 07:12:16 pm »
That's exactly what I was talking about. Apply this and delete that Active(ID) function and it'll be okay. ;)

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Team-Related Functions/Script
« Reply #9 on: May 02, 2010, 08:00:03 pm »
That's exactly what I was talking about. Apply this and delete that Active(ID) function and it'll be okay. ;)

Yes, Sir!

Updated (02/05/2010).
www.soldatx.com.br - The brazilian Soldat community.