Server Admin Remote Scriptlet

From ALFA
Jump to: navigation, search

Server Admin Remote Scripelets are tools to access PowerShell, NWScript, and other useful tools.

Only those who have server admin access, as defined in SQL, may use the following commands.

General Commands

Command Example Description
#sa rs [scriptlet] #sa rs $s.GetTag( $OBJECT_TARGET ); Run a PowerShell/NWScript scriptlet. The $s object can be used to access NWScript functions, like $s.SendMessageToPC($OBJECT_SELF, 'Message');. The $sql object (an ALFA.Database) can be used to make database accesses. The $CreatureAI object can be used to interface with the creature AI system. See Remote Scriptlets below.
#sa runscript [scriptname] #sa runscript 010_kill_all_pcs Run a script by name.
#sa getglobalint [var] #sa getglobalint ACR_IMPORTANT_VARIABLE Read a variable. getglobalint may be replaced by getglobalfloat, getglobalstring, getmoduleint, getmodulefloat, getmodulestring, or getmoduleobject.
#sa loadscript [C# Script DLL Path] Load a C# script assembly and call its main function.
#sa boot [accountname] #sa boot FoamBats4All Boot a PC by account name (insensitive).
#sa dumpvars [object] #sa dumpvars #module Dump variables on an object (by hex object id, tag, #module, #self, or #area).
#sa dumpareas #sa dumpareas Dump a list of areas in the module.
#sa dumpareaobjects [area] #sa dumpareaobjects #area Dump objects in an area (area specified by hex object id, tag, #module, #self, or #area).
#sa runupdater #sa runupdater Run the ACR_UpdaterScript.cmd batch file in the NWNX4 installation directory (if it exists).
#sa jump [object] #sa jump 010_wp_bg_docks_start Jump to an object (by hex object id or tag).
#sa compilerlog #sa compilerlog Show last module recompilation log file.


Remote Scriptlets

The #sa rs command is rather powerful, able to accomplishing anything on a server, with enough technical knowledge. NWScript functions can be called by using $s.[FunctionName]( [Parameters] );.

Special Words

Placing these in your scriptlet will provide a special target or value.

Command Description
$CreatureAI Refers to the AIServer object.
$OBJECT_SELF Refers to you, or what you are currently controlling.
$OBJECT_TARGET Refers to the currently selected target. A target can be defined by right clicking them, as you would as a player.
$OBJECT_INVALID An invalid object.
$s The scripting environment. This can be used to reference NWScript constants and functions.
$sql References the SQL database object, for calling queries.

Useful Commands

Below are some commands used by HDMs, as well as a description of what they do.

Command Description
#sa rs $s.ClearScriptParams(); $s.AddScriptParameterObject( $OBJECT_TARGET ); $s.AddScriptParameterInt( 0 ); $s.AddScriptParameterInt( [X] ); $s.AddScriptParameterInt( 0 ); $s.ExecuteScriptEnhanced( "ACR_Items", $OBJECT_SELF, 1 ); Alters an item's price by [X]. For instance, a value of -1283 would adjust the item's value by negative 1283 gold. The total price must be a 32 bit integer (-2,147,483,648 to 2,147,483,647) as must the amount to adjust by. Going beyond these values will corrupt the item and either cause it to be destroyed or cause instability in the server.
#sa rs $s.ApplyEffectToObject( $s.DURATION_TYPE_INSTANT, $s.EffectDamage( [DAMAGE], $s.DAMAGE_TYPE_MAGICAL, $s.DAMAGE_POWER_NORMAL, $s.TRUE ), $OBJECT_TARGET, 0.0 ); Deals [DAMAGE] damage to the currently selected object.
#sa rs $s.CreateItemOnObject( "[ITEM_RESREF]", $OBJECT_SELF, 1, "", 1 ); Creates a single item with ResRef [ITEM_RESREF] on the currently controlled character.
#sa rs $s.GetResRef( $OBJECT_TARGET ); Returns the ResRef of the currently selected object.
#sa rs $s.NWNXSetString( "OBJECTATTRIBUTES","SetWingVariation","",$s.ObjectToInt($OBJECT_TARGET), 16 ); As an example, this would provide wings of ID 16 to the currently selected object. With tweaking, this command could set a hair style, or head variation.
#sa rs $s.SetCollision( $OBJECT_TARGET, 0 ); Turns collision off on the currently selected targets.
#sa rs $s.SetWeather( $s.GetArea( $OBJECT_SELF ), 0, 0 ); Make it stop raining in the current area. Change the last parameter to 0-15 to indicate the strength of rain, with 0 being none and 15 being stormy.
#sa rs foreach( $object in $s.GetItemPropertiesOnItem( $s.GetPlayerCurrentTarget( $OBJECT_SELF ) ) ) { if( $s.GetItemPropertyType( $object ) -eq 21 ) { $s.RemoveItemProperty( $s.GetPlayerCurrentTarget( $OBJECT_SELF ), $object); } } $s.DeleteLocalInt( $OBJECT_TARGET, "ACR_NLD_DAMAGE_PENALTY" ); Strip the damage penalty properties from a targeted item.
#sa rs foreach( $object in $s.GetItemPropertiesOnItem( $s.GetPlayerCurrentTarget( $OBJECT_SELF ) ) ) { if( $s.GetItemPropertyType( $object ) -eq 82 ) { $s.RemoveItemProperty( $s.GetPlayerCurrentTarget( $OBJECT_SELF ), $object ); } } Strip on hit cast spell (like, say, a subdual item's unique power) from a targeted item.
#sa rs foreach($object in $s.GetEffects($OBJECT_TARGET)) { $s.RemoveEffect($OBJECT_TARGET, $object); } Remove all effects from the selected object.
#sa rs $s.ClearScriptParams(); $s.AddScriptParameterInt(999); $s.AddScriptParameterString(""); $s.AddScriptParameterInt(0); $s.AddScriptParameterString(""); $s.ExecuteScriptEnhanced("ACR_Quest", $OBJECT_SELF, 1); Send the details about all infestations currently on the server to the DM channel.
#sa rs $s.ClearScriptParams(); $s.AddScriptParameterInt(2); $s.ExecuteScriptEnhanced("ACR_Candlekeep", $OBJECT_SELF, 1); Send the details about all areas and their connecting transitions to the DM channel.
#sa rs $sql.ACR_SQLQuery("SELECT pwdata.Name, pwdata.Tag, pwdata.Value, characters.ID, characters.Status, characters.PlayerID FROM characters JOIN players on players.ID=characters.PlayerID JOIN pwdata on pwdata.Name=characters.Name WHERE pwdata.Tag=players.CDKey and pwdata.`Key`='ACR_DTH_LOCATION' and characters.ServerID='10' and characters.Status=characters.Status|1;"); while($sql.ACR_SQLFetch()) { $object = $s.CreateObject(64, "abr_pl_co_so_pccorpse", $sql.ACR_StringToLocation($sql.ACR_SQLGetData(2)), 0, $sql.ACR_SQLGetData(1)); $s.SetLocalInt($object, "ACR_CID", $s.StringToInt($sql.ACR_SQLGetData(3))); $s.SetLocalInt($object, "ACR_PID", $s.StringToInt($sql.ACR_SQLGetData(5))); $s.SetLocalString($object, "ACR_PSO_NAME", $sql.ACR_SQLGetData(1) + "_" + $sql.ACR_SQLGetData(3)); $s.SetFirstName($object, $sql.ACR_SQLGetData(0)); } Place all known corpses into play, if they failed to spawn on server startup.