Author Topic: How to enable a script on your server  (Read 3467 times)

0 Members and 1 Guest are viewing this topic.

Offline Dizzy So 1337

  • Soldier
  • **
  • Posts: 246
How to enable a script on your server
« on: July 28, 2007, 10:53:16 pm »
UPDATE 081207 re Dedicated Server 2.6.2.  Dedicated Server 2.6.2 includes eC's much-anticipated ScriptCore 2.0 which should make this tutorial almost completely obsolete.  I'll be back with the ScriptCore 2.0 for noobs tutorial soon.  Although this tutorial may still be a benefit for noobs to run through to understand a bit better 'why' things are the way they are, and be better educated to troubleshoot their own stuff. 

Having just learned how to do this, I hope to 'give back' a little by posting a step-by-step for the total noob.  While I was looking for this knowledge I ran across lots of unanswered posts of people asking the same question.  Please link those lost souls to this tutorial.  I am hoping that DorkeyDear and SpankCake do not mind that I used their scripts as examples. 

Note: this doesn't explain how to run scripts in ARSSE.

I.  PREPARING THE SERVER

1) Ensure you have the latest dedicated server.  As of today that is 2.6.1 but check http://www.soldat.pl/down-s.html if your not sure.
2) Open server.ini and ensure that scripting=1
3) Make a backup copy of your Scripts folder.  Dunno if necessary, but let's be careful because we are noobs.
4) Optionally, if you are renting the server from someone, check with them to make sure that Scripting is available for your rental account.  (It probably is, but if it isn't then I just saved you a looooot of trouble).

Before going further, let's look inside that Scripts folder a sec.  The .pas files are the scripts.  The Includes.txt file will determine which scripts will be active on our server.  Open the Includes.txt and note that each of the .pas files is listed in there.  Further, note that SocketCore.pas has a // in front of it.  This means that //SocketCore.pas is NOT active.  I have been informed that SocketCore.pas is NOT IMPORTANT for noobs, so don't worry about it.

II. PREPARING THE SCRIPT

Next, let's get a script ready.  I'll use SpankCake's NextMapVote script for the first example because it is the one that I learned on.

1) Open the Script Combiner via http://scriptcombiner.awardspace.com/
2) Check the 'Use Template' box.
3) Paste this text into the rightside window New Script:

Code: [Select]
var
  NextMapArray: array[1..32] of Boolean;
  NextMapVote: Byte;

procedure ResetMapVote();
var
i: integer;
begin
NextMapVote:=0;
for i := 1 to 32 do begin
NextMapArray[i] := False;
end;
end;

procedure OnMapChange(NewMap: string);
begin
ResetMapVote()
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
if NextMapArray[ID] then begin
NextMapArray[ID]:=false;
NextMapVote:=NextMapVote-1;
end;
end;

procedure NextMapV(ID: integer);
var
VotePrec: Double;
begin
   NextMapArray[ID]:=true;
   NextMapVote:=NextMapVote+1;
   command('/say Voters for Next Map: ' + inttostr(NextMapVote)+'/'+inttostr(NumPlayers));
   VotePrec:=NextMapVote/NumPlayers;
  {the 0.6 means 60% vote percentage needed. (changeable)}
   if (VotePrec>0.6) then Begin
    Command('/say Next Map Vote Had Passed');
    Command('/nextmap');
   End;
End;

procedure OnPlayerSpeak(ID: byte; Text: string);
begin
  if (Text = '!nextmap') and (NextMapArray[ID]=false) then NextMapV(ID);
End;

4) Click on Combine Scripts button.
5) Once the script is combined, copy and paste the text fromtop window New Combined Script into a .txt file on your desktop.  Rename this file to Test.pas.

The script is now ready.  Test.pas is now a 'superscript' that includes all the functions of Core.pas, AdminCore.pas, NetworkCore.pas, and the functions of the NewMapVote code. 

III.  UPLOADING THE NEW SCRIPT
Next we will update our server so that Test.pas will run.

1) Upload Test.pas to the Scripts folder in your server.  Delete all the other .pas files from this folder (you did make backups, right?)
2) Open Includes.txt and type Test.pas at the bottom.
3) Remove all the references to other .pas files from the Includes.txt file, save and close.
4) Restart server and enjoy.  Test by saying !nextmap.  The next map should load.
If it doesn't work, try restarting the server a few more times before starting over from scratch.  I dunno if I am just being nooby but this seems to work some times for mysterious reasons.

More info on SpankCake's NextMapVote script at http://enesce.com/forum/index.php?topic=575.0

IV.  ADDING ANOTHER SCRIPT
Next we will add another script on top of what we already have.  The example I am gonna use is DorkeyDear's BigText script that I got from forums.soldat.pl.

1) Since I don't know if you noobs closed the Script Combiner or left it open, let's all close it and reopen it so that we are sure we are all on the same page.  Yes this would be a little easier if we had left it open.
2) OK, so Script Combiner is open, right?  This time do NOT check Use Template.
3) Get your Test.pas script pasted into the leftside window Current Script.  Paste the new example script into the rightside window New Script:

Code: [Select]
function OnCommand(ID: Byte; Text: string): boolean;
var
  Name: string;
begin
  if ID = 255 then Name := 'Server' else Name := GetPlayerStat(ID,'Name');
  if Copy(Text,1,5) = '/big ' then begin
    if Length(Text) <= 72 then DrawText(0,Copy(Text,6,Length(Text)),Length(Text) * 10 + 100,$FFDF3CA8,4 / Length(Text),8,240 + Length(Text)) else WriteConsole(ID,'Your message was greater than 72 charactes. It was unable to be drawn.',$FFDF3CA8);
    WriteConsole(0,'[' + Name + '] ' + Copy(Text,6,Length(Text)),$FFDF3CA8);
  end;
end;


4) Click Combine Script.
5) Again, copypaste from top window New Combined Script into a new .txt document on your desktop.  Let's name this one Test2.pas.  That way, if you made a mistake in section IV you won't have to start completely from scratch.
6) Upload Test2.pas using the same steps described in Section III.
7) Restart, and enjoy.  Test by typing /big HI I HAVE COMBINED SCRIPTS MUHAHA! (you have to be logged in as an admin to do it)

More info on DorkeyDear's DrawText script at http://forums.soldat.pl/index.php?topic=15732.0

Now you can see why this is so incredibly simple and easy to do that most people can't be bothered to explain it to noobs.  Thanks to KeyDon, IQ-Unlimited, and bja888 for explaining it to me.  Thanks to PerroAzul for making the post (somewhere around here) that set me on the right path.  And ffs thanks to mikembm for making Script Combiner in the first place.  Also #soldat.devs @ quakenet, forums.soldat.pl and EnescE forums http://enesce.com/forum/index.php are good resources for learning more. 

Now that you have the total basics of hosting a script down, go out and learn more cool stuff!
« Last Edit: August 12, 2007, 06:40:18 pm by Dizzy So 1337 »
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 mikembm

  • Soldier
  • **
  • Posts: 210
Re: How to enable a script on your server
« Reply #1 on: August 02, 2007, 08:53:03 pm »
Glad to see my script combiner being used :D

Although please note that it is not perfect:
- You cannot combine more than one script at a time if the two script share a certain procedure or function.
- Also you can end up having the same variable twice in a procedure, for example "i" for a loop is quite common. But as far as I'm aware having it twice does not affect anything.

And I really don't feel like updating it because in the next version it wont be needed...

Offline 1221995

  • Soldier
  • **
  • Posts: 206
Re: How to enable a script on your server
« Reply #2 on: August 03, 2007, 07:39:08 am »
Nice Guide, And Mikembm, nice commbiner :)

Offline BondJamesBond

  • Flagrunner
  • ****
  • Posts: 986
    • http://tobylands.com
Re: How to enable a script on your server
« Reply #3 on: August 03, 2007, 10:18:24 am »
Wah! Thank you for the guide.
The computer is a moron.
?  - Peter Drucker

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: How to enable a script on your server
« Reply #4 on: August 03, 2007, 12:41:50 pm »
You should put the code in [ code ] ... [ /code ] tags :)

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: How to enable a script on your server
« Reply #5 on: August 04, 2007, 12:09:08 am »
Very nice tutorial. This is just what every noob needs :P

By the way, you don't really need to restart the server, you can use /recompile command.
urraka

Offline Dizzy So 1337

  • Soldier
  • **
  • Posts: 246
Re: How to enable a script on your server
« Reply #6 on: August 04, 2007, 03:02:56 am »
Very nice tutorial. This is just what every noob needs :P

By the way, you don't really need to restart the server, you can use /recompile command.

Thanks Perro.  As I recall now, it was one of you posts that really set me on the right path!  Sorry I forgot to credit you, fixed now.  While I'm at it, I need to credit mikembm for making Script Combiner, since, looking back, this is essentially a Script Combiner tutorial.

People who help noobs FTW.

« Last Edit: August 04, 2007, 05:16:07 pm by Dizzy So 1337 »
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 mikembm

  • Soldier
  • **
  • Posts: 210
Re: How to enable a script on your server
« Reply #7 on: August 04, 2007, 08:04:01 am »
By the way, you don't really need to restart the server, you can use /recompile command.

/recompile has problems and doesn't always work

Offline GravitY

  • Major(1)
  • Posts: 5
Re: How to enable a script on your server
« Reply #8 on: August 08, 2007, 12:16:02 am »
It doesent work for me i tried it twice and it shuts down right when i try to start it up. I made a text document and named it .pas but that doesent really make it a test.pas file right??

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: How to enable a script on your server
« Reply #9 on: August 08, 2007, 12:43:06 am »
Depending on your windows configuration the extension of the file can be hidden. so maybe u see it as .pas but it's actually .txt.

Maybe can help you a bit more if you show the error message when the server gets shut down.
urraka

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: How to enable a script on your server
« Reply #10 on: August 09, 2007, 12:10:07 pm »
I have my windows configured to always show the extention (other than .ink files, or whatever the shortcut file extention is, which I can not modify that, does anybody know how? lol) This may help you out a lot of you switch it to that, or it may just confuse you. ^^

Offline Iq Unlimited

  • Flagrunner
  • ****
  • Posts: 864
  • mr. foobar2000
Re: How to enable a script on your server
« Reply #11 on: August 09, 2007, 12:35:53 pm »
yay tutorial, I was wondering if Curt was going to do this xD.
By the way, you don't really need to restart the server, you can use /recompile command.

/recompile has problems and doesn't always work
It usually works for me, the one time when I implemented Trenchwar Domination it screwed up, otherwise it worked ok.
« Last Edit: August 09, 2007, 12:37:43 pm by Iq Unlimited »

Offline haha

  • Camper
  • ***
  • Posts: 298
  • soldier=soldat=game
Re: How to enable a script on your server
« Reply #12 on: August 17, 2007, 04:19:43 am »
eh, does the link work now....cause its just a white screen when it stops loading
Image removed, please read the forum rules.

Offline mikembm

  • Soldier
  • **
  • Posts: 210
Re: How to enable a script on your server
« Reply #13 on: August 17, 2007, 11:00:20 am »
eh, does the link work now....cause its just a white screen when it stops loading

You don't need the script combiner anymore.
This guide needs to be rewritten.

Offline haha

  • Camper
  • ***
  • Posts: 298
  • soldier=soldat=game
Re: How to enable a script on your server
« Reply #14 on: August 17, 2007, 09:35:49 pm »
ar ok...but not trying to be noob, when i downloaded the eC trench war script, it was a .pas file, and i just needed to paste it into the script folder and run ir. but ten i went to the other script threads and it was only many words, not a .pas file.  i tried to paste it into a notepad program and change the type to .pas, but the server only could ran the trench war script...why cant they detech the others? or did i do it wrong?
Image removed, please read the forum rules.

Offline Dizzy So 1337

  • Soldier
  • **
  • Posts: 246
Re: How to enable a script on your server
« Reply #15 on: August 18, 2007, 07:09:02 pm »
In the newest server version, run each script in a separate subfolder of Scripts, each with its own Includes.txt.

You did the right thing making the .pas file.  Now create a subfolder in Scripts named [anything] and put the contents of Avarax's script folder in there.  Make another subfolder in Scripts named [anything else] and put the new .pas (let's say you called it script.pas)  in there.  Also in that second folder put a file called Includes.txt that has the text script.pas in it.

Restart and enjoy.

Since Script Combiner is indeed unavailable I am gonna be asking to get this topic Locked or archived or whatever.  Until I've written a new uber-noob-friendly tutorial for the new server, anybody who is tackling this for their first time please feel free to PM me if you find this locked.
xfire - todhostetler
"There's nothing I wouldn't do to win. But I never hurt anyone except to stick a dogskull on a stake."