Modifié par Lazarus Magni, 17 juin 2011 - 10:03 .
Can anyone point me to a script or utility that removes/merges items from players on log in?
#26
Posté 17 juin 2011 - 10:03
#27
Posté 18 juin 2011 - 07:51
Lazarus Magni wrote...
Secondly Ghost could you elaborate on what a "non drop database item" is? Do you mean just a new item (and it's associated tag) created in the mod (via the toolset)?
There are different types of ways to use a database in NWN. You can use the one Bioware provided with function like SetCampaignInt, etc. You can use something like SQL with NWNx. Or what I and a lot of other people prefer to do is just store variables on an item the player will always have. A "database item". Something like a rule book. Or one of the dmfi widgets like the dicebag or what not. Just something that ALL player will have and flagged/checked as Undropable in the toolset so that the players can not get rid of it.
You can store all kinds of information that pertains to that particular player. Kills, deaths, quest info, saved locations, etc. Anything that you need to be persistent. And the "one time item check" would be one of those things that would be perfect for this. The script runs and then sets a variable on your "database item". Then any time the player enters the mod the first thing that is checked is that variable on the database item. If the variable is there, then the script doesn't get fired.
Hope the info is helpful.
EDIT: I did just alter the last script I posted on the previous page. It hit me at work that if you did use a "database item" method, that item would be destroyed in the process. I fixed it so it would leave that one item alone. I also added a much needed ExportSingleCharacter line to make sure that all the new items are saved as well as the variable on the database item.
And again if you prefer other methods of "database" use then this script could be altered to fit whatever type you would use.
Modifié par GhostOfGod, 18 juin 2011 - 07:59 .
#28
Posté 18 juin 2011 - 07:20
#29
Posté 18 juin 2011 - 07:43
Funky
#30
Posté 18 juin 2011 - 08:28
FunkySwerve wrote...
If you're already using MySQL, there's absolutely no reason to use a DB item, and a number of reasons not to.
Funky
I can only take this statment to be an opinon.
To me the greatest benifit for useing a DB item is keeping the data with the characters Bic file.
Don't get me wrong, I am not saying that there are no drawbacks to using DB items. But there are still some benifits.
Lets say I have a player in a PW that want to delete a few character from his vault. Once I have deleted his characters the data that was stored on his DB item is gone. I do not need to create a system to also remove data for that character from an external DB. Most people in this position would just leave the unneeded data in the DB.
To me the DB item is just an extention of the Character's Data structure. If there is ever anything where I could say. "It sure would be nice to just have this as part of the character structure." I just add it to the DB item and save it out as part of the characters structure.
#31
Posté 18 juin 2011 - 09:05
It's not opinion, it's fact. That 'benefit' is a huge drawback, since it makes that data highly inaccessible when the character is offline, short of digging into their bic with a gff editor. By contrast, you can easily wipe all data related to a character with a single MySQL DELETE FROM call. No 'system' required, beyond the system you already need in any MySQLor other database setup for connecting database entries to bic files - by default, correlation of player and character name, or, in more advanced setups, a unique id.Lightfoot8 wrote...
FunkySwerve wrote...
If you're already using MySQL, there's absolutely no reason to use a DB item, and a number of reasons not to.
Funky
I can only take this statment to be an opinon.
To me the greatest benifit for useing a DB item is keeping the data with the characters Bic file.
Don't get me wrong, I am not saying that there are no drawbacks to using DB items. But there are still some benifits.
Lets say I have a player in a PW that want to delete a few character from his vault. Once I have deleted his characters the data that was stored on his DB item is gone. I do not need to create a system to also remove data for that character from an external DB. Most people in this position would just leave the unneeded data in the DB.
To me the DB item is just an extention of the Character's Data structure. If there is ever anything where I could say. "It sure would be nice to just have this as part of the character structure." I just add it to the DB item and save it out as part of the characters structure.
Then, of course, there's all the other applications where the bic file's inaccessibility is an even bigger drawback. Suppose you want to know how many characters have a given variable set. With a database item, that means going into each bic individually, or, if you have the savvy, writing an extensive letoscript for Moneo to scan up the data. By contrast, with MySql, it's just another single call.
I can only assume from your mistaken assumptions about MySQL that you don't use it yourself?
Funky
#32
Posté 18 juin 2011 - 10:41
You are correct that I do not use MySQL for the NWN DB. I also do not use NWNx.FunkySwerve wrote...
I can only assume from your mistaken assumptions about MySQL that you don't use it yourself?
Funky
I already stated that a DB item has draw backs and the one you state here is by far the biggest. It is also why you do not store information that you want to gain while the character is off line on a DB item.Then, of course, there's all the other applications where the bic file's inaccessibility is an even bigger drawback. Suppose you want to know how many characters have a given variable set. With a database item, that means going into each bic individually, or, if you have the savvy, writing an extensive letoscript for Moneo to scan up the data. By contrast, with MySql, it's just another single call.
I would hold that the storage of the unique id in more advanced setups would be good use of a DB item. Even if it was the only data on the item.By contrast, you can easily wipe all data related to a character with a single MySQL DELETE FROM call. No 'system' required, beyond the system you already need in any MySQLor other database setup for connecting database entries to bic files - by default, correlation of player and character name, or, in more advanced setups, a unique id.
I am not trying to start an argument here. I am just stating my opinion.
#33
Posté 18 juin 2011 - 11:00
#34
Posté 18 juin 2011 - 11:12
I already stated that a DB item has draw backs and the one you state here is by far the biggest. It is also why you do not store information that you want to gain while the character is off line on a DB item.
[/quote]
The problem is, that that category - things you might want to check offline - is very large, especially if you want to leave open future functionality.
[quote]
I would hold that the storage of the unique id in more advanced setups would be good use of a DB item. Even if it was the only data on the item. [/quote]
Unique ids are best stored on things that players can't mess with - bic fields. There are ways to force undroppable items out of inventory. Though you could probably make it VERY counter to their interests to do so, with a little creative coding.
[/quote]
[quote]
I am not trying to start an argument here. I am just stating my opinion.
[/quote]
Two man enter. One man leave.
Funky
Modifié par FunkySwerve, 18 juin 2011 - 11:16 .
#35
Posté 18 juin 2011 - 11:13
Just SetPersistent some variable on them, and check for it before you run the item reset. Are you setting your Persistent vars as locals on the pc for faster reads? If not, I'd recommend doing so, and would be happy to show you how.Lazarus Magni wrote...
So if I don't use the database item approach (and as I mentioned the mod is already set up to be run with nwnx and a MySQL database, or at least that is how it was done in the past, and I am assuming there are things [like scripts, and functions] with in the mod that depend on it being run as such in the future.) how would you flag a PC as having had the item check run?
Funky
#36
Posté 19 juin 2011 - 12:26
#37
Posté 19 juin 2011 - 01:40
When you replace all of a character's items with updated versions, you need to somehow mark that character as having had all their items replaced (so that the process doesn't run every time they enter the mod or trigger or however it's set to run). To mark them, you set a variable on them.and have the script check for it before running. Setting a variable on a player in-game only lasts until the server resets, but setting a Persistent variable sets it in the external database (like MySQL) which keeps track across resets.
Since I have no experience with databases, I would do what GoG suggested and give the player an item that they can't drop, trade, sell, etc. You can set variables on that item in their inventory and all those variables are saved across server resets, because it is part of the character file. No database knowledge required, but of course you can't do many spiffy things Funky is talking about.
I think if you used GoG's script, set it on a trigger that every player must walk thru when entering the mod, and have it give them an item tthey can't drop, sell, trade, etc and set the variable on that item, then you'll be done.
#38
Posté 19 juin 2011 - 02:46
Don't worry about it. Just use SetPersistent from the nwnx database include to set a variable, and GetPersistent to check it. If it's not been set, set it, and replace all the character's items.Lazarus Magni wrote...
I feel stupid here, but sadly I don't know that mean's Funky, so I would say no not intentionally, however I have no idea what previous devs have done in that regard.
Lastly, ignore the people telling you to use a database item. With MySQL available, that would be completely harebrained. If you need me to supply you a script, I'm hapy to do so.
Funky
Modifié par FunkySwerve, 19 juin 2011 - 02:55 .
#39
Posté 19 juin 2011 - 02:47
If this is the case, why on earth are you posting in this thread? SetPersistent isn't 'jargon', it's a reference to a specific function that comes packaged with the default NWNX install, which you would know if you had said experience.Terrorble wrote...
Since I have no experience with databases,
Funky
#40
Posté 19 juin 2011 - 03:07
I personally haven't experienced any drawbacks from using a "database item". Quite the contrary.
But yes if you are going to be using mysql and have it all set up and what not, then you might as well use it since it is much more versatile.
Modifié par GhostOfGod, 19 juin 2011 - 03:17 .
#41
Posté 19 juin 2011 - 03:43
#include "aps_include"
void ResRefMatchReplace(object oItem, object oTarget) {
string sResRef = GetResRef(oItem);
DestroyObject(oItem);
object oReplacement = CreateItemOnObject(sResRef, oTarget);
if (!GetIsObjectValid(oReplacement))
WriteTimestampedLogEntry("Character: " + GetName(oTarget) + " (playername: " +
GetPCPlayerName(oTarget) + "): No replacement item for " +GetName(oItem) +
" (resref: " + sResRef + ").");
}
void CheckReplaceItems(object oTarget){
if (!GetIsPC(oTarget) ||
GetPersistentInt(oTarget, "ItemsReplaced"))
return;
SetPersistentInt(oTarget, "ItemsReplaced", 1);
object oItem = GetFirstItemInInventory(oTarget);
int iSlot;
//Get items in inventory and replace if needed
while (GetIsObjectValid(oItem)) {
//if item is a container, loop through items inside
if (GetHasInventory(oItem)) {
object oConItem = GetFirstItemInInventory(oItem);
while (GetIsObjectValid(oConItem)) {
ResRefMatchReplace(oConItem, oTarget);
oConItem = GetNextItemInInventory(oItem);
}
} else
ResRefMatchReplace(oItem, oTarget);
oItem = GetNextItemInInventory(oTarget);
}
//Get equipped items and replace if necessary
for (iSlot=0; iSlot<NUM_INVENTORY_SLOTS; iSlot++) {
oItem = GetItemInSlot(iSlot, oTarget);
if (GetIsObjectValid(oItem))
ResRefMatchReplace(oItem, oTarget);
}
}
Then include it in the area onenter script for the first area pcs spend any substantial time. In that script, just Get the entering object, and call CheckReplaceItems on them, like so:
#include "item_replace_inc"
void main() {
object oEnter = GetEnteringObject();
CheckReplaceItems(oEnter);
}
If it generates lag hiccups from the mass replacements, let me know, and I'll write you one with recursive delays like the one I pasted on the first page of this thread.
LMK if you have any questions.
Funky
Modifié par FunkySwerve, 19 juin 2011 - 03:44 .
#42
Posté 19 juin 2011 - 05:26
FunkySwerve wrote...
If this is the case, why on earth are you posting in this thread? SetPersistent isn't 'jargon', it's a reference to a specific function that comes packaged with the default NWNX install, which you would know if you had said experience.Terrorble wrote...
Since I have no experience with databases,
Funky
I'm not usually argumenative, but why not.
It is jargon, and did not appear to be completely understood.
Lack of experience does not preclude my offering clarification, and a suggestion - that would work.
The jargon comment was not directed, but I see how it looks that way.
Sorry to argue.
#43
Posté 19 juin 2011 - 05:31
for some reason when you guys speak it makes alot of sense to me. I think you must have some skill bonus to newbie dev relations or something.
@ Funky,
It seems you are a bit overly defensive. Quite understandable actually given the BS that goes on in online forums (or e-mail chains for that matter), and also due to the fact that text vs vocalizations lends messages transmited as such being open to much more interpertation from the receiver, than perhaps may have been originally intended. But be assured I appreciate your efforts to help me with this, as I do everyones. Sadly due to my own inexperience I have alot of trouble deciphering what you are saying.
@ All,
It seems there are competing ideas on how to achieve this goal. To me though they aren't competing just different alternatives (options are always good). Database item solutions seems more straight forward (and newbie friendly), yet Funky's approach seems more flexible (yet requires some basic understanding of the componets used [e.g. nwnx and its plugins, or MySQL], which unfortunately I don't have.)
Regardless, the server is set up with nwnx, and a mysql database, although it sounds like a database item approach would be workable with in that. I may try both in the dev mod and see what happens. Thank you again everyone so much!
Laz
Modifié par Lazarus Magni, 19 juin 2011 - 05:32 .
#44
Posté 19 juin 2011 - 06:09
Defensive? Not at all. I just don't have a great deal of patience for people who insist on talking about things they don't understand. There's just more of that going on in this thread than usual.Lazarus Magni wrote...
@ Funky,
It seems you are a bit overly defensive. Quite understandable actually given the BS that goes on in online forums (or e-mail chains for that matter), and also due to the fact that text vs vocalizations lends messages transmited as such being open to much more interpertation from the receiver, than perhaps may have been originally intended. But be assured I appreciate your efforts to help me with this, as I do everyones. Sadly due to my own inexperience I have alot of trouble deciphering what you are saying.
In any event, if their comments have made you feel the need to try using a database item, then they've done you a disservice - it's actually more complex, as well as less useful, since you already have nwnx databasing set up. By all means, though, feel free to ignore the code I posted and do whatever you like. You can lead a horse to water...
Funky
#45
Posté 19 juin 2011 - 08:27
I most certainly am guilty of talking about things I don't understand, and believe me it is not by choice. It is pure necessity that I am having to confront these issues, and my lack of understanding is merely due to my inexperience along with the fact that other than these boards I am having to try to do this stuff on my own thus far.
I most certainly would like to try the script you made Funky, but I would prolly require some guidance unfortunately. I can make a new script in the mod by cut and pasting what you posted, and attach it to the onclient enter script (by adding the execute script xyx line to the end I think), but I don't know what " In that script, just Get the entering object," means, or how to do that.
P.S. My comment toward you was not meant to agitate. I love you man, your PW is awsome, and your contribution to the NWN community in general is outstanding. I have just noticed you seem to feel adversarial towards others with differing opinions here sometimes (which I am sure in the context of past interactions with people on these boards in general is prolly justified), but all I was saying is we are just all friends here, just people, with different knowledge bases, and bound by a common interest (nwn).
Cheers!
Modifié par Lazarus Magni, 19 juin 2011 - 08:32 .
#46
Posté 19 juin 2011 - 08:07
That wasn't directed at you, but at some of the people offering you advice.Lazarus Magni wrote...
LOL Funky... I was just saying options are always good. Say in the future someone is using the standard nwn database, at least the alternatives presented here would give an option for them.
I most certainly am guilty of talking about things I don't understand, and believe me it is not by choice. It is pure necessity that I am having to confront these issues, and my lack of understanding is merely due to my inexperience along with the fact that other than these boards I am having to try to do this stuff on my own thus far.
All you have to do is execute the onenter I provided from your onenter, as you described. I could tell you were having difficulty, so I kept it simple.I most certainly would like to try the script you made Funky, but I would prolly require some guidance unfortunately. I can make a new script in the mod by cut and pasting what you posted, and attach it to the onclient enter script (by adding the execute script xyx line to the end I think), but I don't know what " In that script, just Get the entering object," means, or how to do that.
To elaborate, what I meant about getting the entering object, was to use the GetEnteringObject() function, as the onenter I provided does. In area onenter scripts like this one, it's a common way of getting the object we're usually interested in - the one that triggered the event. Feel free to ask whatever other questions you may have.
I wasn't agitated, honestly. And I'm always open to differing opinions and the input of others, so long as they're based on something. You'll notice I basically used GoG's script wholesale, for example, since it was sound as a pound.When it comes to people offering incorrect information or mischaracterizations about systems they've never used, however, I'm considerably less tolerant, since they're wasting their time, mine, and yours. I was reminded of nothing so much as virgins talking about how sex is no big deal.P.S. My comment toward you was not meant to agitate. I love you man, your PW is awsome, and your contribution to the NWN community in general is outstanding. I have just noticed you seem to feel adversarial towards others with differing opinions here sometimes (which I am sure in the context of past interactions with people on these boards in general is prolly justified), but all I was saying is we are just all friends here, just people, with different knowledge bases, and bound by a common interest (nwn).
Cheers!
Funky
#47
Posté 19 juin 2011 - 08:22
#48
Posté 19 juin 2011 - 09:46
// created by: GhostOfGod
// altered by: Greyfort
//
/*
This code can be used by a DM item or placed in a triger in the very first
area a pc will enter mod. This will insure that a PC wont run around a
world with a +20 vorpal time stoping sword...
*/
// will destory items set for destruction by local variable
// if( GetLocalString(oItem,"Destroy")=="VALID" ){DestroyObject(oItem);}
// SetLocalString(oItem,"Destroy","VALID");
void Destory_Items(object oPC=OBJECT_SELF);
void Destory_Items(object oPC=OBJECT_SELF)
{
object oItem = GetFirstItemInInventory(oPC);
while ( GetIsObjectValid(oItem)==TRUE )
{
if( GetLocalString(oItem,"Destroy")=="TRUE" ){DestroyObject(oItem);}
oItem = GetNextItemInInventory(oPC);
}
}
// find resref matched weapon
void ResRefMatchReplace(object oItem, object oTarget);
void ResRefMatchReplace(object oItem, object oTarget)
{
string sResRef = GetResRef(oItem);
if ( GetLocalString(oItem,"Updated")!="Updated")
{
// debug
SendMessageToPC( oTarget,"@@@...Item ResRef="+ sResRef +"...@@@");
object oReplacement = CreateItemOnObject(sResRef, oTarget,1);
if (GetIsObjectValid(oReplacement)==FALSE)
{
//do stuff if there is no item with matching res ref.
// if item doesn't have resref dont destroy, flag PC for DM intervention
// debug
SendMessageToPC( oTarget,"!!!...InValid Item...!!!");
SetLocalString(oItem,"Destroy","InValid");
SetLocalInt(oTarget,"DM_intrvn",TRUE);
}
else
{
// debug
SendMessageToPC( oTarget,"***...Valid Item...UPDATED***");
SetLocalString(oReplacement,"Updated","Updated");
SetLocalString(oItem,"Updated","Updated");
SetLocalString(oItem,"Destroy","TRUE");
}
}
}
//////////////////////////////[ END OF FUNCTIONS ]////////////////////////////
#include "x2_inc_switches"
void main()
{
// NOTE: this is code for a tool by GhostOfGod
/*
int iEvent = GetUserDefinedItemEventNumber();
if (iEvent != X2_ITEM_EVENT_ACTIVATE) return;
object oActivator = GetItemActivator();
if (!GetIsDM(oActivator)) return;
object oTarget = GetItemActivatedTarget();
object oItem = GetFirstItemInInventory(oTarget);
*/
// NOTE: this is code for trigger, trigers work better at clearing equiped gear.
// so I have found, then area event/scripts Greyfort
// here you will have to decide what DB you are using nwn_db or nwnx_db
// example useing nwn_db
string sDM_Name = "Help_Script_MOD";//""+GetModuleName()+"_"+"SaVE_LOC";
object oTarget = GetEnteringObject();
// resets vars for testing
SetCampaignInt(sDM_Name,"Gear_updtd",0,oTarget);
// custom player effect
effect ePlyr_update =EffectPetrify();
// save location invalid set
object oBadArea = GetObjectByTag("");
vector vBadVec = Vector(0.0,0.0,0.0);
location lbadloc = Location(oBadArea,vBadVec,0.0);
location lSave_Loc = GetCampaignLocation( sDM_Name,"Save_Loc",oTarget );
object oDflt_Start = GetObjectByTag("WP_oDflt_Start");
object oDM_Thrpy = GetNearestObjectByTag( "WP_oDM_Thrpy",oTarget );
int iSlot;
//------------------------------------------------------------------------------
// added check for update variable if false update if true jump to loc
// if update false update
if( GetCampaignInt(sDM_Name,"Gear_updtd",oTarget)==0 )
{
//Get items in inventory and replace if needed
// debug
SendMessageToPC( oTarget,"1)...Inventory check...");
object oItem = GetFirstItemInInventory(oTarget);
while (GetIsObjectValid(oItem)==TRUE )
{
//if item is a container, loop through items inside
if (GetHasInventory(oItem)==TRUE)
{
// debug
SendMessageToPC( oTarget,"2)...Container check...");
object oConItem = GetFirstItemInInventory(oItem);
while (GetIsObjectValid(oConItem)==TRUE)
{
ResRefMatchReplace(oConItem, oTarget);
oConItem = GetNextItemInInventory(oItem);
}
}
else
{
ResRefMatchReplace(oItem, oTarget);
}
oItem = GetNextItemInInventory(oTarget);
}
//Get equipped items and replace if necessary
// debug
SendMessageToPC( oTarget,"equipped items check...");
for (iSlot=0; iSlot< 13; iSlot++)
{
oItem = GetItemInSlot(iSlot, oTarget);
if (GetIsObjectValid(oItem))
{
ResRefMatchReplace(oItem, oTarget);
}
}
//-----------------------[jump player to apropriate loc]----------------
// now if player flagged for DM intervention jump play to DM Therepy...
if ( GetLocalInt(oTarget,"DM_intrvn")==TRUE)
{
// flag player not updated here:
SetCampaignInt(sDM_Name,"Gear_updtd",0,oTarget);
// jump to DM_area
//AssignCommand(oTarget,ClearAllActions(TRUE));
AssignCommand(oTarget,ActionJumpToObject( oDM_Thrpy ));
}
// now if player not flagged for DM intervention jump player to default start,
// or saved loc
if ( GetLocalInt(oTarget,"DM_intrvn")==FALSE)
{
//jump to save loc if valid else jump to default start
if (lSave_Loc != lbadloc)
{
// flag player updated here:
SetCampaignInt(sDM_Name,"Gear_updtd",1);
// jump to save_lov
//AssignCommand(oTarget,ClearAllActions(TRUE));
AssignCommand(oTarget,JumpToLocation( lSave_Loc ));
}
else
{
// flag player updated here:
SetCampaignInt(sDM_Name,"Gear_updtd",1,oTarget);
// jump to default start
//AssignCommand(oTarget,ClearAllActions(TRUE));
AssignCommand(oTarget,ActionJumpToObject( oDflt_Start ));
}
}
}//ENDO OF if( SetCampaignInt(sDM_Name,"Gear_updtd")==FALSE )
//------------------------------------------------------------------------------
// if update TRUE DONT update
if( GetCampaignInt(sDM_Name,"Gear_updtd",oTarget)==1 )
{
//jump to save loc if valid else jump to default start
if (lSave_Loc != lbadloc)
{
// flag player updated here:
SetCampaignInt(sDM_Name,"Gear_updtd",1,oTarget);
// jump to save_lov
//AssignCommand(oTarget,ClearAllActions(TRUE));
AssignCommand(oTarget,JumpToLocation( lSave_Loc ));
}
else
{
// flag player updated here:
SetCampaignInt(sDM_Name,"Gear_updtd",1,oTarget);
// jump to default start
//AssignCommand(oTarget,ClearAllActions(TRUE));
AssignCommand(oTarget,ActionJumpToObject( oDflt_Start ));
}
}//END if( SetCampaignInt(sDM_Name,"Gear_updtd")==TRUE )
//---!!!!!!!!!!--
// destroy items
//
// debug
SendMessageToPC( oTarget,"3)...DESTORYING Updated ITEMS...");
Destory_Items(oTarget);
//[END OF SCRIPT//]
}
This script placed on a triggers on enter event/script will check players gear update anything that is in the module palate even nwn default items, and if player has items that are not palate they will be flagged and sent to DM help area.
If your interested I can send you a mod ware all you will have to do is import dm area, start area, and script and your problem is solved.
EDIT: I forgot to add the DM area has a player option to not wait for a dm, just update items, destroy all invalid ones and start playing. Otherwise player can wait if thats an option. I tried to give every option I could in the example.
Modifié par Greyfort, 19 juin 2011 - 09:55 .
#49
Posté 20 juin 2011 - 01:06
// created by: GhostOfGod
// altered by: Greyfort
//
// pc_update_v2
// created by: GhostOfGod
// altered by: Greyfort
//
/*
this is one script with oput include file all functions needed are here for
script.
This code can be used by a DM item or placed in a triger in the very first
area a pc will enter mod. This will insure that a PC wont run around a
world with a +20 vorpal time stoping sword...
*/
//////////////[ Adjust only these variables ]//////////////////////
const int nDM_Therapy=FALSE;//DEFAULT FALSE;
const int nUPDate_Msgs=FALSE;//DEFAULT FALSE;
//===============================================================//
//////////////////////////////[ START OF FUNCTIONS ]////////////////////////////
//////////[ !!! Don not change functions unless quality scripter !!! ]//////////
// checks if location valid
int GetIsLocationValid(location lLocation);
int GetIsLocationValid(location lLocation)
{
// note you need to create a hidden creature wuth resref "Loctstr"
object oLoctstr = CreateObject (OBJECT_TYPE_CREATURE,"Loctstr",lLocation);
if (GetIsObjectValid(oLoctstr)==TRUE){DestroyObject(oLoctstr);return TRUE;}
return FALSE;
}
// destroys all items with var invalid
void Destory_InValidItems(object oPC=OBJECT_SELF);
void Destory_InValidItems(object oPC=OBJECT_SELF)
{
int iSlot;
object oItem = GetFirstItemInInventory(oPC);
while ( GetIsObjectValid(oItem)==TRUE )
{ //SetLocalString(oItem,"Destroy","InValid");
if( GetLocalString(oItem,"Destroy")=="InValid" ){DestroyObject(oItem);}
oItem = GetNextItemInInventory(oPC);
}
for (iSlot=0; iSlot< 13; iSlot++)
{
oItem = GetItemInSlot(iSlot, oPC);
if (GetIsObjectValid(oItem))
{
if( GetLocalString(oItem,"Destroy")=="InValid" ){DestroyObject(oItem);}
}
}
}
// will destory items set for destruction by local variable
// if( GetLocalString(oItem,"Destroy")=="VALID" ){DestroyObject(oItem);}
// SetLocalString(oItem,"Destroy","VALID");
void Destory_Items(object oPC=OBJECT_SELF);
void Destory_Items(object oPC=OBJECT_SELF)
{
object oItem = GetFirstItemInInventory(oPC);
while ( GetIsObjectValid(oItem)==TRUE )
{
if( GetLocalString(oItem,"Destroy")=="TRUE" ){DestroyObject(oItem);}
oItem = GetNextItemInInventory(oPC);
}
}
// find resref matched weapon
void ResRefMatchReplace(object oItem, object oTarget);
void ResRefMatchReplace(object oItem, object oTarget)
{
string sResRef = GetResRef(oItem);
if ( GetLocalString(oItem,"Updated")!="Updated")
{
// debug
if( nUPDate_Msgs==TRUE){SendMessageToPC( oTarget,"@@@...Item name & ResRef="+GetName(oItem)+" & "+sResRef +"...@@@");}
object oReplacement = CreateItemOnObject(sResRef, oTarget,1);
if (GetIsObjectValid(oReplacement)==FALSE)
{
//do stuff if there is no item with matching res ref.
// if item doesn't have resref dont destroy, flag PC for DM intervention
// debug
if( nUPDate_Msgs==TRUE){SendMessageToPC( oTarget,"!!!...InValid Item...!!!");}
SetLocalString(oItem,"Destroy","InValid");
if ( nDM_Therapy==TRUE){
SetLocalInt(oTarget,"DM_intrvn",TRUE);}
}
else if (GetIsObjectValid(oReplacement)==TRUE)
{
// debug
if( nUPDate_Msgs==TRUE){SendMessageToPC( oTarget,"***...Valid Item...UPDATED***");}
//SetLocalInt(oTarget,"DM_intrvn",FALSE);
SetLocalString(oReplacement,"Updated","Updated");
SetLocalString(oItem,"Updated","Updated");
SetLocalString(oItem,"Destroy","TRUE");
}
}
}
//////////////////////////////[ END OF FUNCTIONS ]////////////////////////////
#include "x2_inc_switches"
void main()
{
// NOTE: this is code for a tool by GhostOfGod
/*
int iEvent = GetUserDefinedItemEventNumber();
if (iEvent != X2_ITEM_EVENT_ACTIVATE) return;
object oActivator = GetItemActivator();
if (!GetIsDM(oActivator)) return;
object oTarget = GetItemActivatedTarget();
object oItem = GetFirstItemInInventory(oTarget);
*/
// NOTE: this is code for trigger, trigers work better at clearing equiped gear.
// so I have found, then area event/scripts Greyfort
// here you will have to decide what DB you are using nwn_db or nwnx_db
// example useing nwn_db
// !!! CHANGE VARIABLES HERE !!!
// TO your DB var, your waypoints Tags, Save_loc var
string sDM_Name = "Help_Script_MOD";
object oDflt_Start = GetObjectByTag("WP_oDflt_Start");
object oDM_Thrpy = GetObjectByTag( "WP_oDM_Thrpy" );
object oTarget = GetEnteringObject();
location lSave_Loc = GetCampaignLocation( sDM_Name,"Save_Loc",oTarget );
// resets vars for testing other wise uncoment // it out
//SetCampaignInt(sDM_Name,"Gear_updtd",0,oTarget);
int iSlot;
//------------------------------------------------------------------------------
// added check for update variable if false update if true jump to loc
// if update false update
if( GetCampaignInt(sDM_Name,"Gear_updtd",oTarget)==0 )
{
//Get items in inventory and replace if needed
// debug
if( nUPDate_Msgs==TRUE){SendMessageToPC( oTarget,"1)...Inventory check...");}
object oItem = GetFirstItemInInventory(oTarget);
while (GetIsObjectValid(oItem)==TRUE )
{
//if item is a container, loop through items inside
if (GetHasInventory(oItem)==TRUE)
{
// debug
if( nUPDate_Msgs==TRUE){SendMessageToPC( oTarget,"2)...Container check...");}
object oConItem = GetFirstItemInInventory(oItem);
while (GetIsObjectValid(oConItem)==TRUE)
{
ResRefMatchReplace(oConItem, oTarget);
oConItem = GetNextItemInInventory(oItem);
}
}
else
{
ResRefMatchReplace(oItem, oTarget);
}
oItem = GetNextItemInInventory(oTarget);
}
//Get equipped items and replace if necessary
// debug
if( nUPDate_Msgs==TRUE){SendMessageToPC( oTarget,"equipped items check...");}
for (iSlot=0; iSlot< 13; iSlot++)
{
oItem = GetItemInSlot(iSlot, oTarget);
if (GetIsObjectValid(oItem))
{
ResRefMatchReplace(oItem, oTarget);
}
}
//-----------------------[jump player to apropriate loc]----------------
// now if player flagged for DM intervention jump play to DM Therepy...
if ( nDM_Therapy==TRUE)
{
if ( GetLocalInt(oTarget,"DM_intrvn")==TRUE)
{
// flag player not updated here:
SetCampaignInt(sDM_Name,"Gear_updtd",0,oTarget);
// jump to DM_area
AssignCommand(oTarget,ClearAllActions(TRUE));
AssignCommand(oTarget,ActionJumpToObject( oDM_Thrpy ));
}
// now if player not flagged for DM intervention jump player to default start,
// or saved loc
if ( GetLocalInt(oTarget,"DM_intrvn")==FALSE)
{
//jump to save loc if valid else jump to default start
if (GetIsLocationValid(lSave_Loc)==TRUE)
{
// flag player updated here:
SetCampaignInt(sDM_Name,"Gear_updtd",1,oTarget);
// jump to save_lov
//AssignCommand(oTarget,ClearAllActions(TRUE));
AssignCommand(oTarget,JumpToLocation( lSave_Loc ));
}
else
{
// flag player updated here:
SetCampaignInt(sDM_Name,"Gear_updtd",1,oTarget);
// jump to default start
//AssignCommand(oTarget,ClearAllActions(TRUE));
AssignCommand(oTarget,ActionJumpToObject( oDflt_Start ));
}
}
}//END OF if ( nDM_Therapy=TRUE)
//////////////////////////////////
// not use dm_option
if ( nDM_Therapy==FALSE)
{
//jump to save loc if valid else jump to default start
if (GetIsLocationValid(lSave_Loc)==TRUE)
{
// flag player updated here:
SetCampaignInt(sDM_Name,"Gear_updtd",1,oTarget);
// jump to save_lov
//AssignCommand(oTarget,ClearAllActions(TRUE));
AssignCommand(oTarget,JumpToLocation( lSave_Loc ));
}
else
{
// flag player updated here:
SetCampaignInt(sDM_Name,"Gear_updtd",1,oTarget);
// jump to default start
//AssignCommand(oTarget,ClearAllActions(TRUE));
AssignCommand(oTarget,ActionJumpToObject( oDflt_Start ));
}
}//END OF if ( nDM_Therapy=FALSE)
}//END OF if( SetCampaignInt(sDM_Name,"Gear_updtd")==FALSE )
//------------------------------------------------------------------------------
// if update TRUE DONT update this is dependant on data base
if( GetCampaignInt(sDM_Name,"Gear_updtd",oTarget)==1 )
{
//jump to save loc if valid else jump to default start
if (GetIsLocationValid(lSave_Loc)==TRUE)
{
// flag player updated here:
SetCampaignInt(sDM_Name,"Gear_updtd",1,oTarget);
// jump to save_lov
//AssignCommand(oTarget,ClearAllActions(TRUE));
AssignCommand(oTarget,JumpToLocation( lSave_Loc ));
}
else
{
// flag player updated here:
SetCampaignInt(sDM_Name,"Gear_updtd",1,oTarget);
// jump to default start
//AssignCommand(oTarget,ClearAllActions(TRUE));
AssignCommand(oTarget,ActionJumpToObject( oDflt_Start ));
}
}//END if( SetCampaignInt(sDM_Name,"Gear_updtd")==TRUE )
//---!!!!!!!!!!--
// destroy items
//
// debug
if( nUPDate_Msgs==TRUE){SendMessageToPC( oTarget,"3)...DESTORYING Updated ITEMS...");}
Destory_Items(oTarget);
if ( nDM_Therapy==FALSE){Destory_InValidItems(oTarget);}
//[END OF SCRIPT//]
}
Forgive me I posted the wrong script, this is the correct script. You can place it on areas/triggers “on enter” event/script. I can also send you a Module as an example if you like.
This script is adjustable use dm_therapy option True/false , show Update messaging
Modifié par Greyfort, 20 juin 2011 - 01:21 .
#50
Posté 20 juin 2011 - 01:45





Retour en haut







