Official Soldat Forums

Server Talk => Scripting Discussions and Help => Topic started by: Leo on November 08, 2006, 02:07:04 am

Title: Errors
Post by: Leo 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 
06-11-08 08:04:48 
06-11-08 08:04:48 
06-11-08 08:04:48 
06-11-08 08:04:48 
06-11-08 08:04:48 

I get these "Dublicate identifier" errors whenever another script trys to compile.
Title: Re: Errors
Post by: EnEsCe 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....
Title: Re: Errors
Post by: Leo on November 08, 2006, 02:42:39 am
06-11-08 08:38:40 
Where I put this function ?
Title: Re: Errors
Post by: chrisgbk 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.
Title: Re: Errors
Post by: Leo 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
Title: Re: Errors
Post by: chrisgbk on November 08, 2006, 03:12:22 am
I take it you solved your problems?
Title: Re: Errors
Post by: Leo 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.
Title: Re: Errors
Post by: chrisgbk 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.
Title: Re: Errors
Post by: Leo 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  :)
Title: Re: Errors
Post by: chrisgbk 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.
Title: Re: Errors
Post by: Leo 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 ?
Title: Re: Errors
Post by: cooz 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
Title: Re: Errors
Post by: Leo on November 08, 2006, 06:32:29 am
cooz, I would be greatful if you could visit #lrs channel, I need your help :)
Title: Re: Errors
Post by: cooz on November 08, 2006, 06:42:56 am
sure, real time conversation is always more effective...