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 SERVER1) 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 SCRIPTNext, 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:
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 SCRIPTNext 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.0IV. ADDING ANOTHER SCRIPTNext 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:
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.0Now 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!