logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
FastFrench Table creation methods

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Development
View previous topic :: View next topic  
Author Message
Fizzbang



Joined: 29 Nov 2006
Posts: 1

PostPosted: Wed Nov 29, 2006 17:55    Post subject: FastFrench Table creation methods Reply with quote

I used to use the FastFrench version of this system sometime ago on our persistant world and it featured a few nice additions that I am not sure NWNX had.

It had a script on first load that would automatically create all the required tables etc in MySQL if it was not already present.

It also had the ability to return a players character to exactly the location you left the server and not somewhere on that particular area, is this a feature of NWNX?

BTW, Good work in getting this moving so quickly.
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Thu Nov 30, 2006 10:17    Post subject: Reply with quote

FastFrench's version of NWNX always had been a bit more specific than NWNX itself, that is why he could include some particular optimization / features that I could not. In NWNX4, the table creation will be part of the demo module for the SQL plugins, and will support the various databases. So new users will have to load the module once.

The location saving has nothing to do with NWNX, but can be implemented with the functions it offers.
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
seed



Joined: 01 Dec 2006
Posts: 44

PostPosted: Fri Dec 01, 2006 19:20    Post subject: NWNX!DMREBOOT Reply with quote

Please add the one truely nice function from FF - NWNX!DMREBOOT
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Fri Dec 01, 2006 21:06    Post subject: Reply with quote

Sure!


.
.
.


uhm, what does that function actually do ?
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Mixplikt



Joined: 01 Dec 2006
Posts: 1

PostPosted: Fri Dec 01, 2006 23:47    Post subject: Reply with quote

Papillon wrote:
uhm, what does that function actually do ?


Code:
NWNX!DMREBOOT

This will ask the monitoring tool to restart the server.

Example of use:

int Reboot() // Gives the number of micro-seconds since NWServer started

{

SetLocalString(GetModule(), "NWNX!DMREBOOT", GetName(OBJECT_SELF));

}



Code:
NWNX!RUN

With this function, you can run any external executable from your NWN scripts.

Example of use:

SetLocalString(GetModule(),  "NWNX!RUN", "command.com /c del c:\\fic.txt");

if (GetLocalString(GetModule(),  "NWNX!RUN")=="") // Error!

{

// Error processing

}

 

NWNX!TIMER

Returns the number of micro-second since the NWNServer.exe is started. It can be used to very precisely benchmark any NWN Scripts.

Example of use:

int SQLGetTime() // Gives the number of micro-seconds since NWServer started

{

SetLocalString(GetModule(), "NWNX!TIMER", "000000000000");

return StringToInt(GetLocalString(GetModule(), "NWNX!TIMER"));

}



And about the optimized functions?

Code:
Part1: Non-database related functions

Those functions do not need any Database, and as such work with NWN-MySQL.dll but also NWN-NoDB.dll

int SQLGetTime();       // Gives the number of micro-seconds since NWServer started (can be used for precise Benchmarks)

string SQLGetVersion(); // Returns version string for NWN-FF

int SQLGetRLDate();     // Returns the number of second since january 1st 2001 (in RL world)

void SQLSetIGDate();    // This function can be put in OnModuleLoad event to automatically synchronize IG and IRL times

Part2: Database related functions (2nd generation: they can be freely mixed with APS/NWNX functions)

Those functions need a MySQL database. They work with NWN-MySQL.dll or even NWN-FF MySQL plugin (NWNx_ODBC).

// SQLExecAndFetchDirect is roughly equivalent to SQLExecDirect immediately followed by SQLFetch (but faster)
// It can be used for result sets up to 4KB long (4096 characters)
int SQLExecAndFetchDirect(string sSQL);                                                                               

// When you’re doing a request that returns several values, using SQLGetData may be very inefficient.
// Better use SQLEatData (and, if you don’t need to use all data as they are returned, SQLSkipData to ignore some of them). SQLEatData read the next unread Data.
// but if you really need something really fast, then use the next set of functions (SQLLocalExecAndFetchDirect/SQLLocalEatData…)
string SQLEatData();

void SQLSkipData();

Part3: Database related functions (3rd generation: the fastest, but can’t be mixed together with APS/NWNX functions)

Those functions do need a MySQL database. They work with NWN-MySQL.dll or even NWN-FF MySQL plugin (NWNx_ODBC).

Because all SQLLocalXXXX functions share a global variable, all such functions related to the same request should better be used within a single script. Avoid for instance to call SQLLocalExecAndFetchDirect in a function and then corresponding SQLLocalEatData within other functions called with AssignCommand, ExecuteScript or DelayCommand. Except in this case, you should always try to use this set of function instead of those described within previous sections.

Similar to the 2nd generation SQLExecAndFetchDirect function, this one is to be used with the other SQLLocalXXXX functions.
int SQLLocalExecAndFetchDirect(string sSQL);

If you’re waiting for several answers (rows) after a request, then either use
SQLExec then SQLLocalFetch for each row, until it returns SQL_ERROR
Or, use SQLLocalExecAndFetchDirect for the first row, and then SQLLocalFetch for each following.
int SQLLocalFetch();

Similar to SQLEatData(), use this one after SQLLocalExecAndFetchDirect or SQLLocalFetch to retrieve each value as a string (column).
string SQLLocalEatDataString();

Same but for other type of data  (int, float, location or vector)
int SQLLocalEatDataInt();
float SQLLocalEatDataFloat();
location SQLLocalEatDataLocation();
vector SQLLocalEatDataVector();

Similar to SQLSkipData, to be used if there is a column you don’t need.
void SQLLocalSkipData();

 

Part4: Database related functions (still 3rd generation: those used to store or retrieve a single value)

Very fast set of function used to store or retrieve a single value.

This function take a SQL request as a parameter (plus an optional default value, used if the request fails). It returns the result of the request as a string. It is much optimized, but should only be used for relatively short results: the size of the result string needs to be smaller than the size of the request.
string SQLExecAndFetchSingle(string sSQL, string DefaultValue="");

Similar to SQLLocalEatData except it directly returns an int.
int SQLExecAndFetchSingleInt(string sSQL, int DefaultValue=0);

Those 11 optimized functions are used to very easily store, retrieve or delete a single value (string, int, float, location or vector). Other kind of data can be easily supported by using conversion routines. You can optionally specify the name of the table and the default value returned on ff_GetPersitentXXX functions when the data do not exist (except for ff_SQLGetPersistentLocation).
string ff_GetPersistentString(string ValueName, string sTable="global", string DefaultValue="");
int ff_GetPersistentInt(string ValueName, string sTable="global", int DefaultValue=0);
float ff_GetPersistentFloat(string ValueName, string sTable="global", float DefaultValue=0.0);
location ff_GetPersistentLocation(string ValueName, string sTable="global");
vector ff_GetPersistentVector(string ValueName, string sTable="global");
void ff_SetPersistentString(string ValueName, string sValue, string sTable="global");
void ff_SetPersistentInt(string ValueName, int iValue, string sTable="global");
void ff_SetPersistentFloat(string ValueName, float fValue, string sTable="global");
void ff_SetPersistentLocation(string ValueName, location lValue, string sTable="global");
void ff_SetPersistentVector(string ValueName, vector vValue, string sTable="global");
void ff_DeletePersistentVariable(string ValueName, string sTable="global");

Those 11 optimized functions are used to very easily store, retrieve or delete a single value for a given PC (string, int, float, location or vector). Other kind of data can be easily supported by using conversion routines. Those can only be used if you use the default login mechanism provided with NWN-FF.erf.
string ff_GetPCPersistentString(object oPC, string ValueName);
int ff_GetPCPersistentInt(object oPC, string ValueName);
float ff_GetPCPersistentFloat(object oPC, string ValueName);
location ff_GetPCPersistentLocation(object oPC, string ValueName);
vector ff_GetPCPersistentVector(object oPC, string ValueName);
void ff_SetPCPersistentString(object oPC, string ValueName, string sValue);
void ff_SetPCPersistentInt(object oPC, string ValueName, int iValue);
void ff_SetPCPersistentFloat(object oPC, string ValueName, float fValue);
void ff_SetPCPersistentLocation(object oPC, string ValueName, location lValue);
void ff_SetPCPersistentVector(object oPC, string ValueName, vector vValue);
void ff_DeletePCPersistentVariable(object oPC, string ValueName);

Part5 Database related functions, dealing with objects

// Store an object for that PC on a specific Placable (chest...)
void ff_SetPersistentObject(object oOwner, object oObject, object oPlacable=OBJECT_INVALID, string sTable = "RCO_SCO");

// Retrieve the first object for that PC on a specific Placable (chest...)
object ff_GetPersistentObjectFirst(object oOwner, object oPlacable=OBJECT_INVALID, string sTable = "RCO_SCO");

// Retrieve the next objects ('til return NULL)
object ff_GetPersistentObjectNext(object oOwner, object oPlacable=OBJECT_INVALID);

// Remove all objects associated with that player on a given placable
void ff_CleanPersistentObject(object oOwner, object oPlacable=OBJECT_INVALID, string sTable = "RCO_SCO");

 

And the following functions are provided for NWNx/APS compatibility:
object GetPersistentObject(object oObject, string sVarName, object oOwner = OBJECT_INVALID, string sTable = "pwobjdata");
void SetPersistentObject(object oOwner, string sVarName, object oObject, int iExpiration = 0, string sTable = "pwobjdata");

Plus this bonus function, very useful to handle persistent inventories (chests…)

void DeleteAllPersistentObject(object oObject, string sTable = "pwobjdata");

 

Part6 New helper set of functions, coming with NWNx functions plugin.

void ff_SetGoldPieceValue(object oObject, int iValue);
void ff_SetName(object oObject, string NewName);
void ff_SetDescription(object oObject, string NewDescription);
string ff_GetDescription(object oObject);
void ff_SetBodyPart(object oPlayer, int nPart, int nType);
int ff_GetBodyPart(object oPlayer, int nPart);
void SetLockDC(object oChest, int DC);
void ff_ChangePlayerAppearance(object oPlayer, int nPart, int nType);
void ff_ChangePlayerAppearance(object oPlayer, int nPart, int nType);
void ff_DeleteThisChar(object oPC);
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Sat Dec 02, 2006 13:58    Post subject: Reply with quote

I did not read through the whole list, but I think a few of these modifications are not necessary any more, while others will be included as time permits. Some others again, might be better put into separate plugins.

Give it some time, and you will probably see more and more functions popping up.
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Development All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group