Aller au contenu

Photo

Trouble installing an Exp bank into module.


  • Veuillez vous connecter pour répondre
23 réponses à ce sujet

#1
Lazarus Magni

Lazarus Magni
  • Members
  • 1 134 messages
Disclaimer: I am not sure where the best place to post this is since there is no Dev forum, but seeing as a bunch of scripts are involved I thought I would try here.

I am trying to install an XP Bank by TheGrimReefer from the vault into a module.
http://nwvault.ign.c....Detail&id=2866

I am able to get it to work, however when I go to withdraw exp, I can continue to do so beyond what I have deposited into the bank.

In the script description it says this was intended for "standard bioware DB calls" however the module is using MySQL. Anyone know if this is the problem, and how to fix it?

Modifié par Lazarus Magni, 19 juin 2011 - 10:44 .


#2
Kato -

Kato -
  • Members
  • 392 messages
The system uses BioWare DB calls, indeed. MySQL usually(sorry if there are other ways I don't know of) interacts with NWN via NWNX-ODBC. If this is already set, then you simply have to replace some function calls, in order to properly interact with MySQL. For instance, SetCampaignInt can be replaced by SetPersistentInt, and so on. You'll find the functions you need for MySQL in the script "aps_include". I'll be happy to help you with the "conversion" if you need.

Kato

#3
Lazarus Magni

Lazarus Magni
  • Members
  • 1 134 messages
Hi Kato, thanks for the response. I certainly would welcome your help.

#4
Lazarus Magni

Lazarus Magni
  • Members
  • 1 134 messages
Ok so I just opened the fist of those scripts and I replaced SetCampaignIn with SetPersistentInt. I then saved and complied, and got this error message:

6/20/2011 10:53:42 PM: Error. 'xp_deposit_1000k' did not compile.
xp_deposit_1000k.nss(13): ERROR: UNDEFINED IDENTIFIER (SetPersistentInt)

I am assuming that means it is not working?

#5
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
The script from NWNX called "aps_include" needs to be in your module. Then in your script, just above the void main(), put the line: #include "aps_include"

Also be aware that the SetPersistentInt function has different parameters. Instead of a string for a database name you will need to put in some object.

This is an example of a gold deposit script. It might give you and idea. You can use the player character as the object as well. I just didn't cause I want all characters the player uses to have access to the same gold.


///////////////////////
//Deposit 1,000 gold.//
///////////////////////
#include "aps_include"
void main()
{
object oPC = GetPCSpeaker();
object oBankDBObject = GetNearestObjectByTag("BANK_DB_OBJECT", oPC);
int nDeposit = 1000;
string sCDKey = GetPCPublicCDKey(oPC);
//int nBalance = GetCampaignInt("AURYN_BANK", sCDKey);
int nBalance = GetPersistentInt(oBankDBObject, sCDKey, "pwdata");
int nAmount = (nDeposit + nBalance);
int nGold = GetGold(oPC);

if (nGold >= 1000)
    {
    TakeGoldFromCreature(nDeposit, oPC, TRUE);
    //SetCampaignInt("AURYN_BANK", sCDKey, nAmount, oPC);
    SetPersistentInt(oBankDBObject, sCDKey, nAmount, 0, "pwdata");
    SpeakString("Thank You.", TALKVOLUME_TALK);
    }
else
    {
    SpeakString("I'm sorry but you do not have enought gold to deposit that amount.");
    }
}

Modifié par GhostOfGod, 21 juin 2011 - 04:11 .


#6
Lazarus Magni

Lazarus Magni
  • Members
  • 1 134 messages
Hi Ghost, thanks for the respons.
I do have aps_include in the module. By in your script I assume you mean all the scripts that the bank erf added? (there were a dozen or so) I will try and add #include "aps_include" to each, and see what happens. I assume I also change GetCampaignInt to SetPersistentInt as Kato mentioned?

On the first one I tried this with I am still getting this compile error:
6/20/2011 11:46:37 PM: Error. 'xp_deposit_1000k' did not compile.
xp_deposit_1000k.nss(12): ERROR: DECLARATION DOES NOT MATCH PARAMETERS

I am not sure what you mean by this "Instead of a string for a database name you will need to put in some object."? Can you explain that a bit?

Modifié par Lazarus Magni, 21 juin 2011 - 04:47 .


#7
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
If you take a look at the script I posted above you will see that I was also useing GetCampaignInt but then commented it out and replaced it with GetPersistentInt(I also did the same thing with the SetPersistentInt).

//int nBalance = GetCampaignInt("AURYN_BANK", sCDKey);
int nBalance = GetPersistentInt(oBankDBObject, sCDKey, "pwdata");

The parameters for these two functions are not the same. In the standard GetCampaignInt function. the first parameter requires that you entet a string for the database name. In the case above my database name was "AURYN_BANK".
Now with the NWNX function, GetPersitentInt, the first parameter is not asking for a string for a database name. It is asking for the object that the persistent int is stored on. You will need to define your object and then pass that into the first parameter. The other parameters in the Get/SetPersistent functions are also different . Except for the second one, variable name.

#8
Lazarus Magni

Lazarus Magni
  • Members
  • 1 134 messages
Honestly you have totally lost me. Really I am not a scripter at all. I just make sad attempts at tweaking them out of neccesity when the need arises.

As you can see above I replaced GetCampaignInt with SetPersistentInt when it prolly should have been GetPersistentInt? I will try that now, however I don't really understand "It is asking for the object that the persistent int is stored on. You will need to define your object and then pass that into the first parameter."?

#9
Kato -

Kato -
  • Members
  • 392 messages
Okay. First, you need to put the line: #include "aps_include" in 3 of the system's scripts, at the very beginning of the script: xp_inc, xp_sc_10k and xp_sc_50k. The rest of the scripts include xp_inc, so you don't need to add the line to them.

Next, as mentioned by GhostOfGod, you must of course pass the correct parameters to the aps_include functions. In all the system's scripts where either GetCampaignInt or SetCampaignInt is called, the object "tied" to the bank account is retrieved with GetPCSpeaker() and named oPC. This is the object you need to pass to GetPersistentInt and SetPersistentInt. Next comes the name of the variable you wish to store or retrieve, wich is the second parameter of the aforementioned functions. In the system you're using, this parameter is the cd key of oPC, retrieved with GetPCPublicCDKey(), and named sCDKey. Next comes the value(or banked xp) you want to set in SetPersistentInt() followed by the table name. So, the infos you need to pass to the new functions are already present in the system you're using, you only need to pass them in a different order in the new function calls.

For instance, let's say you want to "update" the script: xp_deposit_100k.

#include "xp_inc"

void main()
{
object oPC =GetPCSpeaker();
if (GetHitDice(oPC) >= 20)
{
int DepositXP = 100000/fraction;
string sDepositXP = IntToString(DepositXP);
string sCDKey = GetPCPublicCDKey( oPC);
int fXP = GetCampaignInt( "XP", sCDKey) + DepositXP;
int XP = GetXP(oPC) - 100000;
SetCampaignInt( "XP", sCDKey, fXP);
SetXP(oPC, XP);
SpeakString ("You have deposited "+ sDepositXP +" XP.");
}
else
{
SpeakString ("Sorry, but you need to be at least level 20 to use this feature.");
}
}


Would become:


#include "xp_inc"

void main()
{
object oPC =GetPCSpeaker();
if (GetHitDice(oPC) >= 20)
{
int DepositXP = 100000/fraction;
string sDepositXP = IntToString(DepositXP);
string sCDKey = GetPCPublicCDKey( oPC);
int fXP = GetPersistentInt(oPC, sCDKey) + DepositXP;
int XP = GetXP(oPC) - 100000;
SetPersistentInt(oPC, sCDKey, fXP);
SetXP(oPC, XP);
SpeakString ("You have deposited "+ sDepositXP +" XP.");
}
else
{
SpeakString ("Sorry, but you need to be at least level 20 to use this feature.");
}
}

This is taken from one of the system's scripts, for informational purposes, I'm not saying that the code is debugged and secure, it's only "converted" to use aps_include, with the aforementioned functions.

Using MySQL offers you a great deal of flexibility and speed, so you might want to eventually create your own table(s) and write some SQL queries, or even simply test your current queries, so I would advise you use MySQL Query Browser, a very simple and free tool wich will allow you to do all this and more.

Finally, I'm currently using several banking systems in my PW(xp, gold, objects), all custom and under MySQL, so I'd be happy to share some code snippets with you, yet I would not want to disrespect the builder of your current system...

Good luck!

Kato

Modifié par Kato_Yang, 24 juin 2011 - 06:40 .


#10
Lazarus Magni

Lazarus Magni
  • Members
  • 1 134 messages
Hi Kato,
Ok first of all, when I go to add #include "aps_include" at the beginning of those scripts I get the error message:
There was no "void main ()" function in the script.
Would you like to compile the script as a conditional script instead?
And I get 2 options yes or no... Not sure which to choose... Or if I should go back and put in the line void main () at the beginning?

I will start working my way through the rest of your instructions once I get past this first one...

I have MySQL workbench, and also downloaded that stand alone program you mentioned, but I think that will be down the road, before I get into any of that.

The module does already have a persistant banking system for gold and items, using MySQL. I would not worry about disrespecting anyone, as the mod was released on the vault a year and a half ago or more, when the first host shut down, for anyone to do with as they please, and the version I have now after the most recent host shut down a week and a half ago or so, has received another years worth of development of which I was a big part of (I think I did more work on it than anyone other than the host, and a previous dev who stoped working on it in December), so I feel quite justified continuing to work on it, and also am at this point the only person developing my version of it, however I am hoping to put a team together, but would hope they could all worth together. It also has community development as a part of it's legacy, which is an aspect I am hoping to continue. There is someone else who has picked up hosting this same mod base now (as of a week ago), however he has made it clear I am not welcome to continue working on it with him at the helm, and that my vision for it is not what he wants, which is why I am persuing my own path with it now, and hoping others will join me along the way who like the direction I am taking it.

Modifié par Lazarus Magni, 22 juin 2011 - 01:34 .


#11
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
My advice which is a bit contradictory to what Kato suggested. Do not put the #include "aps_include" line at the top of those three system scripts and only add that line to the top other the other script like "xp_deposit_100k". You are probably having some looping include problems. Unless you know for sure that your not doubling up on your includes somewhere it's but to keep em separated.

So keep your script the way that Kato fixed it, to work with NWNX, but add the line #include "aps_include" to the top of it as well. And keep that line off those three system scripts that Kato mentioned. See if that helps out.


#include "xp_inc"
#include "aps_include"

void main()
{
    object oPC =GetPCSpeaker();
    if (GetHitDice(oPC) >= 20)
    {
        int DepositXP = 100000/fraction;
        string sDepositXP = IntToString(DepositXP);
        string sCDKey = GetPCPublicCDKey( oPC);
        int fXP = GetPersistentInt(oPC, sCDKey) + DepositXP;
        int XP = GetXP(oPC) - 100000;
        SetPersistentInt(oPC, sCDKey, fXP);
        SetXP(oPC, XP);
        SpeakString ("You have deposited "+ sDepositXP +" XP.");
    }
    else
    {
        SpeakString ("Sorry, but you need to be at least level 20 to use this feature.");
    }
}

Modifié par GhostOfGod, 22 juin 2011 - 01:51 .


#12
Lazarus Magni

Lazarus Magni
  • Members
  • 1 134 messages
Well that's why multiple minds are better than one, you get different perspectives and ideas. I am guessing both approaches will work (unless I get the looping problem with Kato's approach, as you suggested is possible Ghost.)

I am still not sure what to do about the current error I am receiving? If I select no, I get a message saying:

6/21/2011 9:24:20 PM: Error. 'pf_portal_util' did not compile.
pf_portal_util.nss: ERROR: NO FUNCTION MAIN() IN SCRIPT

If I select yes I get a message saying:
6/21/2011 9:25:16 PM: Error. 'pf_portal_util' did not compile.
pf_portal_util.nss: ERROR: NO FUNCTION STARTINGCONDITIONAL() IN SCRIPT

Edit:
Sorry that was the same error message but when compiling a different script.

The one I get for the script I posted above is:
6/21/2011 9:32:54 PM: Error. 'xp_deposit_1000k' did not compile.
xp_deposit_1000k.nss(12): ERROR: DECLARATION DOES NOT MATCH PARAMETERS

But I can't remember if I chose yes or no :(  (*looks foolish*)

Modifié par Lazarus Magni, 22 juin 2011 - 02:35 .


#13
Kato -

Kato -
  • Members
  • 392 messages
Okay let's clarify things a bit. I mentioned 3 scripts:
xp_inc: The main include. Included by all system scripts except the two listed below. Includes nothing, no aps_include function calls.
xp_sc_10k: Includes nothing, calls aps_include function.
xp_sc_50k: Includes nothing, calls aps_include function.
All other scripts: Include xp_inc, call aps_include functions.

So we can see that the two scripts including nothing could not possibly call functions from aps_include without including it. Moreover, since all other scripts include xp_inc, and considering that the very few lines of code this one contains do not conflict with aps_include, it seems cleaner to simply add the include line in xp_inc instead of adding it to all the scripts. I have just tested this setup and it perfectly compiled, as expected.

Concerning the question about compiling as conditional, you should answer no, and then on the displayed script, simply press spacebar + backspace, then save your script(simply recompiling). You will get an error message, but this time the message should be explicit enough for you to know where to look in your code. If you can't fix the bugged line(or instruction), I'll do my best to help you out.

Kato

Modifié par Kato_Yang, 22 juin 2011 - 07:22 .


#14
Lazarus Magni

Lazarus Magni
  • Members
  • 1 134 messages
As I mentioned in the e-mail I sent you...

"Ok so I am trying to follow the instructions you posted on the forums. I am starting off with xp_inc, when I save and compile I get the error I described. I selected no, and then got this error message:
6/21/2011 10:15:57 PM: Error. 'xp_inc' did not compile.
xp_inc.nss: ERROR: NO FUNCTION MAIN() IN SCRIPT
I then pressed spacebar + backspace, but it didn't seem to do anything?"

If you would perfer to work through this on the forums that's all good, whatever works best for you.

As I mentioned spacebar + backspace didn't seem to do anything, but I saved afterwards nonetheless, and still got the message:

Error. 'xp_inc' did not compile.
xp_inc.nss: ERROR: NO FUNCTION MAIN() IN SCRIPT

This may be explicit for you, but I have no idea what that means or how to fix it?

#15
Alex Warren

Alex Warren
  • Members
  • 179 messages
You don't have to fix it ;p Include scripts don't compile. Just make sure that other scripts using this include compile.

#16
Lazarus Magni

Lazarus Magni
  • Members
  • 1 134 messages
Thank you Alex, that is good to know. I will proceed then, and report back what happens...

#17
Kato -

Kato -
  • Members
  • 392 messages
Your xp_inc should look like this:

#include "aps_include"
/*
XP Bank by uhmm TheGrimReefer, yay..
This Bank is a way for people to transfer Experience points from an old character
to a new one, so they dont have to deal with those tedious first levels.

Obviously there would be a penalty, this is represented by the Int "Penalty", go figure.

*/////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
/*//////////////////////*/ int Penalty = 25; /////////////////////////////
//The magic number, this is a percent of the XP taken that is actually stored \\\\
//in the bank. Ex, if they deposit 100 XP, only 25 XP is stored for withdraw. \\\\
////////////////////////////////////////////////////////////////////////////////
int fraction = 100/Penalty; // just a divider, to send the % to the other scripts,ignore.

// OK now, this I just threw in at the last second, if enabled, it will stop
// people from withdrawing after they reach a certain amount of XP.

int WithdrawCap = FALSE; // set as 'TRUE' if you want to stop them from withdrawing after a certain lvl
int XPcap = 190000; //this is the number to have them stop at, 190k = lvl 20
string slvlcap = "I am sorry, but you currently have too many experience points for me to help you.";
// and that's the happy message you tell them. ^^
/////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
/*
//
//
//
*/
// These next lines just prevents ppl from dumping thier XP if thier below a designated lvl
// I believe there is a reason I did those, aside from making slackers hit lvl 10 or so,
// but you can probly jut set it to 1, and it'll turn this feature off
int lvl = 10; // meaning u have to be lvl 10 or higher to dump ALL your XP into bank.
string slvl = IntToString(lvl);
string sNO = "Sorry, but you need to be at least level "+slvl+" to deposit all your experience.";


Kato

Modifié par Kato_Yang, 22 juin 2011 - 05:54 .


#18
Lazarus Magni

Lazarus Magni
  • Members
  • 1 134 messages
Ok, sorry about the delay Kato, had to spend some time with a lady friend, and then been getting bogged down with just trying to get the module up and functioning correctly prior to making major customizations.

So I have followed you up to the point of swaping out the campaign integers. When I do that I get the error:
6/24/2011 1:16:43 AM: Error. 'xp_deposit_100k' did not compile.
xp_deposit_100k.nss(11): ERROR: DECLARATION DOES NOT MATCH PARAMETERS

pointing to line 11 which I have as:
int fXP = GetPersistentInt( "XP", sCDKey) + DepositXP;

Just so you can see if I set this up as per your example here is one of the scripts that is throwing this error:
#include "xp_inc"
void main()
{
object oPC =GetPCSpeaker();
 if (GetHitDice(oPC) >= 20)
  {
  int DepositXP = 100000/fraction;
  string sDepositXP = IntToString(DepositXP);
  string sCDKey = GetPCPublicCDKey( oPC);
  int fXP = GetPersistentInt( "XP", sCDKey) + DepositXP;
  int XP = GetXP(oPC) - 100000;
   SetPersistentInt( "XP", sCDKey, fXP);
   SetXP(oPC, XP);
   SpeakString ("You have deposited "+ sDepositXP +" XP.");
  }
else
   {
    SpeakString ("Sorry, but you need to be at least level 40 to use this feature.");
   }
}

So, I have the error, but not sure what to do about it.
Laz
P.S. I did change it from level 10 to level 40 in the xp_inc script in case you were wondering why it says lvl 40.

Modifié par Lazarus Magni, 24 juin 2011 - 06:22 .


#19
Kato -

Kato -
  • Members
  • 392 messages
Take a look at the example a few posts above this one, it's exactly with the same function you just posted. If you follow the instructions given with the example for all the scripts wich call database functions in your system, you should have no trouble.

Kato

#20
Lazarus Magni

Lazarus Magni
  • Members
  • 1 134 messages
So your saying just ignore the error?

Edit:
Well I tried this (testing locally, but connected to a MySQL database), but now it is removing exp, and not saving it apparently. When I had tried it previously just using it out of the package so to speak, it actually worked fine, except for the fact that when I would go to withdraw exp, I could keep withdrawing it beyond what I had stored in the bank. So now I am really confused.... Seems like we have made some progress but still not quite working right.

Modifié par Lazarus Magni, 24 juin 2011 - 07:21 .


#21
Lazarus Magni

Lazarus Magni
  • Members
  • 1 134 messages
So alternatively to this whole system mentioned above, something Ghost said gave me an idea. I looked at the scripts for our persistant gold bank, and our releveler. I am wondering if I can use them modified to just make new exp bank scripts? As an example, some of the gold scripts are:

#include "aps_include"

// Used to deposit gold in the bank. oPC is the character depositing gold
// and iGold is the amount to deposit
void DepositGold(object oPC, int iGold);

// Used to withdraw gold from the bank. oPC is the character withdrawing gold
// and iGold is the amount to withdraw
void WithdrawGold(object oPC, int iGold);

// Returns the amount of gold the player has in the bank
int GetBankGold(object oPC);

void DepositGold(object oPC, int iGold)
{
int iMaxGold = 200000000; //Maximum gold that can be stored in the bank
int iBankGold;
string sPlayer = SQLEncodeSpecialChars(GetPCPlayerName(oPC));
string sSQL = "SELECT gold FROM bankvault WHERE player='" + sPlayer + "'";
SQLExecDirect(sSQL);
if (SQLFetch() == SQL_SUCCESS)
{
iBankGold = StringToInt(SQLGetData(1));
if ((iBankGold + iGold) > iMaxGold)
{
iGold = iMaxGold - iBankGold;
SendMessageToPC(oPC, "The maximum amount of gold you can store is "
+ IntToString(iMaxGold));
}
sSQL = "UPDATE bankvault SET gold=" + IntToString(iBankGold + iGold)
+ " WHERE player='" + sPlayer + "'";
SQLExecDirect(sSQL);
TakeGoldFromCreature(iGold, oPC, TRUE);
}
else
{
if (iGold > iMaxGold)
{
iGold = iMaxGold;
SendMessageToPC(oPC, "The maximum amount of gold you can store is "
+ IntToString(iMaxGold));
}
sSQL = "INSERT INTO bankvault (player,gold) VALUES ('" + sPlayer + "',"
+ IntToString(iGold) + ")";
SQLExecDirect(sSQL);
TakeGoldFromCreature(iGold, oPC, TRUE);
}
}

int GetBankGold(object oPC)
{
int iBankGold = 0;
string sPlayer = SQLEncodeSpecialChars(GetPCPlayerName(oPC));
string sSQL = "SELECT gold FROM bankvault WHERE player='" + sPlayer + "'";
SQLExecDirect(sSQL);
if (SQLFetch() == SQL_SUCCESS)
{
iBankGold = StringToInt(SQLGetData(1));
}
else
{
sSQL = "INSERT INTO bankvault (player,gold) VALUES ('" + sPlayer + "',0)";
SQLExecDirect(sSQL);
}
return iBankGold;
}

void WithdrawGold(object oPC, int iGold)
{
int iBankGold = GetBankGold(oPC);
string sPlayer = SQLEncodeSpecialChars(GetPCPlayerName(oPC));
string sSQL = "UPDATE bankvault SET gold=" + IntToString(iBankGold - iGold)
+ " WHERE player='" + sPlayer + "'";
SQLExecDirect(sSQL);
GiveGoldToCreature(oPC, iGold);
}

and than an example of a deposit amount script:

#include "jk_inc_bank"

void main()
{
object oPC = GetPCSpeaker();
int iGold = 10000;
DepositGold(oPC, iGold);
ExportSingleCharacter(oPC);
}

And also in case any sort of interger information, and translation (gp to xp) might be needed here is an example of one of the releveler scripts:
#include "conf_module"

void main( )
{
object oPC = GetPCSpeaker( );

int nXP = GetXP( oPC );
int nXPAfter = FloatToInt(IntToFloat(nXP) * IntToFloat(RELEVEL_XP_PENALTY) / 100.00);
SetXP( oPC, 10000 );
SetXP( oPC, nXPAfter );
}

Modifié par Lazarus Magni, 24 juin 2011 - 08:02 .


#22
Lazarus Magni

Lazarus Magni
  • Members
  • 1 134 messages
Specifically what I am thinking is something along these lines:
#include "aps_include"

// Used to deposit Experience in the bank. oPC is the character depositing gold
// and iXP is the amount to deposit
void DepositGold(object oPC, int iXP);

// Used to withdraw Experience from the bank. oPC is the character withdrawing gold
// and iXP is the amount to withdraw
void WithdrawGold(object oPC, int iXP);

// Returns the amount of Experience the player has in the bank
int GetBankXP(object oPC);

void DepositXP(object oPC, int iXP)
{
int iMaxXP = 200000000; //Maximum Experience that can be stored in the bank
int iBankXP;
string sPlayer = SQLEncodeSpecialChars(GetPCPlayerName(oPC));
string sSQL = "SELECT Experience FROM bankvault WHERE player='" + sPlayer + "'";
SQLExecDirect(sSQL);
if (SQLFetch() == SQL_SUCCESS)
{
iBankXP = StringToInt(SQLGetData(1));
if ((iBankXP + iXP) > iMaxXP)
{
iXP = iMaxXP - iBankXP;
SendMessageToPC(oPC, "The maximum amount of Experience you can store is "
+ IntToString(iMaxXP));
}
sSQL = "UPDATE bankvault SET Experience=" + IntToString(iBankXP + iXP)
+ " WHERE player='" + sPlayer + "'";
SQLExecDirect(sSQL);
TakeExperienceFromCreature(iXP, oPC, TRUE);
}
else
{
if (iXP > iMaxXP)
{
iXP = iMaxXP;
SendMessageToPC(oPC, "The maximum amount of Experience you can store is "
+ IntToString(iMaxXP));
}
sSQL = "INSERT INTO bankvault (player,Experience) VALUES ('" + sPlayer + "',"
+ IntToString(iXP) + ")";
SQLExecDirect(sSQL);
TakeExperienceFromCreature(iXP, oPC, TRUE);
}
}

int GetBankXP(object oPC)
{
int iBankXP = 0;
string sPlayer = SQLEncodeSpecialChars(GetPCPlayerName(oPC));
string sSQL = "SELECT Experience FROM bankvault WHERE player='" + sPlayer + "'";
SQLExecDirect(sSQL);
if (SQLFetch() == SQL_SUCCESS)
{
iBankXP = StringToInt(SQLGetData(1));
}
else
{
sSQL = "INSERT INTO bankvault (player,Experience) VALUES ('" + sPlayer + "',0)";
SQLExecDirect(sSQL);
}
return iBankXP;
}

void WithdrawExperience(object oPC, int iXP)
{
int iBankExperience = GetBankExperience(oPC);
string sPlayer = SQLEncodeSpecialChars(GetPCPlayerName(oPC));
string sSQL = "UPDATE bankvault SET Experience=" + IntToString(iBankXP - iXO)
+ " WHERE player='" + sPlayer + "'";
SQLExecDirect(sSQL);
GiveExperienceToCreature(oPC, iXP);
}

Except I do that I get the error message:
6/24/2011 3:38:59 AM: Error. 'laz_inc_xpbank' did not compile.
laz_inc_xpbank.nss(33): ERROR: UNDEFINED IDENTIFIER (TakeExperienceFromCreature)

So perhaps using some of the integers from the releveler scripts like:
int nXP = GetXP( oPC );

#23
Kato -

Kato -
  • Members
  • 392 messages
Now that's a different system... Not a problem, but I'll pm/email you instead of continuing online, I would not want to overload the forums.

Kato

Modifié par Kato_Yang, 24 juin 2011 - 04:51 .


#24
Lazarus Magni

Lazarus Magni
  • Members
  • 1 134 messages
Sounds good Kato. I merely presented that as a possible alternative if I can't get the vault one to work with my mod. Honestly whichever is easiest to implement would be my preferance since I have a ton of other stuff I am trying to work on too.