Getting_started/Script_xml

Every script folder has a Script.xml that lists its files:

TagAttributesMeaning
<script>file, clientclient="0" runs on the server. client="1" is sent to players and run on their game.
<script>dir, client="1", recursive, loadEvery .nut of a sub folder is a client script, in alphabetical order (00_util.nut before 10_main.nut). recursive="1" includes sub folders. load="0" (also on a file line) downloads the file but runs it only when a client script calls IncludeScript. Every .nut in the folder is sent to the players, except files with their own file line: keep server scripts out of it. No .., absolute paths or links.
<sprite>fileAn image (png/jpg) under Scripts/<folder>/Sprites/. Downloaded to players; use with GUISprite / Draw3DSprite.
<font>file(0.5) A .ttf / .otf / .ttc font under Scripts/<folder>/Fonts/. Downloaded to players (PC and Android) before the client scripts run; use it as FontName = "pricedown.ttf" (also "pricedown" or the font's family name, for example "Pricedown").
<sound>fileAn .mp3 in the server's Sounds/ folder, downloaded to players for FindSound on the client.
<vehicle>model name dff txd hanRegisters a custom vehicle (see Custom vehicles below).
<skin>id dff txdRegisters a custom skin, id 200-299 (see Custom skins below).
<weapon>id name slot data dff txd model ...(0.5-rc1) Registers a custom weapon (see Custom weapons below).
<script file="Server.nut" client="0" />
<script file="Client.nut" client="1" />
<script dir="client" client="1" recursive="1" />
<script dir="lazy" client="1" load="0" />
<sprite file="logo.png"/>
<font file="pricedown.ttf"/>
<sound file="siren.mp3"/>
<vehicle model="4000" name="Sultan" dff="sultan.dff" txd="sultan.txd" han="handling.cfg" />

Custom vehicles. model is a free id from 4000 to 5499. The .dff base name (for example sultan) selects the vanilla vehicle whose collision, wheels and handling defaults the new car inherits; name is shown in-game when entering it. File paths are relative to the script folder. Create one with CreateVehicle(4000, ...).

A vehicle that is not a copy of a vanilla car needs base (the vanilla car it inherits doors, components and wheels from, for example base="sentinel"), usually a col file (a COL archive holding a model named like the dff), wheel / wheelscale, and a handling line in han. Ambient traffic (0.4.6): class (poorfamily, richfamily, executive, worker, special, big or taxi; anything else means no traffic) and freq (how many copies go into that class table, the higher the more often it spawns) put the car into the game's own traffic; level is the island bit mask (1 Portland, 2 Staunton, 4 Shoreside), comprules the hex component rules of an IDE line and colours="c1,c2 c1,c2 ..." up to 8 colour pairs of the game's colour table. All clients create the same cars, the traffic sync carries the model as the server id. A beta cars pack built this way: tools/build_betacars_pack.py.

Vehicle and object ids are separate (0.4.6). A car mod and a map mod may both use 4005: CreateVehicle(4005, ...) is always the car and CreateObject(4005, ...) / an IPL line / a pickup always the map object. Before, the second of the two was dropped ("id is already used", missing objects in Upstate Liberty). The files of the second one travel under an internal key; nothing changes for scripts.

<skin id="200" dff="skins/doomer.dff" txd="skins/doomer.txd" />

Custom skins. id is 200 to 299 (at most 100 skins). dff and txd are both required and are relative to the script folder; the dff must be a normal GTA III ped model. Players download them when they join (PC and Android). Use the id like any skin: player.Skin = 200, npc.Skin = 200, a spawn class skin, or CreateNPC(200, ...). Other players see the skin too.

<object id="3296" dff="sol/liisle.dff" txd="sol/missliberty.txd" col="autogen" dist="299" />

Custom map objects. id is the model id (1 to 5499) the object is registered at, so a map .ipl in LU/data/maps (or CreateObject) can place it by that id; it must be unused in the player's game. dff and txd are relative to the script folder. col is none (default, no collision), autogen (collision built from the model, an exact triangle mesh; very small faces are left out) or a .col file. dist is the draw distance (default 299; use more than 300 only for a far LOD stand-in) and flags the IDE flags. Objects are downloaded with the vehicles and skins, registered before the map IPLs are placed, and survive island changes and /reconnect.

<weapon id="13" name="M60" slot="5" data="m60.dat" dff="m60/m60.dff" txd="m60/m60.txd" model="4300"
        pickupcolor="255,200,0" sounds_folder="m60" />
<weapon id="14" name="Minigun" slot="6" data="mini.dat" shot_sound="mini/shot.wav" reload_sound="mini/reload.wav"
        hud_icon_texture="mini/icon.png" />
<weapon id="6" name="Old M16" data="m16.dat" />

Custom weapons (0.5-rc1). A <weapon> tag adds a weapon the game does not have, or replaces a stock one, for everybody on the server (PC and Android). id 13 to 64 is a new weapon with that id (v0.5.1; before it was 13 to 15) (id 12 stays the detonator); an id from 1 to 11 replaces that stock weapon. name gives the constant WEP_<NAME> (upper case, anything that is not a letter or digit becomes _; for example WEP_M60), the name for GetWeaponID("M60") and the name of its line in the weapon data file. Up to 64 weapons per server.

slot (new weapons, 1 to 11): the stock weapon slot the new weapon rides in. The game keeps 13 weapon slots and a new weapon takes the one named here: while a player owns the custom weapon he does not also carry the stock weapon of that slot (the custom one takes its place). The slot also decides the behaviour the game gives the weapon - the fire animation set, the aiming camera, the crosshair - so pick a slot whose stock weapon is like yours: 2 pistol, 3 uzi, 4 shotgun, 5 AK-47 style rifle, 6 M16 style rifle, 7 sniper. Slots 1 and 8 to 11 (bat, launcher, flamethrower, throwables) have special handling; the server warns when you pick one. A replacing weapon (id 1 to 11) needs no slot.

data is a vanilla weapon.dat line (the numbers: fire type, range, rate, reload, ammo per clip, damage, speed, radius, lifespan, spread and the fire offset - the muzzle flash and the shot start at that offset, move it when the flash is in the wrong place) for this weapon. The line named like the weapon is used, or the only line of the file. The same numbers can be changed later with SetWeaponData("m60.damage", 40).

dff / txd / model register the weapon's hand model: model is a free model id (a custom object id, 1 to 26999) under which the .dff and .txd are registered. The dff is one atomic, like the models in weapons.dff; the textures it uses must be inside the txd. Without them the weapon keeps the stock model of its slot. pickupcolor (r,g,b, 0 to 255 each) is the colour the weapon's pickup glows in (light, corona and halo); the pickup itself is made with CreateWeaponPickup(WEP_M60, Vector(x, y, z), 250). A weapon needs a model for that.

shot_sound / reload_sound / hud_icon_texture are the files of the shot sound (PCM .wav, 8 or 16 bit), the reload sound and the HUD icon (png, about 64 x 64) relative to the script folder; sounds_folder="m60" looks for shot.wav, reload.wav and icon.png inside that folder instead. The game itself is silent for a custom weapon, so these sounds are the only ones. Shots of other players fade out with the distance.

Give the weapon with player.SetWeapon(WEP_M60, 300); GetWeaponID("M60") and the numeric id work too. The player's Weapon and WeaponAmmo properties, onPlayerWeaponChange and the damage events use the custom id (13 to 64). The weapon switches with the normal weapon keys, shows its own icon and crosshair and shoots like its slot's stock weapon (instant hit). NPCs and bots can only use weapons 0 to 12.

Categories: Getting started