Author Topic: adding script  (Read 2707 times)

0 Members and 1 Guest are viewing this topic.

Offline sakae

  • Soldier
  • **
  • Posts: 161
adding script
« on: April 17, 2007, 06:47:09 pm »
I couldnt find any thing of this on search function.

anyway. when I start the server when I have only copied and pasted in the NetworkCore.pas this message gets shown:
Hit CTRL+C twice to exit
 Please command the server using the Soldat Admin program
Welcome to Soldat 1.3.1
 Server name: -Major-'s R/S CTF
 Server PID: 7675
 
  • Compiling Script Core.pas...
  • Compiling Script AdminCore.pas...
  • Compiling Script NetworkCore.pas...
  • (NetworkCore.pas) [Error] (83:11): Duplicate identifier 'ONJOINTEAM'
  • Exception raised on SetVariables(Access violation at address 08089481, accessing address 00000000)
  • Run-time error (ActivateServer "function OnRequestGame(IP: string;State: integer):integer;"): No Error

----------------------------------------------------------------
Shutting server...
Shutting down admin server...

could anyone explain how I shall add them? I have looked at bmekims "tutorial" but I dont understand it.

oh also the server is on linux, is that whats causes the problem?

I am using soldatserver 2.5.4 too.

also I am not sure if this is the right place to post this in...
« Last Edit: April 17, 2007, 07:03:59 pm by sakae »

Offline chrisgbk

  • Moderator
  • Veteran
  • *****
  • Posts: 1739
Re: adding script
« Reply #1 on: April 18, 2007, 03:15:54 am »
You have the OnJoinTeam function declared twice; each function can only exist once.

Offline sakae

  • Soldier
  • **
  • Posts: 161
Re: adding script
« Reply #2 on: April 18, 2007, 04:25:51 am »
hmm.. also. shall I add the script in NetworkCore.pas or shall I create a new .pas file?

and how do I do to fox the problem? shall I change some names on the script?

or do you know any good walk trough about this?

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: adding script
« Reply #3 on: April 18, 2007, 05:24:06 am »
from what i know its better to make 1 script file by combining them, a good example of this:
http://forums.soldat.pl/index.php?topic=7516.0

It really worked  for me.
You even could do this, the constants first---save---looks if it works---then  the variables---save---look if it  works etc
So you  know  where the problem is.
Greetz Spkka

Offline sakae

  • Soldier
  • **
  • Posts: 161
Re: adding script
« Reply #4 on: April 18, 2007, 05:42:24 am »
whats wrong in this script?

Code: [Select]
const
//Teams
ALPHA = 1;
BRAVO = 2;
CHARLIE = 3;
DELTA = 4;
SPECTATOR = 5;
//Game Modes
DEATHMATCH = 0;
POINTMATCH = 1;
TEAMMATCH = 2;
CTF = 3;
RAMBO = 4;
INF = 5;
HTF = 6;

SERVER = 255;

var
kills: array[1..32] of integer;

var
killLog: array[1..32] of byte;
voteTime: array[1..32] of byte;
spawnKill: array[1..32] of byte;
killAtSpawn: byte;

function IDtoTeam(PlayerID: integer):integer;
begin
  case PlayerID of
    1: Result:= Player_Team_1;
    2: Result:= Player_Team_2;
    3: Result:= Player_Team_3;
    4: Result:= Player_Team_4;
    5: Result:= Player_Team_5;
    6: Result:= Player_Team_6;
    7: Result:= Player_Team_7;
    8: Result:= Player_Team_8;
    9: Result:= Player_Team_9;
    10: Result:= Player_Team_10;
    11: Result:= Player_Team_11;
    12: Result:= Player_Team_12;
    13: Result:= Player_Team_13;
    14: Result:= Player_Team_14;
    15: Result:= Player_Team_15;
    16: Result:= Player_Team_16;
    17: Result:= Player_Team_17;
    18: Result:= Player_Team_18;
    19: Result:= Player_Team_19;
    20: Result:= Player_Team_20;
    21: Result:= Player_Team_21;
    22: Result:= Player_Team_22;
    23: Result:= Player_Team_23;
    24: Result:= Player_Team_24;
    25: Result:= Player_Team_25;
    26: Result:= Player_Team_26;
    27: Result:= Player_Team_27;
    28: Result:= Player_Team_28;
    29: Result:= Player_Team_29;
    30: Result:= Player_Team_30;
    31: Result:= Player_Team_31;
    32: Result:= Player_Team_32;
  end;
case PlayerID of
    1: Result:= Player_Team_1;
    2: Result:= Player_Team_2;
    3: Result:= Player_Team_3;
    4: Result:= Player_Team_4;
    5: Result:= Player_Team_5;
    6: Result:= Player_Team_6;
    7: Result:= Player_Team_7;
    8: Result:= Player_Team_8;
    9: Result:= Player_Team_9;
    10: Result:= Player_Team_10;
    11: Result:= Player_Team_11;
    12: Result:= Player_Team_12;
    13: Result:= Player_Team_13;
    14: Result:= Player_Team_14;
    15: Result:= Player_Team_15;
    16: Result:= Player_Team_16;
    17: Result:= Player_Team_17;
    18: Result:= Player_Team_18;
    19: Result:= Player_Team_19;
    20: Result:= Player_Team_20;
    21: Result:= Player_Team_21;
    22: Result:= Player_Team_22;
    23: Result:= Player_Team_23;
    24: Result:= Player_Team_24;
    25: Result:= Player_Team_25;
    26: Result:= Player_Team_26;
    27: Result:= Player_Team_27;
    28: Result:= Player_Team_28;
    29: Result:= Player_Team_29;
    30: Result:= Player_Team_30;
    31: Result:= Player_Team_31;
    32: Result:= Player_Team_32;
  end;
end;

procedure showVoteMenu(k,v: integer);
begin
killLog[v] := k;
voteTime[v] := 15;
SayToPlayer(v, 'You have 15 seconds or to end of round to decide an action');
SayToPlayer(v, '!1 - Forgive player');
SayToPlayer(v, '!2 - Kill player now');
SayToPlayer(v, '!3 - Kill player on next respawn');
end;

procedure AppOnIdle(Ticks: integer);
begin
var
i: integer;
begin
if (NumPlayers > 0) then begin
if (Ticks mod 60 = 0) then begin
if killAtSpawn > 0 then killAtSpawn := killAtSpawn - 1;
for i := 1 to 32 do begin
if (spawnKill[i] = 1) and (killAtSpawn = 1) then begin
Command('/kill ' + inttostr(i));
spawnKill[i] := 0;
end;
if voteTime[i] > 0 then voteTime[i] := voteTime[i] - 1;
end;
if killAtSpawn = 1 then killAtSpawn := 0;
end;
end;
end;

procedure OnJoinTeam(IP, Nickname: string;Team: byte);
begin
kills[NameToId(Nickname)] := 0;
killLog[NameToId(Nickname)] := 0;
spawnKill[NameToId(Nickname)] := 0;
end;

procedure OnLeaveGame(IP, Nickname: string;Team: byte);
begin
kills[NameToId(Nickname)] := 0;
killLog[NameToId(Nickname)] := 0;
spawnKill[NameToId(Nickname)] := 0;
end;

procedure OnPlayerKill(Killer,Victim,Weapon: string);
var
spree: array[1..17] of string;
i: integer;
j: integer;
killsNeeded: integer;

begin
killsNeeded := 5; //number of kills needed to count as a killing spree
//spree[x] where x represents the current number of spree kills player has
//more can be added just be sure to change the spree array size
spree[killsNeeded] := ' is on a Killing Spree!';
spree[8] := ' is on a Rampage!';
spree[11] := ' is Dominating!';
spree[14] := ' is Unstoppable!';
spree[17] := ' is Godlike!';
i := NameToId(killer);
j := NameToId(victim);

if killer <> victim then begin //needed for servers with survival mode
if (IDtoTeam(NameToId(killer)) <> IDtoTeam(NameToId(victim))) then begin
kills[i] := kills[i] + 1;

if (kills[j] >= killsNeeded) then begin
Command('/say ' + victim + '''s ' + inttostr(kills[j]) + ' kills spree ended by ' + killer);
end;
kills[j] := 0;

if (kills[i] <= Arrayhigh(spree) + 1) then begin
if (spree[kills[i]] <> '') then Command('/say ' + killer + spree[kills[i]]);
end;
end
else begin
if (kills[i] > 0) then SayToPlayer(NameToId(killer), 'Your spree kills have been reset for team killing');
kills[i] := 0;
end;

end;
begin
(IDtoTeam(NameToId(killer)) = IDtoTeam(NameToId(victim))) then showVoteMenu(NameToId(killer),NameToId(victim));
end;

procedure OnPlayerSpeak(Name,Text: string);
begin
ar
id: integer;
begin
id := NameToId(Name);
if (Text = '!1') or (Text = '!2') or (Text = '!3') then begin
if (killLog[id] > 0) and (voteTime[id] <> 0) then begin
if (Text = '!1') then begin
SayToPlayer(killLog[id], Name +' has forgiven you');
end
else if (Text = '!2') then begin
SayToPlayer(killLog[id], Name +' has chosen to kill you');
Command('/kill ' + inttostr(killLog[id]));
end
else begin
SayToPlayer(killLog[id], Name +' has chosen to kill you on next respawn');
spawnKill[killLog[id]] := 1;
end;
SayToPlayer(id, 'Vote successful');
killLog[id] := 0;
voteTime[id] := 0;
end
else begin
SayToPlayer(id, 'You waited too long to vote');
killLog[id] := 0;
voteTime[id] := 0;
end;
end;
end;

procedure OnPlayerRespawn(ID: integer);
begin
killAtSpawn := 3;
killLog[id] := 0;
voteTime[id] := 0;
end;

procedure OnPlayerRespawn(ID: integer);
begin
killAtSpawn := 3;
killLog[id] := 0;
voteTime[id] := 0;
end;
end;

procedure OnPlayerRespawn(ID: integer);
begin
end;

procedure ActivateServer();
begin
end;

procedure OnCommand(ID: integer;Text: string);
begin
end;

function OnRequestGame(IP: string;State: integer):integer;
begin
Result := State;
end;

procedure OnJoinGame(IP, Nickname: string;Team: byte);
begin
end;

procedure OnFlagGrab(ID: integer;TeamFlag: byte;GrabbedInBase: boolean);
begin
end;

procedure OnFlagReturn(ID: integer;TeamFlag: byte);
begin
end;

procedure OnFlagScore(ID: integer;TeamFlag: byte);
begin
end;

this is my try in combining killing spree and TK voting script
« Last Edit: April 18, 2007, 08:12:35 am by sakae »

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: adding script
« Reply #5 on: April 18, 2007, 10:41:46 am »
what ive seen so far is
procedure OnPlayerRespawn(ID: integer);
begin
killAtSpawn := 3;
killLog[id] := 0;
voteTime[id] := 0;
end;

procedure OnPlayerRespawn(ID: integer);
begin
killAtSpawn := 3;
killLog[id] := 0;
voteTime[id] := 0;
end;
end;

Its there twice which can´t i think but i need to go to work now
Look back in your log folder to see which error may occured!
Good luck

Offline sakae

  • Soldier
  • **
  • Posts: 161
Re: adding script
« Reply #6 on: April 18, 2007, 11:42:42 am »
  • Compiling Script AdminCore.pas...
  • Compiling Script NetworkCore.pas...
  • (NetworkCore.pas) [Error] (116:1): Identifier expected
  • Exception raised on SetVariables(Access violation at address 08089481, accessing address 00000000)
  • Run-time error (ActivateServer "const"): No Error
Quote
  • (NetworkCore.pas) [Error] (116:1): Identifier expected
does this mean that the error is on line 116? and what means with that? is Identifier "var"? or i: integer;?
« Last Edit: April 18, 2007, 11:51:09 am by sakae »

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: adding script
« Reply #7 on: April 18, 2007, 12:24:24 pm »
yur still compiling multiple scripts.. Networkcore.pas etc
Make just one script called sakae.pas or something and change the include.txt in the same script folder
remove the Admincore.pas, Networkcore.pas etc in the include.txt and only include the sakae.pas

Then post further errors


Offline sakae

  • Soldier
  • **
  • Posts: 161
Re: adding script
« Reply #8 on: April 18, 2007, 12:37:41 pm »
  • Compiling Script Server.pas...
  • (Server.pas) [Error] (116:1): Identifier expected
  • Exception raised on SetVariables(Access violation at address 08089481, accessing address 00000000)
  • Run-time error (ActivateServer "const"): No Error


still this error.
Code: [Select]
procedure AppOnIdle(Ticks: integer);
begin
var

i: integer;
begin
if (NumPlayers > 0) then begin
if (Ticks mod 60 = 0) then begin
if killAtSpawn > 0 then killAtSpawn := killAtSpawn - 1;
for i := 1 to 32 do begin
if (spawnKill[i] = 1) and (killAtSpawn = 1) then begin
Command('/kill ' + inttostr(i));
spawnKill[i] := 0;
end;
if voteTime[i] > 0 then voteTime[i] := voteTime[i] - 1;
end;
if killAtSpawn = 1 then killAtSpawn := 0;
end;
end;
end;

is the "var" the error? I have tested to remove:
begin
var

i:integer;

but then it gets error on:
for i := 1 to 32 do begin

(on "var" is line 116)

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: adding script
« Reply #9 on: April 18, 2007, 06:35:03 pm »
You dont put

procedure AppOnIdle(Ticks: integer);
begin
var

its just
procedure AppOnIdle(Ticks: integer);
var
i:integer;
begin

Offline sakae

  • Soldier
  • **
  • Posts: 161
Re: adding script
« Reply #10 on: April 18, 2007, 10:02:52 pm »
new error...

 
  • Compiling Script Server.pas...
  • (Server.pas) [Error] (185:1): Identifier expected
  • Exception raised on SetVariables(Access violation at address 08089481, accessing address 00000000)
  • Run-time error (ActivateServer "const"): No Error


Identifier again... what means with that?

piece of code on line 185 (begin = line 185:1)


Code: [Select]
begin
(IDtoTeam(NameToId(killer)) = IDtoTeam(NameToId(victim))) then showVoteMenu(NameToId(killer),NameToId(victim));
end;

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: adding script
« Reply #11 on: April 18, 2007, 10:08:06 pm »
Why are you trying to set the value of the IDtoTeam function -_-... Thats why you have an error. Your missing an IF

Offline sakae

  • Soldier
  • **
  • Posts: 161
Re: adding script
« Reply #12 on: April 19, 2007, 09:27:14 am »
ok I found the problem. just a "couple" of hours and deep reading on the scripts and comparing and looking on all ID thingies I got the scripts to work :). thank you all for the help
« Last Edit: April 21, 2007, 08:28:25 am by sakae »