How do i make a custom script for dedicated servers?

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
User avatar
Bonecrusher16O
Private Second Class
Posts: 66
Joined: Mon Apr 25, 2011 5:57 pm
Projects :: Snipers Galore and SAM
Games I'm Playing :: SWBF2 and MC
xbox live or psn: PS3 :)

How do i make a custom script for dedicated servers?

Post by Bonecrusher16O »

Ok, all I wanted to know is if there is a forum to this or not?
If not some help would be appericated. (What I mean by custom scripts for dedicated servers is like the realistic weapons mod Dakota made that is on Filefront.)
[Padawan]Helkaan
Sith
Sith
Posts: 1444
Joined: Mon Aug 16, 2010 3:01 pm
Projects :: Dunno. Maybe making something
Games I'm Playing :: Some.

Re: How to make costum script for dedicated servers.

Post by [Padawan]Helkaan »

Here's a tutorial made by Zerted:
Make Custom User Scripts.txt wrote:Overview
* The UnOfficial v1.3 patch r102+ supports up to 11 custom user scripts. User scripts are loaded and processed at the start of game_interface.lua. This allows the scripts to control or adjust almost everything that happens ingame. For instance, you can create a script that does a few FakeConsole commands at the start of any map or a script that changes the server name to reflect the amount of people on the server.

Requirements
* SWBF2 mod tools
* v1.3 patch r94+ installed
* Basic understanding of Lua
* Basic understanding of how the game works

How To Do It:
1) First, you will need to read and understand the 'Munge A Custom LVL File.txt' document
2) Then you need to pick a user script slot. The slots are from zero to ten. This guide will use slot four: "4". If you plan to distribute your scripts to others, it is best to copy your files and munge a custom lvl for each slot. This way, the user can decide which slot to use if he or she already has other user scripts in different slots.
3) Configure your map to munge the custom lvl: "user_script_4.lvl" (see the custom lvl doc for help)
4) user_script_4.lvl must, at the very least, contain the lua script: "user_script_4". When your custom lvl is processed by the game, it will load only this script. You can always include more scripts or resources in the lvl if you need them, but the expected script (user_script_4) must load them (use ScriptCB_DoFile() or ReadDataFile()).
5) After you munge your user_script_4.lvl, copy it to the folder: "GameData\Data\_LVL_PC"
6) Thats it! Run your game and check its debug output. You should see it saying it found and loaded your script each time you load a map/level.

More Info
* For an example user script that runs a few FakeConsole commands when you play a single-player map (easy to remove the SP part), see "user_script_example.zip" in the "code eamples" folder of the v1.3 patch.
* You can use these scripts to better configure a dedicated server or enforce rules, such as 'no vehicles' by using the FakeConsole command 'Lock Vehicles' or a snipers only rule by listening in on AddUnitClass() and canceling any non-sniper units from being added to the team!
Munge A Custom LVL File.txt wrote:Overview
* This tutorial will guide you through munging a custom lvl file

Requirements
* SWBF2 mod tools
* Basic understanding of modding
* Basic understanding of the munge process

How To Do It
) This guide will assume the mod map is XXX
) Create the folder: "data_XXX\Shell"
) Create the text file: "data_XXX\Shell\shell.req"
) Create the folder "data_XXX\Shell\scripts"
) Create the script file: "data_XXX\Shell\scripts\test.lua"
) In shell.req, add:

ucft
{
REQN
{
"script"
"test"
}
}

) Open VisualMunge, click "Unselect All", check "Shell", click "Munge"
) When VisualMunge finishes, it will have created the lvl file: "data_XXX\_LVL_PC\shell.lvl"
) Rename shell.lvl to whatever name you need, then move it to where you need the file.

Notes
* The test.lua script is just an example script file. You should change the req file to reflect whatever it is you are trying to munging.
User avatar
Bonecrusher16O
Private Second Class
Posts: 66
Joined: Mon Apr 25, 2011 5:57 pm
Projects :: Snipers Galore and SAM
Games I'm Playing :: SWBF2 and MC
xbox live or psn: PS3 :)

Re: How to make costum script for dedicated servers.

Post by Bonecrusher16O »

Uhh thanks for the tutorial.... But that not really the question I asked.....
Thanks anyways.
User avatar
sim-al2
2nd Lieutenant
2nd Lieutenant
Posts: 412
Joined: Mon Jul 06, 2009 10:26 pm
Projects :: Mapping on occasion
Games I'm Playing :: SWBFII + MW4 + SC4
Location: In the cockpit of some vehicle...

Re: How to make costum script for dedicated servers.

Post by sim-al2 »

Bonecrusher16O wrote:Uhh thanks for the tutorial.... But that not really the question I asked.....
Thanks anyways.
But you did ask for a custom script tutorial, even if you didn't know what they were or what you were looking for. Dakota's mod is not a script but rather a replacement of the existing server side files, which is doable by modifying and munging all of the files in the stock side assets for each side you wish to mod.
User avatar
Bonecrusher16O
Private Second Class
Posts: 66
Joined: Mon Apr 25, 2011 5:57 pm
Projects :: Snipers Galore and SAM
Games I'm Playing :: SWBF2 and MC
xbox live or psn: PS3 :)

Re: How do i make a custom script for dedicated servers?

Post by Bonecrusher16O »

Well... I guess its the replacement of the dedicated side files.
User avatar
Dakota
Field Commander
Field Commander
Posts: 991
Joined: Mon Dec 06, 2010 8:21 pm
Projects :: making random weapon assets
Games I'm Playing :: SWBF2 and more
xbox live or psn: PS3 beats xbox
Location: at a computer desk floating around in space

Re: How do i make a custom script for dedicated servers?

Post by Dakota »

my mod (which never was on filefront) doesn't have custom scripts. all i did was change the odfs in the common folder (NOT THE ONE IN THE SIDES FOLDER) of the mod and also i changed some sides (well, all sides) in the sides folder. and yet that isn't really what i think that you wanted because that has no scripting at all just odf changes...

the other mod i made that is on filefront is darky war mod which does have a custom mission.lvl which is what i changed with scripting. (its actually all scripting except for the fact that i changed the damage multiplyers on the pistol and award pistol)

this is a tutorial Fasty showed me from another topic that asked this question
Hidden/Spoiler:
1) Make a new map and delete all the lua files for it.
2) Go into the assets and get all the luas of all the stock maps you want in your server.
3) Put them into your new maps common/scripts/abc folder and make changes to them (add the code I mentioned).
4) Add the three letter names of the stock maps you're adding in the mission.req in data_abc/common.
5) Munge with common checked then go into your munged maps folder and copy the mission.lvl
6) Paste it in your servers files C:\Program Files (x86)\LucasArts\Star Wars Battlefront II PC Server\data\_LVL_PC
If you want to see this in action go join the Gamerz Hero FFA|NoForce/Guns server and see for yourself.
its for a dedicated but for a regular you only put the file in a different folder

(the _LVL_PC folder for the game not the dedicated server)
User avatar
Bonecrusher16O
Private Second Class
Posts: 66
Joined: Mon Apr 25, 2011 5:57 pm
Projects :: Snipers Galore and SAM
Games I'm Playing :: SWBF2 and MC
xbox live or psn: PS3 :)

Re: How do i make a custom script for dedicated servers?

Post by Bonecrusher16O »

Oh.. See you never told me THAT before dak...
User avatar
Dakota
Field Commander
Field Commander
Posts: 991
Joined: Mon Dec 06, 2010 8:21 pm
Projects :: making random weapon assets
Games I'm Playing :: SWBF2 and more
xbox live or psn: PS3 beats xbox
Location: at a computer desk floating around in space

Re: How do i make a custom script for dedicated servers?

Post by Dakota »

Bonecrusher16O wrote:Oh.. See you never told me THAT before dak...
well actually... i thought that you were there when i was telling all about the whole modding process of it...
Post Reply