Author Topic: Problem with a small script  (Read 1087 times)

0 Members and 1 Guest are viewing this topic.

Offline Corsair

  • Major(1)
  • Posts: 12
Problem with a small script
« on: November 06, 2007, 04:58:05 pm »
The problem is somewhere here:
Code: [Select]
var
bots: array[1..16] of string;
autobot: boolean;

const
numbots = 1; //Number of bots to join
maxp = 4; //Maximum number of players (inc bot) for a bot to be kicked
minp = 2; //Minumum number of players for a bot to be added

autobot := true; //Bot auto-joining on/off

bots[1] := 'Admiral';
bots[2] := 'Billy';
bots[3] := 'Blain';
bots[4] := 'Boogie Man';
bots[5] := 'Commando';
bots[6] := 'D Dave';
bots[7] := 'Danko';
bots[8] := 'Dutch';
bots[9] := 'John';
bots[10] := 'Kruger';
bots[11] := 'Poncho';
bots[12] := 'Roach';
bots[13] := 'Sgt. Mac';
bots[14] := 'Sniper';
bots[15] := 'Stevie';
bots[16] := 'Terminator';

I'm getting and error saying that there's a duplicate identifier '' and since i'm not that good at pascal at all i'm hoping you'll help me with this...

If you need the rest of the script:
Code: [Select]
procedure ActivateServer();
var i: integer;
begin
for i := 1 to numbots do begin
Command('/addbot ' + bots[i]);
end;
end;

procedure AppOnIdle(Ticks: integer);
var i: integer;
begin
//Check for num players then add or remove bot
if autobot = true then begin
if Ticks mod (30 * 60) = 0 then begin
if ((NumPlayers >= maxp) and (NumBots >= numbots)) then begin
for i := 1 to numbots do begin
Command('/kick ' + bots[i]);
end;
end;
if ((NumPlayers <= minp) and (NumBots = 0)) then begin
for i := 1 to numbots do begin
Command('/addbot ' + bots[i]);
end;
end;
end;
end;
end;

//if GetPiece(Text, ' ', 2) = CurrentMap then

function OnCommand(ID: Byte; Text: string): boolean;
begin
  if Text = '/autobot' then begin
if autobot = true then begin
SayToPlayer(ID, '[*] Bot auto-joining is ON.');
end
else begin
SayToPlayer(ID, '[*] Bot auto-joining is OFF.');
end;
  end; 
 
  if (GetPiece(Text, ' ', 2) = 'on') or (GetPiece(Text, ' ', 2) = '1') then begin
autobot := true;
SayToPlayer(ID, '[*] Bot auto-joining turned ON.');
  end;
 
  if (GetPiece(Text, ' ', 2) = 'off') or (GetPiece(Text, ' ', 2) = '0') then begin
autobot := false;
SayToPlayer(ID, '[*] Bot auto-joining turned OFF.');
  end;
  //NOTE: This function will be called when an admin types a / command.
  Result := false; // Return true if you want to ignore the command typed.
end;

PS: I know that there will be some miscalculations on the way, but i'm working on it :)))

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Problem with a small script
« Reply #1 on: November 06, 2007, 05:23:05 pm »
Code: [Select]
autobot := true; //Bot auto-joining on/off

bots[1] := 'Admiral';
bots[2] := 'Billy';
bots[3] := 'Blain';
bots[4] := 'Boogie Man';
bots[5] := 'Commando';
bots[6] := 'D Dave';
bots[7] := 'Danko';
bots[8] := 'Dutch';
bots[9] := 'John';
bots[10] := 'Kruger';
bots[11] := 'Poncho';
bots[12] := 'Roach';
bots[13] := 'Sgt. Mac';
bots[14] := 'Sniper';
bots[15] := 'Stevie';
bots[16] := 'Terminator';
should be under ActivateServer

Offline Corsair

  • Major(1)
  • Posts: 12
Re: Problem with a small script
« Reply #2 on: November 06, 2007, 06:20:17 pm »
Nope, still getting
Code: [Select]
[*] BotJoin -> [Error] (7:1): Duplicate identifier ''

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Problem with a small script
« Reply #3 on: November 06, 2007, 07:36:09 pm »
Could you paste the script word for word all in one go?

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: Problem with a small script
« Reply #4 on: November 06, 2007, 07:46:11 pm »
Code: [Select]
const
totalBots = 1; //Number of bots to join
maxp = 4; //Maximum number of players (inc bot) for a bot to be kicked
minp = 2; //Minumum number of players for a bot to be added

var
bots: array[1..16] of string;
autobot: boolean;

procedure ActivateServer();
var
i: integer;
begin
autobot := true; //Bot auto-joining on/off
bots[1] := 'Admiral';
bots[2] := 'Billy';
bots[3] := 'Blain';
bots[4] := 'Boogie Man';
bots[5] := 'Commando';
bots[6] := 'D Dave';
bots[7] := 'Danko';
bots[8] := 'Dutch';
bots[9] := 'John';
bots[10] := 'Kruger';
bots[11] := 'Poncho';
bots[12] := 'Roach';
bots[13] := 'Sgt. Mac';
bots[14] := 'Sniper';
bots[15] := 'Stevie';
bots[16] := 'Terminator';

for i := 1 to totalBots do
begin
Command('/addbot ' + bots[i]);
end
end;

procedure AppOnIdle(Ticks: integer);
var
i: integer;
begin
//Check for num players then add or remove bot
if autobot = true then
begin
if Ticks mod (30 * 60) = 0 then
begin
if ((NumPlayers >= maxp) and (totalBots >= totalBots)) then
begin
for i := 1 to totalBots do
begin
Command('/kick ' + bots[i]);
end
end

if ((NumPlayers <= minp) and (totalBots = 0)) then
begin
for i := 1 to numbots do
begin
Command('/addbot ' + bots[i]);
end
end
end
end
end;

function OnCommand(ID: Byte; Text: string): boolean;
begin
if Text = '/autobot' then
begin
if autobot = true then
begin
SayToPlayer(ID, '[*] Bot auto-joining is ON.');
end else
begin
SayToPlayer(ID, '[*] Bot auto-joining is OFF.');
end
  end
 
if (GetPiece(Text, ' ', 2) = 'on') or (GetPiece(Text, ' ', 2) = '1') then
begin
autobot := true;
SayToPlayer(ID, '[*] Bot auto-joining turned ON.');
end
 
if (GetPiece(Text, ' ', 2) = 'off') or (GetPiece(Text, ' ', 2) = '0') then
begin
autobot := false;
SayToPlayer(ID, '[*] Bot auto-joining turned OFF.');
end
//NOTE: This function will be called when an admin types a / command.
  Result := false; // Return true if you want to ignore the command typed.
end;


NumBots was already used
http://enesce.com/help/index.html?Variables/NumBots.html

the rest was ok i think didn't test if the commands work tho.
its compiles ;)
« Last Edit: November 06, 2007, 07:48:17 pm by spkka »

Offline Corsair

  • Major(1)
  • Posts: 12
Re: Problem with a small script
« Reply #5 on: November 07, 2007, 02:02:23 am »
Thanks, added some small fixes, everything compiles, now have to add a fire checks so that the server won't we filled with one-named bots and add one bot-at-a-time kicking :))

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: Problem with a small script
« Reply #6 on: November 07, 2007, 02:18:34 pm »
Glad it works! Good luck with it