Author Topic: Having trouble with scripts  (Read 1838 times)

0 Members and 1 Guest are viewing this topic.

Offline Zyyn

  • Major(1)
  • Posts: 21
Having trouble with scripts
« on: May 14, 2007, 05:34:14 pm »
My friend and I have been trying to get a script working on my server, but it won't start up without a script error.

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: Having trouble with scripts
« Reply #1 on: May 14, 2007, 05:40:49 pm »
if u post the script or give more information we might be able to help you
urraka

Offline Zyyn

  • Major(1)
  • Posts: 21
Re: Having trouble with scripts
« Reply #2 on: May 14, 2007, 05:45:03 pm »
It is the Killing spree script.

var
kills: array[1..32] of integer;
CurMap,NexMap: string;
HKills: integer;
HName: string;

procedure ResetKills();
var
i: integer;
begin
for i := 1 to 32 do begin
kills := 0;
end;
end;

procedure HighestSpree();
begin
if HKills > 1 then begin
Command('/say Highest spree by: ' + HName + ' with ' + IntToStr(HKills) + ' kills!');
HName := '';
HKills := 0;
end;
end;

procedure OnMapChange();
begin
ResetKills();
HighestSpree();
end;

procedure ActivateServer();
begin
CurMap := CurrentMap;
NexMap := NextMap;
end;

procedure AppOnIdle(Ticks: integer);
begin
if Ticks mod 2 = 0 then begin //Every 2 seconds
if ((CurMap <> CurrentMap) and (TimeLeft > 0)) then
begin
OnMapChange; //Map has changed!
CurMap := CurrentMap;
end;
end;
end;

procedure OnCommand(ID: integer;Text: string);
var
i: integer;
begin
if GetPiece(Text, ' ', 1) = '/map' then
begin
if GetPiece(Text, ' ', 2) = CurrentMap then
begin
ResetKills();
HighestSpree();
end;
end;
if GetPiece(Text, ' ', 1) = '/restart' then
begin
ResetKills();
HighestSpree();
end;
if GetPiece(Text, ' ', 1) = '/spree' then
begin
if HKills > 1 then begin
Command('/say Highest spree by: ' + HName + ' with ' + IntToStr(HKills) + ' kills!');
end;
end
end;

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

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

begin
killsNeeded := 5; //number of kills needed to count as a killing spree
//spree
  • 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 Wicked Sick!';
spree[20] := ' is Godlike!';
spree[25] := ' is Beyond Godlike!';
i := NameToId(killer);
j := NameToId(victim);

if killer <> victim then begin //needed for servers with survival mode
kills := kills + 1
if kills > HKills then begin
HKills := kills;
HName := killer;
end;

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

if (kills <= Arrayhigh(spree) + 1) then begin
if (spree[kills] <> '') then Command('/say ' + killer + spree[kills]);
end;
end;
end;

/////Along with the regular NetworkCore.pas file////////

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

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
end;

procedure OnJoinGame(ID, Team: byte);
begin
end;

procedure OnJoinTeam(ID, Team: byte);
begin
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
end;

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

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

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

procedure OnMapChange(NewMap: string);
begin
end;

procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
end;

function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
begin
  // Victim = Player Damaged // Shooter = Player doing the damage
  result := Damage;
end;

procedure OnPlayerRespawn(ID: byte);
begin
end;

procedure OnPlayerSpeak(ID: byte; Text: string);
begin
end;

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: Having trouble with scripts
« Reply #3 on: May 14, 2007, 05:48:06 pm »
i'll try to check it out, if you post the error message you get that will help
urraka

Offline Zyyn

  • Major(1)
  • Posts: 21
Re: Having trouble with scripts
« Reply #4 on: May 14, 2007, 05:52:56 pm »
I'm always getting the error that stats....

07-05-14 16:31:21    Console Log Started
07-05-14 16:31:21 Loaded weapons mod "Default mod v1.4"
07-05-14 16:31:21 Welcome to Soldat 1.4.0
07-05-14 16:31:21 
  • Compiling Script Core.pas...

07-05-14 16:31:21 
  • Compiling Script NetworkCore.pas...

07-05-14 16:31:21 
  • Compiling Script AdminCore.pas...

07-05-14 16:31:21 
  • Compilation Complete.

07-05-14 16:31:21 
  • Run-time error (ActivateServer): Unknown procedure

07-05-14 16:31:21      Scripting is now disabled due to an error in your script.
07-05-14 16:31:21      A copy of this error can be found in /logs/scriptlog.txt
07-05-14 16:31:22 Shutting server...
07-05-14 16:31:22 Shutting down admin server...

Or something like this...

07-05-14 16:21:46    Console Log Started
07-05-14 16:21:47 Loaded weapons mod "Default mod v1.4"
07-05-14 16:21:47 Welcome to Soldat 1.4.0
07-05-14 16:21:47 
  • Compiling Script Core.pas...

07-05-14 16:21:47 
  • Compiling Script NetworkCore.pas...

07-05-14 16:21:47 
  • Compiling Script AdminCore.pas...

07-05-14 16:21:47 
  • [Error] (76:11): Duplicate identifier 'APPONIDLE'

07-05-14 16:21:47 Shutting server...
07-05-14 16:21:47 Shutting down admin server...

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: Having trouble with scripts
« Reply #5 on: May 14, 2007, 06:00:11 pm »
ok, there are problem because you haven't combined the scripts properly and also there were some mistakes in the code and i think it wasn't made for the dedicated server 2.6.0.
I'm correcting it, i'll post it when im done.. in a while

is it the only script you are using?
urraka

Offline Zyyn

  • Major(1)
  • Posts: 21
Re: Having trouble with scripts
« Reply #6 on: May 14, 2007, 06:06:49 pm »
There are the other scripts that come with the dedicated server.
AdminCore.pas
Core.pas
NetworkCore.pas
But that is the only script that I am trying to use on my server at the moment.

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: Having trouble with scripts
« Reply #7 on: May 14, 2007, 06:16:39 pm »
Ok, put these files i attached in your script folder, replacing the ones you already have.
urraka

Offline Zyyn

  • Major(1)
  • Posts: 21
Re: Having trouble with scripts
« Reply #8 on: May 14, 2007, 06:31:15 pm »
A new problem came up.

(19:32:18) 
  • Run-time error (OnCommand): Invalid pointer operation

(19:32:18)      Scripting is now disabled due to an error in your script.
(19:32:18)      A copy of this error can be found in /logs/scriptlog.txt

It came up when I logged onto Arsse.

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: Having trouble with scripts
« Reply #9 on: May 14, 2007, 06:40:44 pm »
yes, i think it was because of the GetPiece function try to replace ks.pas with this:

Code: [Select]
var
kills: array[1..32] of integer;
CurMap,NexMap: string;
HKills: integer;
HName: string;

procedure ResetKills();
var
i: integer;
begin
for i := 1 to 32 do begin
kills[i] := 0;
end;
end;

procedure HighestSpree();
begin
if HKills > 1 then begin
Command('/say Highest spree by: ' + HName + ' with ' + IntToStr(HKills) + ' kills!');
HName := '';
HKills := 0;
end;
end;

procedure ks_OnMapChange();
begin
ResetKills();
HighestSpree();
end;

procedure ks_ActivateServer();
begin
CurMap := CurrentMap;
NexMap := NextMap;
end;

procedure ks_AppOnIdle(Ticks: integer);
begin
if Ticks mod 2 = 0 then begin //Every 2 seconds
if ((CurMap <> CurrentMap) and (TimeLeft > 0)) then
begin
ks_OnMapChange(); //Map has changed!
CurMap := CurrentMap;
end;
end;
end;

procedure ks_OnCommand(ID: byte;Text: string);
begin
if StrPos('/map', Text) = 1 then
begin
if StrPos(CurrentMap, Text) = 6 then
begin
ResetKills();
HighestSpree();
end;
end;

if StrPos('/restart', Text) = 1 then
begin
ResetKills();
HighestSpree();
end;

if StrPos('/spree', Text) = 1 then
begin
if HKills > 1 then begin
Command('/say Highest spree by: ' + HName + ' with ' + IntToStr(HKills) + ' kills!');
end;
end;
end;

procedure ks_OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
kills[ID] := 0;
end;

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

begin
killsNeeded := 5; //number of kills needed to count as a killing spree
//spree 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 Wicked Sick!';
spree[20] := ' is Godlike!';
spree[25] := ' is Beyond Godlike!';
i := Killer;
j := Victim;

if Killer <> Victim then begin //needed for servers with survival mode
kills[i] := kills[i] + 1
if kills[i] > HKills then begin
HKills := kills[i];
HName := IDToName(Killer);
end;

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

if (kills[i] <= Arrayhigh(spree) + 1) then begin
if (spree[kills[i]] <> '') then Command('/say ' + IDToName(killer) + spree[kills[i]]);
end;
end;
end;
urraka

Offline Zyyn

  • Major(1)
  • Posts: 21
Re: Having trouble with scripts
« Reply #10 on: May 14, 2007, 07:13:21 pm »
Ok thanks so much it finally works for my server. The only problem was that I had to remove was an arsse script that says when an administrator joins the game, but I'll see what I can do with that. Unless you know whats wrong. But thank you for the script again.

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: Having trouble with scripts
« Reply #11 on: May 14, 2007, 07:23:57 pm »
If there is an ARSSE script that when you join a game it says you are an administrator, i think that it can be disabled going to configuration (in arrse), events, and unchek OnPlayerJoin. I'm not sure about it, or maybe i didn't understand what you said.
urraka

Offline Zyyn

  • Major(1)
  • Posts: 21
Re: Having trouble with scripts
« Reply #12 on: May 17, 2007, 03:11:26 pm »
I was saying that I "Had" to remove it, it was something that I added to arsse myself. It said something about an error with OnAdminconnect in arsse so I removed it so I could use that script you gave me.

Date Posted: May 14, 2007, 08:44:44 pm
Ok I made a new server folder with new everthing. I put the script you gave me in and now nothing works....

Date Posted: May 17, 2007, 03:33:38 pm
I feel really dumb... I just forgot to change the limit to the killing spree script and well it turns out it works. I just need to get some other scripts working.

Offline shadow x chaos

  • Major(1)
  • Posts: 10
Re: Having trouble with scripts
« Reply #13 on: May 25, 2007, 02:03:43 pm »
lol i was looking for command help for onspeak scripts and here i find u zyyn lol...
Also i need help on annoying majors that keep coming i need a script such as

if $PLAYER_NAME = Major
/say Your name $PLAYER_NAME is not accepted, plz change it
/kick $PLAYER_NAME
endif

i tried OnJoin scripts but it won't work...=(
Note: I'm am sub-admin for zyyn's server.

Offline FliesLikeABrick

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 6144
    • Ultimate 13 Soldat
Re: Having trouble with scripts
« Reply #14 on: May 25, 2007, 02:44:40 pm »
Zyyn and others:  in the future please make sure to use
Code: [Select]
tags so that the code is much easier to read and it takes less space on the page, and it is also more clear where the code starts/stops