Author Topic: Error when compiling  (Read 789 times)

0 Members and 1 Guest are viewing this topic.

Offline Slazenger

  • Soldier
  • **
  • Posts: 100
Error when compiling
« on: February 26, 2008, 08:51:25 am »
I have the following in Includes.txt
Code: [Select]
// All files specified below here will be
// compiled for use with any SoldatServer
// Scripts. Use // to mark a comment.
// Manual:
// http://enesce.com/help/

//SocketCore.pas
//NetworkCore.pas
//AdminCore.pas
admin.pas
//nextmapvote.pas
Medic.pas

and when I try to start the server it gives this error:
Code: [Select]
08-02-26 14:55:48  [*] default -> [Error] (171:3): Duplicate identifier ''What does it mean?

Here is my Medic.pas
Code: [Select]
const
  Color = $FFFFFFFF;
  MaxDist = 65;
  MaxHealth = 65;
  HealRate = 8;

var
  Medic: array[1..2] of byte;

procedure AppOnIdle(Ticks: integer);
var
  i,j: byte;
  X,Y: single;
begin
  for i := 1 to 2 do begin
    GetPlayerXY(Medic[i],X,Y);
    if Medic[i] <> 0 then if GetPlayerStat(Medic[i],'Alive') = true then for j := 1 to 32 do if (GetPlayerStat(j,'Active') = true) and (GetPlayerStat(j,'Alive') = true) and (GetPlayerStat(Medic[i],'Team') = GetPlayerStat(j,'Team')) and (Distance(X,Y,GetPlayerStat(j,'X'),GetPlayerStat(j,'Y')) <= MaxDist) and (GetPlayerStat(j,'Health') < MaxHealth) then begin
      if GetPlayerStat(j,'Health') + HealRate > MaxHealth then DoDamage(j,GetPlayerStat(j,'Health') - MaxHealth) else DoDamage(j,-HealRate);
    end;
  end;
end;

procedure OnJoinGame(ID, Team: byte);
begin
  if Medic[Team] = 0 then WriteConsole(ID,'Medic is up for grabs on your team. Type !medic to claim it.',Color);
end;

procedure OnJoinTeam(ID, Team: byte);
var
  OTeam: byte;
begin
  if Team = 1 then OTeam := 2 else OTeam := 1;
  if Medic[OTeam] = ID then begin
    Medic[OTeam] := 0;
    WriteConsole(0,'Medic for team #' + InttoStr(OTeam) + ' is up for grabs. Type !medic to claim it.',Color);
  end;
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
  if Medic[Team] = ID then begin
    Medic[Team] := 0;
    WriteConsole(0,'Medic for team #' + InttoStr(Team) + ' is up for grabs. Type !medic to claim it.',Color);
  end;
end;

procedure OnMapChange(NewMap: string);
var
  i: byte;
begin
  for i := 1 to 2 do Medic[i] := 0;
  WriteConsole(0,'Medic is now up for grabs for both teams. Type !medic to claim it.',Color);
end;

procedure OnPlayerSpeak(ID: byte; Text: string);
var
  Team: byte;
begin
  if (Text = '!medic') then begin
    Team := GetPlayerStat(ID,'Team');
    if Medic[Team] = 0 then begin
      Medic[Team] := ID;
      WriteConsole(ID,GetPlayerStat(ID,'Name') + ' has claimed medic for team #' + InttoStr(Team) + '.',Color);
    end else WriteConsole(ID,'Medic has already been claimed by ' + GetPlayerStat(Medic[Team],'Name') + '.',Color);
  end;
end;

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: Error when compiling
« Reply #1 on: February 26, 2008, 04:21:57 pm »
you're trying to declare an already declared function or var. Merge the two .pas files and put everything together properly. Or put them in two different scripts if they don't relate to each other

Offline Slazenger

  • Soldier
  • **
  • Posts: 100
Re: Error when compiling
« Reply #2 on: February 26, 2008, 04:53:32 pm »
you're trying to declare an already declared function or var. Merge the two .pas files and put everything together properly. Or put them in two different scripts if they don't relate to each other
That's the problem, I don't know how.

Offline rhide

  • Major
  • *
  • Posts: 60
  • Coffee-addict
    • Vrastar-Hai soldat clan
Re: Error when compiling
« Reply #3 on: February 29, 2008, 05:44:23 pm »
Well, just change the variable name in one of the scripts then... for example, use the name of the script file as prefix for all variables in your scripts (I think global variables should be enough though)
Warning! Division by zero seriously injures yourself and the people in your surroundings.

Proud member of Vrastar-Hai:
http://www.guldheden.com/~erga050/vrastar-hai