C# Class ALFA.Database

This class encapsulates database access for ALFA CLR scripts. Unlike the ad-hoc ALFA.MySQLDatabase class, this class supports a single, "canonical" standard default database connection with the following properties: - There is only one underlying connection so queries are completed in order. - The combined query queue ("ACR_AsyncSQLQuery[Ex]") is synchronized with queries issued on an ALFA.Database object. - All instances of ALFA.Database are synchronized with one another. Generally, "state changing" queries that have to synchronize with the updates performed via NWScript must go through this query. Queries that may be processed independently, e.g. the GameWorldManager in the ACR_ServerCommunicator, may use a standalone connection instead for better performance if they do not require synchronization with the canonical database connection.
Inheritance: IALFADatabase
Afficher le fichier Open project: ALandFarAway/ALFA-Base-Resources Class Usage Examples

Méthodes publiques

Méthode Description
ACR_AsyncSQLQuery ( string Query ) : void

Perform an asynchronous database query. The query is added to the module object's query queue.

ACR_AsyncSQLQueryEx ( string Query, UInt32 QueueTo, ACR_QUERY_FLAGS Flags = ACR_QUERY_FLAGS.None ) : void

Perform an asynchronous database query. The query is added to a specific object's query queue (must be a PC or the module).

ACR_ConvertDatabaseStringToBoolean ( string Str ) : bool

Convert a database string to a Boolean value.

ACR_DeletePersistentVariable ( UInt32 Object, string VarName ) : void

Delete a persistent record.

ACR_FlushAllQueryQueues ( ) : void

Flush all query queues in the system out to the database.

ACR_FlushQueryQueue ( uint ObjectToFlush ) : void

This routine flushes the query queue for an object. It is useful, for example, in server portal scenarios. Normally, the query queue is flushed automatically.

ACR_GetBuildDate ( ) : string

Get the build date of the module OnLoad script (i.e. the time at which the module had its scripts nominally compiled).

ACR_GetCharacterID ( UInt32 PCObject ) : int

This routine returns the database character ID for a player given their PC object id.

ACR_GetHAKBuildDate ( ) : string

Get the build date of the HAK version check script (i.e. the time at which the ACR HAK had its scripts nominally compiled).

ACR_GetHAKVersion ( ) : string

Get the version string of the ACR release that the HAK corresponds to. For example, "1.84".

ACR_GetIsMember ( UInt32 PCObject ) : bool

Returns whether a PC is a fully approved ALFA member (vs. a new account that might be a throw-away, etc.).

ACR_GetIsPCQuarantined ( UInt32 PCObject ) : bool

Return whether a PC is quarantined.

ACR_GetPCLocalFlags ( UInt32 PCObject ) : int

Return the current PC local flags value for a PC.

ACR_GetPersistentFloat ( UInt32 Object, string VarName ) : float

Retrieve a float from the persistent store.

ACR_GetPersistentInt ( UInt32 Object, string VarName ) : int

Retrieve an int from the persistent store.

ACR_GetPersistentLocation ( UInt32 Object, string VarName ) : NWScript.NWScriptEngineStructure2

Retrieve a location from the persistent store.

ACR_GetPersistentString ( UInt32 Object, string VarName ) : string

Retrieve a string from the persistent store.

ACR_GetPersistentVector ( UInt32 Object, string VarName ) : System.Vector3

Retrieve a vector from the persistent store.

ACR_GetPlayerID ( UInt32 PCObject ) : int

This routine returns the database player ID for a player given their PC object id.

ACR_GetServerAddressFromDatabase ( ) : string

This routine queries the database in order to return the public IP address of the game server host.

ACR_GetServerID ( ) : int

This routine returns the database server ID of the current server.

ACR_GetVersion ( ) : string

Get the version string of the ACR release that the module was compiled against. For example, "1.84".

ACR_IncrementStatistic ( string Statistic ) : void

Increment a global tracking statistic counter stored in the database (if statistic tracking was enabled).

ACR_IsServerAdmin ( UInt32 PCObject ) : bool

This routine determines whether a player is a server admin for the current server.

ACR_LocationToString ( NWScript.NWScriptEngineStructure2 Location ) : string

This routine packages a location object into a string.

ACR_LogEvent ( uint Character, string EventName, string EventDescription, uint DM ) : void

Log an event to the database log.

ACR_PCSave ( uint PCToSave, bool Export, bool SaveLocation ) : void

This routine performs a character save.

ACR_PCUpdateStatus ( uint PCToUpdate, bool UpdateLocation ) : void

This method updates regularly-saved persistent information.

ACR_PPSValidatePC ( uint PCToValidate ) : void

This routine validates a character from quarantine.

ACR_RestOnClientEnter ( uint PCToRest ) : void

This method calculates offline resting for a PC after logging in.

ACR_RunScriptOnServer ( int DestinationServerID, string ScriptName, string ScriptArgument ) : bool

Run a script on a remote server. The script must exist on the server. If acknowledgement is desired, it must be implemented in the form of a reply IPC request initiated by the script invoked. A script executed by this function must follow this prototype: void main(int SourceServerID, string Argument);

ACR_SQLEncodeSpecialChars ( string s ) : string

This routine escapes characters for a SQL query.

ACR_SQLExecute ( string SQL ) : void

This routine performs a synchronous SQL query. If there were pending asynchronous queries in the queue, the pending queries are drained first. The query must not return any results.

ACR_SQLFetch ( ) : bool

This routine fetches the next rowset from the database.

ACR_SQLGetAffectedRows ( ) : int

This routine returns the number of rows affected by a query.

ACR_SQLGetData ( ) : string

This routine returns the first column of data from the current SQL rowset.

ACR_SQLGetData ( int ColumnIndex ) : string

This routine returns the specified column of data from the current SQL rowset.

ACR_SQLQuery ( string SQL ) : void

This routine performs a synchronous SQL query. If there were pending asynchronous queries in the queue, the pending queries are drained first.

ACR_SetPCLocalFlags ( UInt32 PCObject, int Flags ) : void

Assigns the current PC local flags value for a PC.

ACR_SetPersistentFloat ( UInt32 Object, string VarName, float Value ) : void

Set a floating point value in the persistent store.

ACR_SetPersistentInt ( UInt32 Object, string VarName, int Value ) : void

Set an integer value in the persistent store.

ACR_SetPersistentLocation ( UInt32 Object, string VarName, NWScript.NWScriptEngineStructure2 Value ) : void

Set a vector value in the persistent store.

ACR_SetPersistentString ( UInt32 Object, string VarName, string Value ) : void

Set a string value in the persistent store.

ACR_SetPersistentVector ( UInt32 Object, string VarName, System.Vector3 Value ) : void

Set a vector value in the persistent store.

ACR_StringToLocation ( string sLocation ) : NWScript.NWScriptEngineStructure2

This routine converts a string to a location.

ACR_StringToLocationData ( string sLocation ) : LOCATION_DATA

This routine converts a string to its component location data fields.

ACR_StringToVector ( string sVector ) : System.Vector3

Convert a string to a vector.

ACR_VectorToString ( System.Vector3 v ) : string

This routine packages a vector into a string.

ACR_XPOnClientLoaded ( uint PCToXP ) : void

This method calculates RPXP for the last playing session.

Database ( CLRScriptBase ScriptBase ) : System

Create a new database object (which can be shared by multiple script objects).

Private Methods

Méthode Description
DemandInitialize ( ) : void

This method performs demand initialization of the database system on the first database call.

RegisterScriptSituationDelegate ( IGeneratedScriptProgram DelegateScript ) : void

This method sets the user's script object to delegate unrecognized script situations to the NWScript library script, allowing a delay continuation started by called NWScript code to function properly.

Method Details

ACR_AsyncSQLQuery() public méthode

Perform an asynchronous database query. The query is added to the module object's query queue.
public ACR_AsyncSQLQuery ( string Query ) : void
Query string Supplies the query string.
Résultat void

ACR_AsyncSQLQueryEx() public méthode

Perform an asynchronous database query. The query is added to a specific object's query queue (must be a PC or the module).
public ACR_AsyncSQLQueryEx ( string Query, UInt32 QueueTo, ACR_QUERY_FLAGS Flags = ACR_QUERY_FLAGS.None ) : void
Query string Supplies the query string.
QueueTo System.UInt32 Supplies the object to queue the query to, /// which should be a PC or the module object.
Flags ACR_QUERY_FLAGS Supplies query flags.
Résultat void

ACR_ConvertDatabaseStringToBoolean() public static méthode

Convert a database string to a Boolean value.
public static ACR_ConvertDatabaseStringToBoolean ( string Str ) : bool
Str string Supplies the database string.
Résultat bool

ACR_DeletePersistentVariable() public méthode

Delete a persistent record.
public ACR_DeletePersistentVariable ( UInt32 Object, string VarName ) : void
Object System.UInt32 Supplies the object whose persistent store is /// to be accessed.
VarName string Supplies the variable keyword to remove. ///
Résultat void

ACR_FlushAllQueryQueues() public méthode

Flush all query queues in the system out to the database.
public ACR_FlushAllQueryQueues ( ) : void
Résultat void

ACR_FlushQueryQueue() public méthode

This routine flushes the query queue for an object. It is useful, for example, in server portal scenarios. Normally, the query queue is flushed automatically.
public ACR_FlushQueryQueue ( uint ObjectToFlush ) : void
ObjectToFlush uint Supplies the object whose query queue /// should be flushed.
Résultat void

ACR_GetBuildDate() public méthode

Get the build date of the module OnLoad script (i.e. the time at which the module had its scripts nominally compiled).
public ACR_GetBuildDate ( ) : string
Résultat string

ACR_GetCharacterID() public méthode

This routine returns the database character ID for a player given their PC object id.
public ACR_GetCharacterID ( UInt32 PCObject ) : int
PCObject System.UInt32 Supplies the object ID of the player to /// query.
Résultat int

ACR_GetHAKBuildDate() public méthode

Get the build date of the HAK version check script (i.e. the time at which the ACR HAK had its scripts nominally compiled).
public ACR_GetHAKBuildDate ( ) : string
Résultat string

ACR_GetHAKVersion() public méthode

Get the version string of the ACR release that the HAK corresponds to. For example, "1.84".
public ACR_GetHAKVersion ( ) : string
Résultat string

ACR_GetIsMember() public méthode

Returns whether a PC is a fully approved ALFA member (vs. a new account that might be a throw-away, etc.).
public ACR_GetIsMember ( UInt32 PCObject ) : bool
PCObject System.UInt32 Supplies the PC object.
Résultat bool

ACR_GetIsPCQuarantined() public méthode

Return whether a PC is quarantined.
public ACR_GetIsPCQuarantined ( UInt32 PCObject ) : bool
PCObject System.UInt32 Supplies the PC object.
Résultat bool

ACR_GetPCLocalFlags() public méthode

Return the current PC local flags value for a PC.
public ACR_GetPCLocalFlags ( UInt32 PCObject ) : int
PCObject System.UInt32 Supplies the PC object.
Résultat int

ACR_GetPersistentFloat() public méthode

Retrieve a float from the persistent store.
public ACR_GetPersistentFloat ( UInt32 Object, string VarName ) : float
Object System.UInt32 Supplies the object whose persistent store is /// to be accessed.
VarName string Supplies the variable keyword to query.
Résultat float

ACR_GetPersistentInt() public méthode

Retrieve an int from the persistent store.
public ACR_GetPersistentInt ( UInt32 Object, string VarName ) : int
Object System.UInt32 Supplies the object whose persistent store is /// to be accessed.
VarName string Supplies the variable keyword to query.
Résultat int

ACR_GetPersistentLocation() public méthode

Retrieve a location from the persistent store.
public ACR_GetPersistentLocation ( UInt32 Object, string VarName ) : NWScript.NWScriptEngineStructure2
Object System.UInt32 Supplies the object whose persistent store is /// to be accessed.
VarName string Supplies the variable keyword to query.
Résultat NWScript.NWScriptEngineStructure2

ACR_GetPersistentString() public méthode

Retrieve a string from the persistent store.
public ACR_GetPersistentString ( UInt32 Object, string VarName ) : string
Object System.UInt32 Supplies the object whose persistent store is /// to be accessed.
VarName string Supplies the variable keyword to query.
Résultat string

ACR_GetPersistentVector() public méthode

Retrieve a vector from the persistent store.
public ACR_GetPersistentVector ( UInt32 Object, string VarName ) : System.Vector3
Object System.UInt32 Supplies the object whose persistent store is /// to be accessed.
VarName string Supplies the variable keyword to query.
Résultat System.Vector3

ACR_GetPlayerID() public méthode

This routine returns the database player ID for a player given their PC object id.
public ACR_GetPlayerID ( UInt32 PCObject ) : int
PCObject System.UInt32 Supplies the object ID of the player to /// query.
Résultat int

ACR_GetServerAddressFromDatabase() public méthode

This routine queries the database in order to return the public IP address of the game server host.
public ACR_GetServerAddressFromDatabase ( ) : string
Résultat string

ACR_GetServerID() public méthode

This routine returns the database server ID of the current server.
public ACR_GetServerID ( ) : int
Résultat int

ACR_GetVersion() public méthode

Get the version string of the ACR release that the module was compiled against. For example, "1.84".
public ACR_GetVersion ( ) : string
Résultat string

ACR_IncrementStatistic() public méthode

Increment a global tracking statistic counter stored in the database (if statistic tracking was enabled).
public ACR_IncrementStatistic ( string Statistic ) : void
Statistic string Supplies the counter name.
Résultat void

ACR_IsServerAdmin() public méthode

This routine determines whether a player is a server admin for the current server.
public ACR_IsServerAdmin ( UInt32 PCObject ) : bool
PCObject System.UInt32 Supplies the object ID of the player to /// query.
Résultat bool

ACR_LocationToString() public méthode

This routine packages a location object into a string.
public ACR_LocationToString ( NWScript.NWScriptEngineStructure2 Location ) : string
Location NWScript.NWScriptEngineStructure2 Supplies the location to convert.
Résultat string

ACR_LogEvent() public méthode

Log an event to the database log.
public ACR_LogEvent ( uint Character, string EventName, string EventDescription, uint DM ) : void
Character uint Supplies an optional character that is /// associated with the log event, else OBJECT_INVALID if none.
EventName string Supplies the log event name.
EventDescription string Supplies the log event description. ///
DM uint Supplies an optional DM character that is /// associated with the log event, else OBJECT_INVALID if none.
Résultat void

ACR_PCSave() public méthode

This routine performs a character save.
public ACR_PCSave ( uint PCToSave, bool Export, bool SaveLocation ) : void
PCToSave uint Supplies the object id of the player to /// save.
Export bool If true, save the character file to disk too. ///
SaveLocation bool If true, update the location of the /// player in the database.
Résultat void

ACR_PCUpdateStatus() public méthode

This method updates regularly-saved persistent information.
public ACR_PCUpdateStatus ( uint PCToUpdate, bool UpdateLocation ) : void
PCToUpdate uint the PC to be updated
UpdateLocation bool whether or not to also update location
Résultat void

ACR_PPSValidatePC() public méthode

This routine validates a character from quarantine.
public ACR_PPSValidatePC ( uint PCToValidate ) : void
PCToValidate uint
Résultat void

ACR_RestOnClientEnter() public méthode

This method calculates offline resting for a PC after logging in.
public ACR_RestOnClientEnter ( uint PCToRest ) : void
PCToRest uint the PC to be rested
Résultat void

ACR_RunScriptOnServer() public méthode

Run a script on a remote server. The script must exist on the server. If acknowledgement is desired, it must be implemented in the form of a reply IPC request initiated by the script invoked. A script executed by this function must follow this prototype: void main(int SourceServerID, string Argument);
public ACR_RunScriptOnServer ( int DestinationServerID, string ScriptName, string ScriptArgument ) : bool
DestinationServerID int Supplies the destination server /// ID.
ScriptName string Supplies the name of the script.
ScriptArgument string Supplies an optional argument to pass /// to the script.
Résultat bool

ACR_SQLEncodeSpecialChars() public méthode

This routine escapes characters for a SQL query.
public ACR_SQLEncodeSpecialChars ( string s ) : string
s string Supplies the string to escape.
Résultat string

ACR_SQLExecute() public méthode

This routine performs a synchronous SQL query. If there were pending asynchronous queries in the queue, the pending queries are drained first. The query must not return any results.
public ACR_SQLExecute ( string SQL ) : void
SQL string Supplies the SQL query text to execute.
Résultat void

ACR_SQLFetch() public méthode

This routine fetches the next rowset from the database.
public ACR_SQLFetch ( ) : bool
Résultat bool

ACR_SQLGetAffectedRows() public méthode

This routine returns the number of rows affected by a query.
public ACR_SQLGetAffectedRows ( ) : int
Résultat int

ACR_SQLGetData() public méthode

This routine returns the first column of data from the current SQL rowset.
public ACR_SQLGetData ( ) : string
Résultat string

ACR_SQLGetData() public méthode

This routine returns the specified column of data from the current SQL rowset.
public ACR_SQLGetData ( int ColumnIndex ) : string
ColumnIndex int Supplies the zero-based column index to /// retrieve.
Résultat string

ACR_SQLQuery() public méthode

This routine performs a synchronous SQL query. If there were pending asynchronous queries in the queue, the pending queries are drained first.
public ACR_SQLQuery ( string SQL ) : void
SQL string Supplies the SQL query text to execute.
Résultat void

ACR_SetPCLocalFlags() public méthode

Assigns the current PC local flags value for a PC.
public ACR_SetPCLocalFlags ( UInt32 PCObject, int Flags ) : void
PCObject System.UInt32 Supplies the PC object.
Flags int Supplies the new Local Flags value.
Résultat void

ACR_SetPersistentFloat() public méthode

Set a floating point value in the persistent store.
public ACR_SetPersistentFloat ( UInt32 Object, string VarName, float Value ) : void
Object System.UInt32 Supplies the object whose persistent store is /// to be accessed.
VarName string Supplies the variable keyword to set.
Value float Supplies the variable data.
Résultat void

ACR_SetPersistentInt() public méthode

Set an integer value in the persistent store.
public ACR_SetPersistentInt ( UInt32 Object, string VarName, int Value ) : void
Object System.UInt32 Supplies the object whose persistent store is /// to be accessed.
VarName string Supplies the variable keyword to set.
Value int Supplies the variable data.
Résultat void

ACR_SetPersistentLocation() public méthode

Set a vector value in the persistent store.
public ACR_SetPersistentLocation ( UInt32 Object, string VarName, NWScript.NWScriptEngineStructure2 Value ) : void
Object System.UInt32 Supplies the object whose persistent store is /// to be accessed.
VarName string Supplies the variable keyword to set.
Value NWScript.NWScriptEngineStructure2 Supplies the variable data.
Résultat void

ACR_SetPersistentString() public méthode

Set a string value in the persistent store.
public ACR_SetPersistentString ( UInt32 Object, string VarName, string Value ) : void
Object System.UInt32 Supplies the object whose persistent store is /// to be accessed.
VarName string Supplies the variable keyword to set.
Value string Supplies the variable data.
Résultat void

ACR_SetPersistentVector() public méthode

Set a vector value in the persistent store.
public ACR_SetPersistentVector ( UInt32 Object, string VarName, System.Vector3 Value ) : void
Object System.UInt32 Supplies the object whose persistent store is /// to be accessed.
VarName string Supplies the variable keyword to set.
Value System.Vector3 Supplies the variable data.
Résultat void

ACR_StringToLocation() public méthode

This routine converts a string to a location.
public ACR_StringToLocation ( string sLocation ) : NWScript.NWScriptEngineStructure2
sLocation string Supplies the string to convert.
Résultat NWScript.NWScriptEngineStructure2

ACR_StringToLocationData() public méthode

This routine converts a string to its component location data fields.
public ACR_StringToLocationData ( string sLocation ) : LOCATION_DATA
sLocation string Supplies the string to convert.
Résultat LOCATION_DATA

ACR_StringToVector() public méthode

Convert a string to a vector.
public ACR_StringToVector ( string sVector ) : System.Vector3
sVector string Supplies the string to convert.
Résultat System.Vector3

ACR_VectorToString() public méthode

This routine packages a vector into a string.
public ACR_VectorToString ( System.Vector3 v ) : string
v System.Vector3 Supplies the vector to convert.
Résultat string

ACR_XPOnClientLoaded() public méthode

This method calculates RPXP for the last playing session.
public ACR_XPOnClientLoaded ( uint PCToXP ) : void
PCToXP uint the PC to XP
Résultat void

Database() public méthode

Create a new database object (which can be shared by multiple script objects).
public Database ( CLRScriptBase ScriptBase ) : System
ScriptBase CLRScriptFramework.CLRScriptBase Supplies the associated script base class /// object, used to access script APIs.
Résultat System