Official Soldat Forums
Server Talk => Scripting Discussions and Help => Topic started by: utkesmer on July 01, 2009, 05:05:18 am
-
-----
Here is my script.
--- SCRIPT.pas ---
var
AS: boolean;
function OnRequestGame(IP: string; State: integer): integer;
begin
Result := State;
{
IMPORTANT NOTE:
If you modify Result, please take into consideration that the user
may also be using another script which also modified the result...
To avoid conflictions, PLEASE perform logical checks...
}
if State = 3 then WriteConsole(0, 'BLABLABLABLABLABLABLABLA', RGB(255,130,0) );
if State = 4 then WriteConsole(0, 'BLABLABLABLABLABLABLABLA', RGB(255,10,10) );
if State = 5 then WriteConsole(0, 'BLABLABLABLABLABLABLABLA', RGB(0,130,255) );
end;
procedure OnJoinGame(ID, Team: byte);
begin
if AS = true then begin
Command('/setteam5 ' +INTTOSTR(ID) );
WriteConsole(ID, 'Auto Spectator is on.', RGB(255,0,0) );
end;
end;
procedure OnPlayerSpeak(ID: byte; Text: string);
begin
if MaskCheck(Text, '!komut*') then begin
WriteConsole(ID, 'BLABLABLABLABLABLABLABLA', RGB(56,176,222) );
end;
if MaskCheck(Text, '!command*') then begin
WriteConsole(ID, 'BLABLABLABLABLABLABLABLA', RGB(56,176,222) );
end;
if MaskCheck(Text, '!kural*') then begin
WriteConsole(ID, 'BLABLABLABLABLABLABLABLA', RGB(56,176,222) );
end;
if MaskCheck(Text, '!rule*') then begin
WriteConsole(ID, 'BLABLABLABLABLABLABLABLA', RGB(56,176,222) );
end;
if MaskCheck(Text, '!alpha*') or MaskCheck(Text, '!red*') or MaskCheck(Text, '!1*') then Command('/setteam1 '+INTTOSTR(ID) );
if MaskCheck(Text, '!bravo*') or MaskCheck(Text, '!blue*') or MaskCheck(Text, '!2*') then Command('/setteam2 '+INTTOSTR(ID) );
if MaskCheck(Text, '!spec*') or MaskCheck(Text, '!5') then Command('/setteam5 '+INTTOSTR(ID) );
if MaskCheck(Text, '!r*') then Command('/restart');
if MaskCheck(Text, '!p*') then Command('/pause');
if MaskCheck(Text, '!up*') or if MaskCheck(Text, '!unpause*') then Command('/unpause');
if MaskCheck(Text, '!ub*') or MaskCheck(Text, '!unb*') then Command('/unbanlast');
if MaskCheck(Text, '!autos1*') then begin
AS := true;
WriteConsole(0, 'Auto Spectator Script is on!', RGB(0,255,0) );
end;
if MaskCheck(Text, '!autos0*') then begin
AS := false;
WriteConsole(0, 'Auto Spectator Script is off!', RGB(255,0,0) );
end;
end;
I can't see any problem but it doesn't work. Server shutting down.
--- Log ---
09-07-01 12:39:19 Console Log Started
09-07-01 12:39:19 Welcome to Soldat 1.5.0
09-07-01 12:39:19 [*] ScriptCore v2.6 loaded! Found 2 scripts...
09-07-01 12:39:19 [*] Compiling default -> Core.pas...
09-07-01 12:39:19 [*] Compiling default -> NetworkCore.pas...
09-07-01 12:39:19 [*] Compiling default -> AdminCore.pas...
09-07-01 12:39:19 [*] Compiling Script -> SCRIPT.pas...
09-07-01 12:39:19 [*] Script -> [Error] (3:1): Identifier expected
09-07-01 12:39:19 [*] Compilation Failed.
09-07-01 12:39:19 Shutting down server...
09-07-01 12:39:19 Shutting down admin server...
09-07-01 12:39:19 Shutting down ScriptCore...
Help me please.
-----
-
Not sure, but 'as' seems to be a delphi command. Try a different variable name.
http://www.delphibasics.co.uk/RTL.asp?Name=As
-
Not sure, but 'as' seems to be a delphi command. Try a different variable name.
http://www.delphibasics.co.uk/RTL.asp?Name=As
Thank you very much, I changed the variable name to "autospec".
--- Log ---
09-07-01 15:44:51 Console Log Started
09-07-01 15:44:52 Welcome to Soldat 1.5.0
09-07-01 15:44:52 [*] ScriptCore v2.6 loaded! Found 2 scripts...
09-07-01 15:44:52 [*] Compiling default -> Core.pas...
09-07-01 15:44:52 [*] Compiling default -> NetworkCore.pas...
09-07-01 15:44:52 [*] Compiling default -> AdminCore.pas...
09-07-01 15:44:52 [*] Compiling Script -> SCRIPT.pas...
09-07-01 15:44:52 [*] Script -> [Error] (87:33): Syntax error
09-07-01 15:44:52 [*] Compilation Failed.
09-07-01 15:44:52 Shutting down server...
09-07-01 15:44:52 Shutting down admin server...
09-07-01 15:44:52 Shutting down ScriptCore...
I found this syntax error too.
Now, there is no problem. =)
Here is the correct script.
var
autospec: boolean;
function OnRequestGame(IP: string; State: integer): integer;
begin
Result := State;
{
IMPORTANT NOTE:
If you modify Result, please take into consideration that the user
may also be using another script which also modified the result...
To avoid conflictions, PLEASE perform logical checks...
}
if State = 3 then WriteConsole(0, 'BLABLABLABLABLABLABLABLA', RGB(255,130,0) );
if State = 4 then WriteConsole(0, 'BLABLABLABLABLABLABLABLA', RGB(255,10,10) );
if State = 5 then WriteConsole(0, 'BLABLABLABLABLABLABLABLA', RGB(0,130,255) );
end;
procedure OnJoinGame(ID, Team: byte);
begin
if autospec = true then begin
Command('/setteam5 ' +INTTOSTR(ID) );
WriteConsole(ID, 'Auto Spectator is on.', RGB(255,0,0) );
end;
end;
procedure OnPlayerSpeak(ID: byte; Text: string);
begin
if MaskCheck(Text, '!komut*') then begin
WriteConsole(ID, 'BLABLABLABLABLABLABLABLA', RGB(56,176,222) );
end;
if MaskCheck(Text, '!command*') then begin
WriteConsole(ID, 'BLABLABLABLABLABLABLABLA', RGB(56,176,222) );
end;
if MaskCheck(Text, '!kural*') then begin
WriteConsole(ID, 'BLABLABLABLABLABLABLABLA', RGB(56,176,222) );
end;
if MaskCheck(Text, '!rule*') then begin
WriteConsole(ID, 'BLABLABLABLABLABLABLABLA', RGB(56,176,222) );
end;
if MaskCheck(Text, '!alpha*') or MaskCheck(Text, '!red*') or MaskCheck(Text, '!1*') then Command('/setteam1 '+INTTOSTR(ID) );
if MaskCheck(Text, '!bravo*') or MaskCheck(Text, '!blue*') or MaskCheck(Text, '!2*') then Command('/setteam2 '+INTTOSTR(ID) );
if MaskCheck(Text, '!spec*') or MaskCheck(Text, '!5') then Command('/setteam5 '+INTTOSTR(ID) );
if MaskCheck(Text, '!r*') then Command('/restart');
if MaskCheck(Text, '!p*') then Command('/pause');
if MaskCheck(Text, '!up*') or MaskCheck(Text, '!unpause*') then Command('/unpause');
if MaskCheck(Text, '!ub*') or MaskCheck(Text, '!unb*') then Command('/unbanlast');
if MaskCheck(Text, '!autos1*') then begin
autospec := true;
WriteConsole(0, 'Auto Spectator Script is on!', RGB(0,255,0) );
end;
if MaskCheck(Text, '!autos0*') then begin
autospec := false;
WriteConsole(0, 'Auto Spectator Script is off!', RGB(255,0,0) );
end;
end;
Thank you again, JFK.