View previous topic :: View next topic |
Author |
Message |
Blayde Windwalker
Joined: 02 Jan 2005 Posts: 18
|
Posted: Sat Jan 15, 2005 18:46 Post subject: Persistant Banking Scripts |
|
|
Hey all, can any of you post a set of working scripts that use the new functionality of NWNX2?
I have been searching all over for a good set of scripts but they all seem to have one problem or another. Looks like the way to go is to follow Old Man Whistlers design as it does not appear to actually open the chest. This has been a problem in a lot of the scripts using a chest, it eventually screws up and stays open, leading to dupe bugs.
Any help would sincerely be appreceiated. Thanks in advance.
I have looked at the new example scripts in aps_demo.mod, but is has no code in it to store persistent data using the StoreCampaignObject ("NWNX...) that I can use as an example. |
|
Back to top |
|
|
MacLir
Joined: 13 Jan 2005 Posts: 22
|
Posted: Sat Jan 15, 2005 20:57 Post subject: |
|
|
Blayde Windwalker wrote: | I have looked at the new example scripts in aps_demo.mod, but is has no code in it to store persistent data using the StoreCampaignObject ("NWNX...) that I can use as an example. |
The 2 functions you want for object storage and retrieval are listed in aps_include:
Code: | // Set oObject's persistent object with sVarName to sValue
// Optional parameters:
// iExpiration: Number of days the persistent variable should be kept in database (default: 0=forever)
// sTable: Name of the table where variable should be stored (default: pwobjdata)
void SetPersistentObject(object oObject, string sVarName, object oObject2, int iExpiration = 0, string sTable = "pwobjdata");
// Get oObject's persistent object sVarName
// Optional parameters:
// sTable: Name of the table where object is stored (default: pwobjdata)
// * Return value on error: 0
object GetPersistentObject(object oObject, string sVarName, object oOwner = OBJECT_INVALID, string sTable = "pwobjdata");
|
|
|
Back to top |
|
|
DarkstarsDad
Joined: 17 Jan 2005 Posts: 59 Location: Overland Park, Kansas USA
|
Posted: Tue Jan 18, 2005 2:09 Post subject: script for bank vaults |
|
|
Here are the scripts you will need to use the new functions as a storage system. It handles all items but it can only store 65000 gp, after that it does some interesting math and you usually lose some. one script is for open and one for close. It only alows the same player character to access it. so one chest can be used by all players. It could be modified for different peramiters. but this covers all the basics. it replaced over 25 scripts and 2 tables in my db. GOD I Love the NWNX team and comunity.
Well heres the onopen script.
Code: |
// Name : On open for persistant chests.
// Purpose : Retrieve objects from the database
// Authors : Ingmar Stieger Modified by Bernard Callesen
// Modified : January 1st, 2005 January 17th, 2005
// This file is licensed under the terms of the
// GNU GENERAL PUBLIC LICENSE (GPL) Version 2
#include "aps_include"
void main()
{
int iItem;
int bContinue = TRUE;
object oCreated;
object oChest1 = GetObjectByTag("your_chests_name");
object oOwner = GetLastOpenedBy();
/* Method 1: GetPersistentObject
*
* Use this method for simplicity.
*/
while (bContinue)
{
oCreated = GetPersistentObject(oOwner, "Item_" + IntToString(iItem), oChest1);
DeletePersistentVariable(oOwner, "Item_" + IntToString(iItem), "pwobjdata");
if (!GetIsObjectValid(oCreated))
bContinue = FALSE;
else
iItem++;
}
/* Method 2: Loop over resultset
*
* Use this method if you need the flexibility of SQL resultsets
*/
/* string sSQL = "SELECT val FROM pwobjdata WHERE player='~'" +
"AND tag='" + GetTag(oChest1) + "'";
SetLocalString(GetModule(), "NWNX!ODBC!SETSCORCOSQL", sSQL);
// The first call to RCO executes the SQL query and returns the first row.
oCreated = RetrieveCampaignObject ("NWNX", "-", GetLocation(oChest1), oChest1);
while (GetIsObjectValid(oCreated))
{
// "FETCHMODE" tells RCO to not execute the SQL statement again, but to
// just advance to the next row in the resultset
oCreated = RetrieveCampaignObject("NWNX", "FETCHMODE", GetLocation(oChest1), oChest1);
iItem++;
}
*/
SendMessageToPC(GetFirstPC(), "Retrieved " + IntToString(iItem) + " objects from database.");
}
|
and the onclose:
Code: |
// Name : On close for persistant chests.
// Purpose : Store objects in the database
// Authors : Ingmar Stieger Modified by Bernard Callesen
// Modified : January 1st, 2005 January 17th, 2005
// This file is licensed under the terms of the
// GNU GENERAL PUBLIC LICENSE (GPL) Version 2
#include "aps_include"
void main()
{
int iItem;
object oChest = GetObjectByTag("your_chests_name");
object oItem = GetFirstItemInInventory(oChest);
object oOwner = GetLastClosedBy();
while (GetIsObjectValid(oItem))
{
SetPersistentObject(oOwner, "Item_" + IntToString(iItem), oItem);
DestroyObject(oItem);
oItem = GetNextItemInInventory(oChest);
iItem++;
}
SendMessageToPC(GetFirstPC(), "Stored " + IntToString(iItem) + " objects in database.");
}
|
Put these on any chest and change the chest name in the script. |
|
Back to top |
|
|
Blayde Windwalker
Joined: 02 Jan 2005 Posts: 18
|
Posted: Tue Jan 18, 2005 18:23 Post subject: Thanks |
|
|
Thanks for the help on this, guys. I will continue to see if I can modify some existing scripts I have found to include this stuff.
I am new to scripting, so it may take a while.
If seems there has just got to be a solution out there somewhere using NWNX and a good chest/banker scripts.
Hopefully one would also address duping exploits and the problem with chests getting stuck open. |
|
Back to top |
|
|
DarkstarsDad
Joined: 17 Jan 2005 Posts: 59 Location: Overland Park, Kansas USA
|
Posted: Tue Jan 18, 2005 21:02 Post subject: dupes and stuck chests. |
|
|
I have been testing this script with the new function on nwnx2. As of today i cant get it to mess up. 5 dayss of testing and other than the money limit. i cant seem to make it mess up yet. only the pc that put the items in can retrieve them even if you log in as same person. but with different character. or characters with similar names. no mess ups. other than the gp limit. and from what i read that is a nw limit on the way the game looks at coins stacked in a box. All other items so far tested have been saved and recreated perfectly. and no stuck lid or anything. if the char does not close the chest the items are not stored but they are also not destroyed. so even if you put them in the box then walk away with out closing the items are still there when you return. This is so cool like i said it saved me a lot of codes i was using b4 |
|
Back to top |
|
|
Beowulf
Joined: 23 Jan 2005 Posts: 4 Location: Austin, TX
|
Posted: Sun Jan 23, 2005 19:30 Post subject: |
|
|
Why not use that set of scripts just for item storage? Then create a banker NPC and allow deposit and withdrawl of gold via conversation with the banker... This way you don't run into the 65000 GP problem. Granted it's not as cool as dragging-n-dropping stacks of gold, but it is straight-forward and works well. _________________ -Beowulf |
|
Back to top |
|
|
DarkstarsDad
Joined: 17 Jan 2005 Posts: 59 Location: Overland Park, Kansas USA
|
Posted: Mon Jan 24, 2005 3:42 Post subject: Thats what i was working on |
|
|
My idea. i have been working on doing that. but glad to know im not the only one thinking like that. |
|
Back to top |
|
|
Blayde Windwalker
Joined: 02 Jan 2005 Posts: 18
|
Posted: Mon Jan 24, 2005 18:54 Post subject: Publish please |
|
|
Can you publish a complete set of scripts to do the banks and chest storage? I thank you in advance! |
|
Back to top |
|
|
Tuebits
Joined: 27 Jan 2005 Posts: 18
|
Posted: Sat Jan 29, 2005 4:47 Post subject: |
|
|
I am trying to get a PW banker that will only store gold via conversation myself.."I want to deposit 10 000 gold, also to be able to see account balance. all the scrift i have found on NWVault was designed for My SQ, not SQlite which comes with the new OBDC..
I have to admit, i know nothing about setting up databases, was nice there was an aps_ mod the setup an sqlite database, but i have no clue what i am doing, and so far everything i have read is above my head |
|
Back to top |
|
|
DarkstarsDad
Joined: 17 Jan 2005 Posts: 59 Location: Overland Park, Kansas USA
|
Posted: Sun Jan 30, 2005 23:15 Post subject: Post script |
|
|
I will be glad to post it when I gett it working. Trying to automate it so the chest takes gold out and stores it as string and deleates it from the chest when you close it. then recreates it when you open the chest again. with no dialog needed think it will be cleaner and easier to use. The item storage is working perfectly so far. tested it about everyway i could think of to mess it up. even used different logins with same char and it denied access. same login different char and so on. so far not one miss. if i get the gold stripper to work right. it will be realy nice and easy to opperate. |
|
Back to top |
|
|
Blayde Windwalker
Joined: 02 Jan 2005 Posts: 18
|
Posted: Mon Jan 31, 2005 17:37 Post subject: Thanks |
|
|
Looks like there is good news on the horizon. Thanks, DarkstarsDad! |
|
Back to top |
|
|
Makzimia De Graf
Joined: 31 Dec 2004 Posts: 55 Location: San Diego CA.
|
Posted: Mon Jan 31, 2005 19:42 Post subject: |
|
|
Real total storage of gold awesome!! BTW, does anyone need the code to auto-fix the chests if someone sticks the lids open? if there is enough demand, I'll post our current chests up on the vault they can't be stuffed anymore due to a rather nasty but persistent bioware bug, addicted ( our head dev) came up with this.
Makz. _________________ Makzimia De Graf
DM/Creator Island of Fredian
fredian.game-host.org:5123
Forums at http://castille.us/fredian/Forums |
|
Back to top |
|
|
DarkstarsDad
Joined: 17 Jan 2005 Posts: 59 Location: Overland Park, Kansas USA
|
Posted: Tue Feb 01, 2005 5:23 Post subject: gold and scripts |
|
|
The gold is getting me down. There seems to be a limit to the stack items on chests. can create alot of 50000GP bags in the chest and it handles them well. but i cant seem to stack it any higher. and since you cant just create GP in a chest I am kinda stumped. Does anyone have any ideas on how to get around this limit? Makzimia De Graf yes i would be interested in the script. I havent been able to stick these chests yet but i can look at the script and see if it might be applicable. |
|
Back to top |
|
|
Xildjian
Joined: 08 Jan 2005 Posts: 100
|
Posted: Wed Feb 02, 2005 21:22 Post subject: |
|
|
I'm confused.
Why are you using a chest to store gold for banking?
I created some scritps where the player talks to an NPC banker to check their balance, and to make a deposit/withdraw. It seems to work pretty nice.
I created a table that looks like:
cdkey(string) playerName(string) Money(long int)
I tied the search to a players cdkey so they can access their account with any of their characters on the server.
I'm just using the access ODBC, and I cheated and added the table to my database with access. _________________ Member Shadow of Iniquity development team |
|
Back to top |
|
|
Blayde Windwalker
Joined: 02 Jan 2005 Posts: 18
|
Posted: Wed Feb 02, 2005 21:54 Post subject: Why don't you two get together |
|
|
Please see if you two can get together and combine your code. Then you can release one file with a total solution for banking and item storage in chests. You might also look at the forementioined fix for stuck chests.
Seem most every piece of code I looked at for chests would eventually get stuck open and then peeps could dupe stuff.
Thanks in advance for your efforts. |
|
Back to top |
|
|
|