Author Topic: Adding scripts  (Read 1417 times)

0 Members and 3 Guests are viewing this topic.

Offline Kitty

  • Major
  • *
  • Posts: 60
Adding scripts
« on: July 08, 2007, 10:10:12 am »
I want to add the killing spree script but how do i actually add it? Cause if i combine scripts it says its missing some things, and if i still put it in it wont work can anyone upload a working script of killing spree's for CTF and tell me how to use it?
-A female soldat player.


Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: Adding scripts
« Reply #1 on: July 08, 2007, 03:34:08 pm »
Try this. I didn't test it but I think it should work.

Code: [Select]
var
CurMap: string;
kills: array[1..32] of integer;
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_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 := 3; //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[5] := ' is on a Rampage!';
spree[7] := ' is Dominating!';
spree[9] := ' is Unstoppable!';
spree[11] := ' is Wicked Sick!';
spree[13] := ' is Godlike!';
spree[15] := ' is Unfreakingbelievable!';
spree[20] := ' is now a STAR PLAYER!';
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
WriteConsole(0, IDToName(Victim) + '''s ' + inttostr(kills[j]) + ' kills spree ended by ' + IDToName(Killer), RGB(255, 0, 0));
end;
kills[j] := 0;
if (kills[i] <= Arrayhigh(spree) + 1) then begin
if (spree[kills[i]] <> '') then
WriteConsole(0, IDToName(killer) + spree[kills[i]], RGB(0, 0, 255));
end;
end;
end;
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
ks_OnLeaveGame(ID, Team, Kicked);
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
ks_OnMapChange();
end;
procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
ks_OnPlayerKill(Killer, Victim, Weapon);
end;
function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
begin
Result := Damage;
end;
procedure OnPlayerRespawn(ID: byte);
begin
end;
procedure OnPlayerSpeak(ID: byte; Text: string);
begin
end;
procedure ActivateServer();
begin
CurMap := CurrentMap;
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(CurrentMap);
CurMap := CurrentMap;
end;
end;
// Here other stuff
end;
function OnCommand(ID: Byte; Text: string): boolean;
begin
ks_OnCommand(ID, Text);
Result := false;
end;
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
Result := false;
end;
procedure OnException(ErrorMessage: string);
begin
//  WriteFile('ErrorLog.txt', ErrorMessage);
end;
procedure OnAdminConnect(IP: string);
begin
end;
procedure OnAdminDisconnect(IP: string);
begin
end;
procedure OnAdminMessage(IP, Msg: string);
begin
end;
urraka

Offline Kitty

  • Major
  • *
  • Posts: 60
Re: Adding scripts
« Reply #2 on: July 09, 2007, 05:27:37 am »
Thats the problem where do i add the script?  ::)
-A female soldat player.


Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: Adding scripts
« Reply #3 on: July 09, 2007, 12:35:22 pm »
First you have to make sure that you have the dedicated server (not the one that comes with the game).

There is a folder called scripts with some .pas files and a include.txt.
You can copy that code I posted in an empty file and rename it to something like script.pas.
After that, open the file include.txt, erase everything there and write this:
Code: [Select]
script.pas(or whatever the name of the file is)
urraka

Offline Kitty

  • Major
  • *
  • Posts: 60
Re: Adding scripts
« Reply #4 on: July 10, 2007, 06:08:22 am »
It still doesnt work i made a new pas file and did the code in there then i restarted the server i get like 10 kills in a row but nothing happens
-A female soldat player.


Offline mikembm

  • Soldier
  • **
  • Posts: 210
Re: Adding scripts
« Reply #5 on: July 10, 2007, 09:58:49 am »
Did you set scripting = 1 in server.ini  ?

Offline Kitty

  • Major
  • *
  • Posts: 60
Re: Adding scripts
« Reply #6 on: July 11, 2007, 08:53:20 am »
Yea scripting=1
-A female soldat player.


Offline Dizzy So 1337

  • Soldier
  • **
  • Posts: 246
Re: Adding scripts
« Reply #7 on: August 02, 2007, 07:17:12 pm »
PerroAZUL's posts here were some of the most helpful I found in trying to figure this out myself.  But I went a bit further and wrote Script Implementation for noobs http://forums.soldat.pl/index.php?topic=17978.0

Be warned I wrote it assuming that the reader knows almost NOTHING.
xfire - todhostetler
"There's nothing I wouldn't do to win. But I never hurt anyone except to stick a dogskull on a stake."

Offline zyxstand

  • Veteran
  • *****
  • Posts: 1106
  • Mother of all Bombs
Re: Adding scripts
« Reply #8 on: August 03, 2007, 03:07:06 pm »
Why can't people just publish their files as a RTG scripts folder?  No confusion there!
Can't think of anything original to put here...

Offline mikembm

  • Soldier
  • **
  • Posts: 210
Re: Adding scripts
« Reply #9 on: August 03, 2007, 08:41:30 pm »
Why can't people just publish their files as a RTG scripts folder?  No confusion there!

They still leaves issues such as scripting=1 and also when they have more than one script.
The fact is that people need to learn how to do it themselves.