Official Soldat Forums
Server Talk => Scripting Discussions and Help => Topic started 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 - 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.
-
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....
-
06-11-08 08:38:40
- (Core.pas) [Error] (34:46): Unknown identifier 'formatTime'
Where I put this function ?
-
Which scripts are you trying to combine? List them here, and I'll show you how to combine them properly.
-
wow! I managed to make the uptime script to work, I am a scripting God I tell you! :P
-
I take it you solved your problems?
-
Well, actually it worked for one script but when I tried to add another it was a mess.
-
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.
-
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 :)
-
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.
-
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 ?
-
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
-
cooz, I would be greatful if you could visit #lrs channel, I need your help :)
-
sure, real time conversation is always more effective...