### Enable and Start SphereServer Service Source: https://github.com/sphereserver/source-x/blob/master/README.md Enables the SphereServer service to start on boot and then starts the service. This is done after installation to ensure SphereServer runs as a background service. ```bash sudo systemctl enable sphereserver sudo systemctl start sphereserver ``` -------------------------------- ### Install MariaDB Client on Ubuntu Source: https://github.com/sphereserver/source-x/blob/master/docs/Getting-started.md Installs the necessary MariaDB client library for the server to function correctly on Ubuntu-based systems. ```bash sudo apt install mariadb-client ``` -------------------------------- ### SAY Command Example Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-56b-PreRelease.txt Example of using the SAY command with message override syntax. ```plaintext SAY @022,,3 1008097,01,MrSugarCube ``` -------------------------------- ### Localized Message Formatting Examples Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-56b-PreRelease.txt Examples showing how to use '@color,font,mode' for localized messages, including specifying unicode or localized message modes. ```script "SYSMESSAGE @,,2 502771" ``` ```script "SYSMESSAGE @2,,2 1042758,MrSugarCube" ``` ```script "SYSMESSAGE @,,2 1062695,MrSugarCube,4,5" ``` -------------------------------- ### Menu Item Coloring Example Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-56b-PreRelease.txt Shows how to color menu items by prefixing the description with '@color'. ```script ON=i_sword_viking @2 This is a viking sword ``` -------------------------------- ### SYSMESSAGELOCEX Example 2 Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-56b-PreRelease.txt Example of SYSMESSAGELOCEX prepending text. ```plaintext SYSMESSAGELOCEX -1,3002003,00,Smoking is bad for your health ``` -------------------------------- ### Sphere Server Configuration Example Source: https://github.com/sphereserver/source-x/blob/master/docs/Getting-started.md Illustrates the basic structure of the sphere.ini file, showing sections, comments, and property settings. ```ini [SPHERE] // Name of your Sphere shard ServName=MyShard ``` -------------------------------- ### Install Build Tools and MariaDB on CentOS/RHEL/Fedora Source: https://github.com/sphereserver/source-x/blob/master/README.md Commands to install necessary build tools and MariaDB client development packages using yum or dnf on CentOS, RHEL, or Fedora systems. ```bash git cmake glibc-devel mariadb-connector-c mariadb-connector-c-devel ``` -------------------------------- ### Install Debian Package Source: https://github.com/sphereserver/source-x/blob/master/README.md Installs a downloaded or built SphereServer Debian package. This command also handles downloading necessary dependencies and setting up the service. ```bash sudo apt install FILENAME.DEB ``` -------------------------------- ### SYSMESSAGELOCEX Example 1 Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-56b-PreRelease.txt Example of SYSMESSAGELOCEX appending text. ```plaintext SYSMESSAGELOCEX -1,1008078,01,MrSugarCube ``` -------------------------------- ### Install Build Tools and MariaDB on Ubuntu/Debian Source: https://github.com/sphereserver/source-x/blob/master/README.md Commands to install essential build tools like Git and CMake, along with MariaDB client libraries required for compilation on Ubuntu and Debian-based systems. ```bash sudo apt-get install git cmake sudo apt-get install libmariadb-dev libmariadb3 ``` -------------------------------- ### NPC Spell Casting Logic Example Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-56c-PreRelease.txt Provides an example of how to implement custom spell casting logic for NPCs using the @NPCActFight trigger. This example checks for magery and attempts to cast a spell if possible. ```text ON=@NPCActFight if ( > 0) local.spell= while ( < 64) if (>) local.skill=magery return 2 else local.spell ++ endif endwhile endif //same for the other magic skills. ``` -------------------------------- ### Example Custom Monster Animation Configuration Source: https://github.com/sphereserver/source-x/blob/master/Changelog.txt Example of how to set custom animation flags for a MONSTER (H slot) with specific actions like flying and casting, but not pillaging. ```plaintext ANIM=020A0 ``` -------------------------------- ### DAMAGE Function Syntax and Example Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-56c-PreRelease.txt Demonstrates the syntax for the DAMAGE function, including new optional arguments for elemental damage distribution. Use this to apply damage with specific elemental percentages. ```script Sintax: DAMAGE value, dam_flag, source, physical(%), fire(%), cold(%), poison(%), energy(%) Example: DAMAGE 50,dam_general,012345,70,30,0,0,0 will split 50 damage into 70% physical damage + 30% fire damage ``` -------------------------------- ### String Substring Function Example Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-55-SERIES.txt Illustrates the function for extracting a substring of a specified length starting from a given position. ```SphereScript ``` -------------------------------- ### Tooltip Object Properties Example Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-56b-PreRelease.txt Shows how to define tooltips for objects using the OBJPROPS property. Tooltips are sent in alphabetical order of their defined names. ```script OBJPROPS.a="1048032" // a bag OBJPROPS.b="1050044,32,450" // ~1_COUNT~ items, ~2_WEIGHT~ stones ``` -------------------------------- ### C-style Cast Example Source: https://github.com/sphereserver/source-x/blob/master/README.md Demonstrates the use of C-style casts for type conversion, which is preferred for conciseness in SphereServer development. ```c++ static_cast(value) ``` -------------------------------- ### SYSMESSAGELOC Syntax and Examples Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-56b-PreRelease.txt Demonstrates the syntax and usage of the SYSMESSAGELOC function for sending localized messages to clients, including color and argument specifications. ```script "SYSMESSAGELOC color,clilocid[,arguments]" ``` ```script "SYSMESSAGELOC -1,502771" - Displays "You cannot reach that." ``` ```script "SYSMESSAGELOC 2,1042758,MrSugarCube" - Displays "You are now loyal to MrSugarCube." in blue ``` ```script "SYSMESSAGELOC -1,1062695,MrSugarCube,4,5" - Displays "MrSugarCube rolls the dice and gets a 4 and a 5!" ``` -------------------------------- ### SENDPACKET Command Example Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-55-SERIES.txt Demonstrates the SENDPACKET command for clients, showing how to send WORD (W), DWORD (D), and BYTE (B) values. Prefixes specify the data type and size. ```SphereScript SRC.SENDPACKET 04e D 20 ``` -------------------------------- ### Subscribe Components to Item Source: https://github.com/sphereserver/source-x/blob/master/Changelog.txt Example of adding CCSpawn and CCChampion components to a CItem during its creation. This demonstrates the new ECS architecture. ```cpp case IT_SPAWN_CHAMPION: { pItem = new CItem(id, pItemDef); pItem->SubscribeComponent(new CCSpawn(pItem)); pItem->SubscribeComponent(new CCChampion(pItem)); break; } ``` -------------------------------- ### Example of multi-column text layout with dtext Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-55-SERIES.txt Demonstrates how to create a multi-column layout for text within a gump using dtext commands. Each column is offset by a specified x-coordinate. ```Sphereserver Script dorigin 10 10 // first row dtext *0 - 5 1: dtext +10 - 0 the text for row1, col1 dtext *200 - 5 2: // x orig = 200 dtext +10 - 0 the text for row1, col2 dtext *200 - 5 3: // x orig = 400 dtext +10 - 0 the text for row1, col2 ``` -------------------------------- ### FORINSTANCES Usage Example Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-56b-PreRelease.txt Loops through all instances of a given BaseID for items and characters. If no ID is supplied, the default object's BaseID is used. ```script FORINSTANCES id ``` -------------------------------- ### Traditional Type Casting Example Source: https://github.com/sphereserver/source-x/blob/master/docs/typecast.html Demonstrates traditional type casting for basic types like double to int using C-style and functional casting. ```C++ int i; double d; i = (int) d; or also i = int (d); ``` -------------------------------- ### Champion Definition Example Source: https://github.com/sphereserver/source-x/blob/master/Changelog.txt Defines a champion with its name, maximum levels, total spawns, NPC groups for each level, and the boss NPC ID. This section is used to configure champion behaviors. ```ini [CHAMPION 01] DEFNAME=CHAMPION_Abyss NAME=Abyss LevelMax=5 Spawns=100 NPCGroup[1] = c_mongbat, c_imp NPCGroup[2] = c_gargoyle, c_harpy NPCGroup[3] = c_gargoyle_fire, c_gargoyle_stone NPCGroup[4] = c_daemon, c_succubus CHAMPIONID=c_semidar ``` -------------------------------- ### Sphere.ini Feature Flags Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-55-SERIES.txt Configuration example for enabling specific server features for clients via the FEATURES= setting in sphere.ini. Each bit corresponds to a feature. ```INI FEATURES=0001 0001 - (T2A) enables chatbutton 0002 - (LBR) enables LBR sound (plays MP3s instead of MIDI) 0004 - (T2A) enables T2A update 0008 - (LBR) enables LBR update (shows monsters) Standard .55i automatically enabled 0001 - but you could disable it. ``` -------------------------------- ### Generate Makefiles with CMake CLI Source: https://github.com/sphereserver/source-x/blob/master/README.md Example command to generate Unix Makefiles for a 64-bit Nightly build on Linux using CMake CLI. Ensure you are in the project's root folder. ```bash mkdir build cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/Linux-GNU-x86_64.cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Nightly" -B ./build -S ./ ``` -------------------------------- ### MySQL Multi-Row Query Example Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-56b-PreRelease.txt Illustrates querying multiple rows from a MySQL database and iterating through rows and columns to access data. Supports accessing fields by column number or row and column number. ```script DB.connect if ( ) db.query "SELECT * FROM mytable" for R 0 -1> SERV.log "--- ROW #> ---" for C 0 -1> SERV.log ".. COLUMN # : >.>>" end end endif ``` -------------------------------- ### Conditional Difficulty Adjustment Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-55-SERIES.txt Example of adjusting skill difficulty dynamically using ACTDIFF before skill start triggers. ```script ON = @Start if ( < ) SRC.ACTDIFF = endif ``` -------------------------------- ### String Position Function Example Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-55-SERIES.txt Demonstrates the usage of the function to find the position of a character within a string, starting from a specified index. ```SphereScript ``` ```SphereScript ``` -------------------------------- ### MySQL Database Object Example Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-56b-PreRelease.txt Demonstrates basic MySQL interaction using the DB script object, including connecting, querying, and logging results. Ensure DB.connect is added to f_onserver_start for server-initiated connections. ```script DB.query "SELECT id FROM users WHERE account=''" SERV.log "Got ID = " ``` -------------------------------- ### Accessing SKILLMAKE Resources Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-55-SERIES.txt Demonstrates how to access individual resources within the SKILLMAKE list for a skill. ```script SKILLMAKE.1 // gets the first resource SKILLMAKE.1.VAL // gets the value SKILLMAKE.1.KEY // gets the associated resource key ``` -------------------------------- ### Character Trigger Examples Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-56b-PreRelease.txt Examples of character triggers that function similarly to item triggers but operate on NPCs. ```script @charAttack, @charClick, @charClienttooltip, @charDClick ``` -------------------------------- ### Crafting Skill EFFECT Property Examples Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-56b-PreRelease.txt Examples demonstrating the use of the EFFECT property in crafting skills to define resource loss percentage on failure. ```script "EFFECT=x" - Always lose x% of resources on fail ``` ```script "EFFECT=x,y" - Lose between x% and y% of resources on fail ``` ```script "EFFECT=x,y,z" - Lose between x% and z% of resources on fail (weighted by y) ``` -------------------------------- ### Configuring CMake for Build Directory Source: https://github.com/sphereserver/source-x/blob/master/lib/cdrc/cdrc/README.md Basic steps to configure the CMake project for building, including creating a build directory and running CMake and make commands. ```bash mkdir build cd build cmake .. make ``` -------------------------------- ### @EffectRemove Trigger Example Source: https://github.com/sphereserver/source-x/blob/master/Changelog.txt Example of using the @EffectRemove trigger for characters. It fires when a spell memory item is removed. Returning 0 prevents default spell behavior. ```plaintext - Added @EffectRemove trigger for characters, Argo: the spell item. Src: the caster. Default object: the target of the spell. Argn1: the spell number. Return 0: remove the spell memory item but don't execute the default spell behaviour when the spell item is removed. The trigger works similarly to @EffectAdd but is fired when a spell memory item is removed (and after the @Destroy trigger of the item) The trigger is needed if you plan to use return 0 in the @EffectAdd trigger, otherwise the default spell behaviour will be executed when the spell item get removed. Example I cast a curse spell and I have a return 0 in my @EffectAdd trigger, no default curse effect are applied but when the spell expires the curse item will be removed and the spell target will get the additional stats from the expired curse! Using return 0 in @EffectRemove will prevent this Additional notes: Both @EffectAdd and @EffectRemove with return 0 can conflict with Poison and Poison Fields spells or scripts that call the poison function, that's because the poison status and effect is applied no matter what. For Summoning spells, returning 0 in @EffectRemove will prevent the summon to disappear. ``` -------------------------------- ### Configuring New Door System Properties Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-56c-PreRelease.txt Shows how to configure new door system properties using ITEMDEF or game item attributes. This includes sounds, target item IDs, and positional changes. ```script -Game Item: (if no info here, use ITEMDEF info) -DOOROPENID=0676 //ID to change into (no DEFNAME as it's only used for dispid) -MOREX=-1 // X position change -MOREY=1 // Y position change -DOORCLOSESOUND=00f3 closing sound -DOOROPENSOUND=00eb opening sound -ITEMDEF: (if no info here and on game item, use default system) -TDATA1=00eb00f3 //WORD open | WORD close (sounds) -TDATA2=0676 //ID to change into (no DEFNAME as it's only used for dispid) -TDATA3=-1 // X position change -TDATA4=1 // Y position change ``` -------------------------------- ### Scripting: REAPAMOUNT / AMOUNT with Multi-Point Values Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-55-SERIES.txt REAPAMOUNT and AMOUNT can now accept multi-point values, similar to the ADVANCE command for skills. ```csharp // Fixed REAPAMOUNT / AMOUNT. It can now take multi-point values in a format similar to // ADVANCE for skills. ``` -------------------------------- ### OPENPAPERDOLL Function Usage Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-56b-PreRelease.txt Examples of using the OPENPAPERDOLL function to display character paperdolls. ```script OPENPAPERDOLL ``` ```script OPENPAPERDOLL with the UID of a character ``` -------------------------------- ### Const Cast Example Source: https://github.com/sphereserver/source-x/blob/master/docs/typecast.html Shows how const_cast can be used to remove the const attribute from a pointer. ```C++ class C {}; const C * a = new C; C * b = const_cast (a); ``` -------------------------------- ### Party Creation Command Syntax Source: https://github.com/sphereserver/source-x/blob/master/Changelog.txt Defines the syntax for the PARTY.CREATE command, which allows creating a party with specified members. The 'msg' argument controls system messages, and subsequent arguments are player UIDs. ```plaintext The command syntaxis: PARTY.CREATE msg,uid(s). Where msg is 0/1 sending default sysmessages or not, the following args (up to 9 more) is/are the players to add to this party. Note that by using PARTY.CREATE the player will be forced to enter the party, so you need to add your own "acceptance system". ``` -------------------------------- ### Get Static Item Properties Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-56b-PreRelease.txt Retrieves the color and height (Z coordinate) of static items. ```script P.STATICS.x.COLOR P.STATICS.x.Z ``` -------------------------------- ### CONTCONSUME Function Example Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-56b-PreRelease.txt Consumes a specified amount of an item from a container and its subcontainers. Does not work on characters or non-container items. ```script CONTCONSUME ``` ```script findlayer.29.contconsume i_gold 100000 ``` -------------------------------- ### Enable Automatic Account Creation Source: https://github.com/sphereserver/source-x/blob/master/docs/Getting-started.md Set the AccApp property to 2 in your configuration file to allow any user to log in and create a new account. ```ini //Code for servers account application process // 0=Closed, // Closed. Not accepting more. // 2=Free, // Anyone can just log in and create a full account. // 3=GuestAuto, // You get to be a guest and are automatically sent email with u're new password. // 4=GuestTrial, // You get to be a guest til u're accepted for full by an Admin. // 6=Unspecified, // Not specified. // To enable auto account you must set this to 2 AccApp=2 ``` -------------------------------- ### NPC Movement Delay Override (Milliseconds) Source: https://github.com/sphereserver/source-x/blob/master/Changelog.txt Use tag.override.movedelay (msec) for NPCs to completely override moverate checks and set the next movement to the given timer. Notes: The final value, with or without tags, running or walking, can't be lower than 1 tenth of second or higher than 5 seconds for the moment until we check the performance impact of lower values. This is the walking speed, running speed and walking speed while mounted is the half (125 instead of 250 msecs using the previous example), running while mounted is 4 times faster (62.5msecs (rounded to 62), defaulted to 100 because of the tenth's limit)). Settig this tag completelly overrides default moverate checks, TAG.OVERRIDE.MOVERATE gets ignored too. ```SphereScript tag.override.movedelay (msec) for NPCS overriding completelly the moverate checks and setting the next movement to the given timer, eg 'tag.override.moverate=250' makes the npc move each 250 milliseconds when walking. ``` -------------------------------- ### SphereServer Startup Confirmation Source: https://github.com/sphereserver/source-x/blob/master/docs/Getting-started.md This message indicates a successful server startup. It confirms the number of items, characters, and accounts loaded. ```plaintext Startup complete (items=0, chars=0, Accounts = 0) Use '?' to view available console commands ``` -------------------------------- ### Configuring CMake for Debug Build Source: https://github.com/sphereserver/source-x/blob/master/lib/cdrc/cdrc/README.md Example of configuring the CMake project for a Debug build by adding the `-DCMAKE_BUILD_TYPE=Debug` flag to the CMake command. ```bash cmake .. -DCMAKE_BUILD_TYPE=Debug ``` -------------------------------- ### Get Ship Direction Command Source: https://github.com/sphereserver/source-x/blob/master/Changelog.txt The DIRMOVE command is a read-only command for ships that returns the direction (0-8) in which the ship is currently moving. ```script DIRMOVE ``` -------------------------------- ### Delayed sort optimization using .container Source: https://github.com/sphereserver/source-x/blob/master/lib/flat_containers/flat_containers/README.md Demonstrates how to use the .container member to push elements and then sort them manually, utilizing the delayed sort optimization. ```cpp std::flat_multiset set; while(cpu_temperature() < 100) set.container.push_back(cpu_temperature()); std::sort(set.begin(), set.end()); ``` -------------------------------- ### Check SphereServer Service Status Source: https://github.com/sphereserver/source-x/blob/master/README.md Checks the current status of the SphereServer service. This command can be used to verify if the service is running correctly after starting it. ```bash systemctl status sphereserver ``` -------------------------------- ### Create Party with System Messages Option Source: https://github.com/sphereserver/source-x/blob/master/docs/Changelog-56c-PreRelease.txt Adds the party.create message argument, where 0 disables default system messages and 1 enables them. Subsequent arguments specify players to add to the party. ```script party.create msg,uid(s) ``` -------------------------------- ### Using .has and .operator[] for map manipulation Source: https://github.com/sphereserver/source-x/blob/master/lib/flat_containers/flat_containers/README.md Demonstrates how to insert elements into a map using operator[] and how to safely check for and modify values using the .has method. ```cpp map["foo"] = "bar"; if(std::string* value = map.has("qux")) *value = "baz"; ``` -------------------------------- ### Make Debian Package Executable Source: https://github.com/sphereserver/source-x/blob/master/README.md Changes the file permissions of the downloaded or built Debian package to make it executable. This is a prerequisite before installing the package. ```bash sudo chmod +x FILENAME.DEB ``` -------------------------------- ### Add Client Tooltip Triggers and Functions Source: https://github.com/sphereserver/source-x/blob/master/Changelog.txt Introduces @ClientTooltip_AfterDefault trigger and REMOVECLILOC/REPLACECLILOC functions for customizing tooltips. CLILOCLIST, CLILOCCOUNT, and CLILOC.n[.ID|.VAL] are added to manage clilocs. ```lua ARGN2 = 1 //Force to ignore attacker. ARGN2 = 0 //Force to unignore attacker. ``` ```lua CLILOCLIST on objects to get list of the clilocs. CLILOCCOUNT and CLILOC.n[.ID|.VAL] to get clilocs. ``` -------------------------------- ### Ship Stop Trigger Example Source: https://github.com/sphereserver/source-x/blob/master/Changelog.txt The @Ship_Stop trigger fires when a ship stops. It can be used to check if the ship is moving or not. The UID of the ship is passed as an argument. ```script on=@Ship_Stop (UID/I = Ship) TAG0.SHIPMOVE= ``` -------------------------------- ### Enable Nightly Build Usage Source: https://github.com/sphereserver/source-x/blob/master/docs/Getting-started.md Adds the AGREE=1 line to the SPHERE section of sphere.ini to acknowledge the use of a nightly build. Remember to save the file after making changes. ```ini ... [SPHERE] // Add this line AGREE=1 // Name of your Sphere shard ServName=MyShard ... ```