Author Topic: Errors  (Read 5584 times)

0 Members and 1 Guest are viewing this topic.

Offline Leo

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1011
Errors
« on: November 08, 2006, 02:07:04 am »
Ok, I am trying but I get some errors. I am doing something wrong but what ? For example:

06-11-08 08:04:48 
  • Compiling Script Core.pas...

06-11-08 08:04:48 
  • Compiling Script mapsList.pas...

06-11-08 08:04:48 
  • Compiling Script upTime.pas...

06-11-08 08:04:48 
  • [Error] (74:11): Duplicate identifier 'ONPLAYERSPEAK'

06-11-08 08:04:48 
  • Exception raised on SetVariables(Access violation at address 0808A241, accessing address 00000000)

06-11-08 08:04:48 
  • Run-time error (ActivateServer ""): No Error


I get these "Dublicate identifier" errors whenever another script trys to compile.

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: Errors
« Reply #1 on: November 08, 2006, 02:18:24 am »
Your doing it MEGA wrong... You cant just copy posted scripts and wack em into your includes file, you need to combine them into NetworkCore.pas or Core.pas....

Offline Leo

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1011
Re: Errors
« Reply #2 on: November 08, 2006, 02:42:39 am »
06-11-08 08:38:40 
  • (Core.pas) [Error] (34:46): Unknown identifier 'formatTime'

Where I put this function ?

Offline chrisgbk

  • Moderator
  • Veteran
  • *****
  • Posts: 1739
Re: Errors
« Reply #3 on: November 08, 2006, 03:00:28 am »
Which scripts are you trying to combine? List them here, and I'll show you how to combine them properly.

Offline Leo

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1011
Re: Errors
« Reply #4 on: November 08, 2006, 03:03:58 am »
wow! I managed to make the uptime script to work, I am a scripting God I tell you! :P

Offline chrisgbk

  • Moderator
  • Veteran
  • *****
  • Posts: 1739
Re: Errors
« Reply #5 on: November 08, 2006, 03:12:22 am »
I take it you solved your problems?

Offline Leo

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1011
Re: Errors
« Reply #6 on: November 08, 2006, 03:16:18 am »
Well, actually it worked for one script but when I tried to add another it was a mess.

Offline chrisgbk

  • Moderator
  • Veteran
  • *****
  • Posts: 1739
Re: Errors
« Reply #7 on: November 08, 2006, 03:18:42 am »
Combining scripts isn't easy for someone inexperienced to carry out. If you list which scripts you want to run, I can show you how to combine them properly so they work without problems.

Offline Leo

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1011
Re: Errors
« Reply #8 on: November 08, 2006, 03:22:48 am »
For a start I would like the upTime script and the joinFloodTrace script. If you show me one time I may learn how to do it myself. Thanks  :)

Offline chrisgbk

  • Moderator
  • Veteran
  • *****
  • Posts: 1739
Re: Errors
« Reply #9 on: November 08, 2006, 04:25:15 am »
Code: [Select]
const
  ADMIN_UPTIME_ON=1; //turns off/on /uptime script
  PLAYER_UPTIME_ON=1; //turns off/on !uptime script
  REDUCE = 6;    //second after flooders stats are updated, higher value - bans slower
  LIMIT = 3;       //amount of game join/leaves till ban, lower value - bans faster
  BANTIME = 60; //in minutes

var
  up: integer;
  flooderID: array[1..32] of integer;
  i: integer;


procedure ActivateServer();
begin
  up:=0;
  for i:= 1 to 32 do flooderID[i]:=0; //are they initialized with zeros anyway?
end;

procedure AppOnIdle(Ticks: integer);
begin
  up:=up+1;
  for i:=1 to 32 do begin
    if flooderID[i]>LIMIT then begin
      BanPlayer(i,BANTIME);
      flooderID[i]:=0;
    end;
  end;

  if Ticks mod (60*REDUCE) = 0 then begin
    for i:=1 to 32 do if flooderID[i]>0 then flooderID[i]:= flooderID[i]-1;
  end;

end;

function formatTime():string;
var d,h,m,s: integer;
begin
  d:= up/86400;
  h:= up/3600 mod 24;
  m:= up/60 mod 60;
  s:= up mod 60;

  if((d=0) and (h=0)) then begin result:=inttostr(m)+'m:'+inttostr(s)+'s'; end
    else if d=0 then begin result:=inttostr(h)+'h:'+inttostr(m)+'m:'+inttostr(s)+'s'; end
      else result:=inttostr(d)+'d:'+inttostr(h)+'h:'+inttostr(m)+'m:'+inttostr(s)+'s';
end;

procedure OnPlayerSpeak(Name,Text: string);
begin
if((Text='!uptime')and(PLAYER_UPTIME_ON=1)) then begin
   saytoplayer(NametoID(Name),'server is running for: '+formatTime());
end;
end;

procedure OnCommand(ID: integer;Text: string);
begin
  if((Text='/uptime')and(ADMIN_UPTIME_ON=1)) then begin
    saytoplayer(ID,'server is running for: '+formatTime());
  end;
end;

procedure OnJoinTeam(IP, Nickname: string;Team: byte);
begin
  flooderID[NameToID(Nickname)]:= flooderID[NameToID(Nickname)]+1; //where's my i++ ;p
end;

I haven't tested it, but it's essentially copy paste so it should work, and it at least gives you the proper idea of how to go about it.

Offline Leo

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1011
Re: Errors
« Reply #10 on: November 08, 2006, 04:31:23 am »
Copy and paste where ? Replace whole Core.pas with this ?

*Ok it works. I had to move procedures "OnJoinTeam" and "OnPlayerSpeak" from NetworkCore.pas to Core.pas or else I had a "Unknown identifier" error when it tried to compile NetworkCore.pas. Is this normal ?
« Last Edit: November 08, 2006, 05:02:06 am by Leo »

Offline cooz

  • Soldier
  • **
  • Posts: 187
  • BANNED
Re: Errors
« Reply #11 on: November 08, 2006, 06:24:52 am »
yes it's normal,
procedures in one file completly doesn't see anything from another file, so you have to do just what you did:
paste everything to one file, then delete duplicated procedures from all other files and it should work
Dead man! Dead man walking! We got a dead man walking here! Banned man crawling more like

Offline Leo

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1011
Re: Errors
« Reply #12 on: November 08, 2006, 06:32:29 am »
cooz, I would be greatful if you could visit #lrs channel, I need your help :)

Offline cooz

  • Soldier
  • **
  • Posts: 187
  • BANNED
Re: Errors
« Reply #13 on: November 08, 2006, 06:42:56 am »
sure, real time conversation is always more effective...
Dead man! Dead man walking! We got a dead man walking here! Banned man crawling more like