Smartzkid
04-19-2011, 02:30 AM
Here's a small include to help organize your players into groups.
Features:
Quickly organize players into different groups
Specify values for players[ ].integers[ ], .booleans[ ], .strings[ ]
Values for the above fields can be set for an entire group or individually (individual settings override script settings)
Never have to write another DeclarePlayers!
To add it to a script, include groups.simba, then go to the built in DeclarePlayers and remove HowManyPlayers, NumberOfPlayers(), and Players[ ].____ and add thisScript := 'GroupName'; and SmartzDeclarePlayers;
It reads configuration information from const accountFile; here's a sample config:
; Players section
[Villavu]
name = Villavu
pass = SimbaIsCool
nick = lla
[Player2IsCool]
name = Player2 Is Cool
pass = OhYeahhh
nick = lay
pin = 2345
Integers5 = 40
Integers6 = 99
Integers7 = 1
; Groups section
[Ratinator1]
0 = Villavu
1 = Player2IsCool
Integers2 = 20
Integers5 = 40
Integers6 = 99
Integers14 = 15
Integers15 = 6
Booleans0 = True
Booleans1 = True
groups.simba
const accountFile = 'Drive:\Path\To\Config.ini';
var
thisScript: string;
function INI(section: string; key: string): string;
begin
result := ReadINI(section, key, accountFile);
end;
procedure SmartzDeclarePlayers;
var
i_AssignedPlayerCount: integer;
s_setting: string;
i, j: integer;
playerName: string;
begin
while(not(INI(thisScript, IntToStr(i_AssignedPlayerCount)) = '')) do
i_AssignedPlayerCount := i_AssignedPlayerCount + 1;
HowManyPlayers := i_AssignedPlayerCount;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
for i := 0 to i_AssignedPlayerCount - 1 do
begin
playerName := INI(thisScript, IntToStr(i));
with Players[i] do
begin
//Set login details
Name := INI(playerName, 'name');
Pass := INI(playerName, 'pass');
Nick := INI(playerName, 'nick');
pin := INI(playerName, 'pin');
Active := true;
//Set Integers
for j := 0 to 15 do
begin
s_setting := INI(playerName, 'Integers' + IntToStr(j));
if(not(s_setting = '')) then
begin
Integers[j] := StrToInt(s_setting);
end else
begin
s_setting := INI(thisScript, 'Integers' + IntToStr(j));
if(not(s_setting = '')) then
Integers[j] := StrToInt(s_setting);
end;
end;
//Set booleans
for j := 0 to 15 do
begin
s_setting := INI(playerName, 'Booleans' + IntToStr(j));
if(not(s_setting = '')) then
begin
Booleans[j] := StrToBool(s_setting);
end else
begin
s_setting := INI(thisScript, 'Booleans' + IntToStr(j));
if(not(s_setting = '')) then
Booleans[j] := StrToBool(s_setting);
end;
end;
//Set strings
for j := 0 to 15 do
begin
s_setting := INI(playerName, 'Strings' + IntToStr(j));
if(not(s_setting = '')) then
begin
Strings[j] := s_setting;
end else
begin
s_setting := INI(thisScript, 'Strings' + IntToStr(j));
if(not(s_setting = '')) then
Strings[j] := s_setting;
end;
end;
end;
end;
writeln('Declared ' + IntToStr(HowManyPlayers) + ' players.');
if(HowManyPlayers = 0) then
begin
writeln('No players defined, terminating script');
TerminateScript;
end;
end;
Features:
Quickly organize players into different groups
Specify values for players[ ].integers[ ], .booleans[ ], .strings[ ]
Values for the above fields can be set for an entire group or individually (individual settings override script settings)
Never have to write another DeclarePlayers!
To add it to a script, include groups.simba, then go to the built in DeclarePlayers and remove HowManyPlayers, NumberOfPlayers(), and Players[ ].____ and add thisScript := 'GroupName'; and SmartzDeclarePlayers;
It reads configuration information from const accountFile; here's a sample config:
; Players section
[Villavu]
name = Villavu
pass = SimbaIsCool
nick = lla
[Player2IsCool]
name = Player2 Is Cool
pass = OhYeahhh
nick = lay
pin = 2345
Integers5 = 40
Integers6 = 99
Integers7 = 1
; Groups section
[Ratinator1]
0 = Villavu
1 = Player2IsCool
Integers2 = 20
Integers5 = 40
Integers6 = 99
Integers14 = 15
Integers15 = 6
Booleans0 = True
Booleans1 = True
groups.simba
const accountFile = 'Drive:\Path\To\Config.ini';
var
thisScript: string;
function INI(section: string; key: string): string;
begin
result := ReadINI(section, key, accountFile);
end;
procedure SmartzDeclarePlayers;
var
i_AssignedPlayerCount: integer;
s_setting: string;
i, j: integer;
playerName: string;
begin
while(not(INI(thisScript, IntToStr(i_AssignedPlayerCount)) = '')) do
i_AssignedPlayerCount := i_AssignedPlayerCount + 1;
HowManyPlayers := i_AssignedPlayerCount;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
for i := 0 to i_AssignedPlayerCount - 1 do
begin
playerName := INI(thisScript, IntToStr(i));
with Players[i] do
begin
//Set login details
Name := INI(playerName, 'name');
Pass := INI(playerName, 'pass');
Nick := INI(playerName, 'nick');
pin := INI(playerName, 'pin');
Active := true;
//Set Integers
for j := 0 to 15 do
begin
s_setting := INI(playerName, 'Integers' + IntToStr(j));
if(not(s_setting = '')) then
begin
Integers[j] := StrToInt(s_setting);
end else
begin
s_setting := INI(thisScript, 'Integers' + IntToStr(j));
if(not(s_setting = '')) then
Integers[j] := StrToInt(s_setting);
end;
end;
//Set booleans
for j := 0 to 15 do
begin
s_setting := INI(playerName, 'Booleans' + IntToStr(j));
if(not(s_setting = '')) then
begin
Booleans[j] := StrToBool(s_setting);
end else
begin
s_setting := INI(thisScript, 'Booleans' + IntToStr(j));
if(not(s_setting = '')) then
Booleans[j] := StrToBool(s_setting);
end;
end;
//Set strings
for j := 0 to 15 do
begin
s_setting := INI(playerName, 'Strings' + IntToStr(j));
if(not(s_setting = '')) then
begin
Strings[j] := s_setting;
end else
begin
s_setting := INI(thisScript, 'Strings' + IntToStr(j));
if(not(s_setting = '')) then
Strings[j] := s_setting;
end;
end;
end;
end;
writeln('Declared ' + IntToStr(HowManyPlayers) + ' players.');
if(HowManyPlayers = 0) then
begin
writeln('No players defined, terminating script');
TerminateScript;
end;
end;