I am in need of some wisdom and education.
I have set up PWs in the past, with very little knowledge of SQL and a great tutorial that held my hand through the process. (nwnx4, mysql, toolset).
I want this in my PW.
https://neverwintervault.org/project/nwn2/other/tailor-smooth-system
Everything makes sense except…
“If you use the Tailor Smooth System in your module you will have to change the GetPCUid function to match your UID system. Indeed it was designed to be used in the whole SEPTI project and will not be compatible with your module as if.”
Here is the code they say to change with my own UID system:
///////Modify this to call you own ID function ////////
string GetPCUid(object oPlayer)
{
string sOutput;
if(GetIsDM_C(oPlayer))
{
string str = “DMUID_”+GetPCPlayerName(oPlayer)+“_”+GetName(oPlayer);
string sTranslate = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
while (GetStringLength(str) > 0)
{
int iTrans = FindSubString(sTranslate, GetStringLeft(str,1));
if(iTrans != -1)
{
sOutput = sOutput + GetStringLeft(str,1);
}
str = GetStringRight(str, GetStringLength(str)-1);
}
}
else
{
sOutput = GetLocalString(GetSeptiBaseItem(oPlayer), SEPTI_PCUID);
}
return sOutput;
}
I guess my question is what is a PCUID, and how do I know if my PW has a system for that, and is there a system that most PWs are using should I need it? Thank you in advance.
Hello, I hope you have found an answer in another way. I don’t check this forum very often.
For you or anyone else reading this:
PC UID is a way to identify a PC. Some servers use AccountName#FirstName_LastName for this, while others give each PC a number upon first connection.
How do I know if my PW has a system for that?
I can’t help you with that specifically, as it really depends on the server. I’m on Discord if you need more specific information.
Is there a system that most PWs use that I should know about?
I don’t know about a specific system, but I have seen that many PWs use the account name and PC name to identify a PC.
Easy way to do :
Set up a function called GetPCUID that simply returns AccountName#FirstName#LastName.
I don’t like this method and don’t recommend it, as it can cause problems on name change. But, it’s not a problem for TSS.
A more robust method is to prepare a specific item blueprint in the editor (with no weight, cannot be dropped or sold, etc. -if you use the dmfi, dmfi ring work). Upon PC connection, check if the PC already has this item. If not, give the PC the item and set a local variable on the item with your unique identifier (e.g. a basic database with an auto-increment ID).
Feel free to ask me on Discord, I will be happy to help you integrate Tailor smooth system on your server.
Would anyone have a script for this already that I could plug in my tags? I am not a great script writer.
A more robust method is to prepare a specific item blueprint in the editor (with no weight, cannot be dropped or sold, etc. -if you use the dmfi, dmfi ring work). Upon PC connection, check if the PC already has this item. If not, give the PC the item and set a local variable on the item with your unique identifier (e.g. a basic database with an auto-increment ID).
Quick example :
(you will need a database and nwnx sql plugin)
Function :
void sept_system_onClientEnter(object oPC)
{
object oTool = GetItemPossessedBy(oPC, SEPTI_BASE_ITEM);
if (oTool==OBJECT_INVALID)
{
// Invalid Tool
oTool = CreateItemOnObject(SEPTI_BASE_ITEM,oPC);
if(!GetIsDM_C(oPC))
{
string sName = SQLEncodeSpecialChars(GetPCPlayerName(oPC)+"#"+GetFirstName(oPC)+GetLastName(oPC));
string sSQL = "INSERT INTO "+SEPT_DB_PREFIX+DB_PCUID+" (creationName, createDate, lastlogDate) VALUES ('"+sName+"', NOW(), NOW())";
SQLExecDirect(sSQL);
sSQL = "SELECT id FROM "+SEPT_DB_PREFIX+DB_PCUID+" WHERE creationName = '"+sName+"'";
SQLExecDirect(sSQL);
SQLFetch();
SetLocalString(oTool, SEPTI_PCUID, "PCUID_"+SQLGetData(1));
}
}
SetLocalObject(GetOriginalPC(oPC), SEPTI_BASE_ITEM, oTool);
if(!GetIsDM_C(oPC))
{
string sID = GetPCUid(oPC);
sID = GetStringRight(sID, GetStringLength(sID)-6);
string sSQL = "UPDATE "+SEPT_DB_PREFIX+DB_PCUID+" SET lastlogDate = NOW() WHERE id = " + sID;
SQLExecDirect(sSQL);
}
}
To call in your oncliententer script :
sept_system_onClientEnter(GetEnteringObject());
include this file :
sept_lib_base_script.nss (5.1 KB)
(you can change const string SEPTI_BASE_ITEM = “sept_base_item”; to set it to your “base object”. Or create an item blueprint with the good name.)
(if you use dmfi , i think the tag is : dmfi_exe_tool, -dmfi use the string const DMFI_ITEM_TAG )
Now, you can include sept_lib_base_script and call GetPCUid.
1 Like
I am an idiot and I do not know how to implement this.
I don’t know where those script should go nor how to add them to my current onareaenter and oncliententer scripts.