View previous topic :: View next topic |
Author |
Message |
Squatting Monk
Joined: 28 Jun 2007 Posts: 76
|
Posted: Fri Jul 27, 2007 12:07 Post subject: First persistency script problems |
|
|
Alright, I finally got my first script pounded out, though I'm having some problems with it. It works when I test it, but the values are not stored in the database according to the command line utility or SQLiteCC. The persistent ints I set last only until I close NWNX. Restarting NWNX and reloading the module seems to put things back on square one.
The script checks to see if the player has a Player's Handbook item. If so, it just lets the character on with no interference. If not, it checks to see if the database has any record of a character with that name by that player being given a Handbook. If so, it sends an error message and logs the PC off (in order to prevent exploits). If not, it gives the character one and passes that information along to the database.
Here's the script:
Code: | #include "aps_include"
void main()
{
object oPC = GetEnteringObject(); // Get the PC
string sTag = "NR_PHB"; // PHB tag
string sResref = "nr_phb"; // PHB resref
string sVarName = "passport_given"; // Peristent variable name
int bValue = TRUE; // Persistent variable value
string sError = "You may not create two PCs with" // Server message to PC telling him to change name
+ " the same name. Please re-make your PC with a different"
+ " name or ask a DM to purge your old PC with this name"
+ " from the database and server vault. Logging out...";
string sGiven = "Please examine the Player's" // Server message to PC telling him how to use PHB
+ " Handbook item in your inventory to see the server"
+ " rules. Activate the item to access the Player's Handbook.";
float fLogOut = 6.0f; // Time before player is logged out.
if(!GetIsPC(oPC)) return; // If the entering object is not a PC, abort script.
if(GetItemPossessedBy(oPC, sTag) == OBJECT_INVALID) // If the PC does not have the passport item...
{
if(GetPersistentInt(oPC, sVarName)) // If the database say the player has a passport, then...
{
SendMessageToPC(oPC, sError); // Tell the PC duplicate names not allowed, then...
DelayCommand(fLogOut, BootPC(oPC)); // Boot the player.
}
else // Otherwise...
{
CreateItemOnObject(sResref, oPC); // Create it, then...
SetPersistentInt(oPC, sVarName, bValue); // Tell the database it's there, then...
SendMessageToPC(oPC, sGiven); // Tell the PC how to use it.
}
}
} |
It's the first script that I've ever written from scratch on my own, so I'm kind of lost. Any help is great. Thanks. |
|
Back to top |
|
|
Papillon x-man
Joined: 28 Dec 2004 Posts: 1060 Location: Germany
|
Posted: Wed Aug 01, 2007 21:41 Post subject: Re: First persistency script problems |
|
|
Squatting Monk wrote: | Alright, I finally got my first script pounded out, though I'm having some problems with it. It works when I test it, but the values are not stored in the database according to the command line utility or SQLiteCC. |
I think your script is fine, but this strikes me as odd. Please post the contents of your odbc log file (with full logging enabled in the INI). Log in with a new player so the whole thing will be logged. _________________ Papillon |
|
Back to top |
|
|
Squatting Monk
Joined: 28 Jun 2007 Posts: 76
|
Posted: Sat Aug 04, 2007 22:17 Post subject: |
|
|
And of course when I go to duplicate it yet again to post the logs, it inexplicably starts working. *sighs* Sorry to be a bother. |
|
Back to top |
|
|
|
|
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
|