greetings all, first post in a looong time.
I have a question I am hoping someone with better knowledge can help me with.
first a quick explanation what I am doing and what i have done so far.
this is for a multiplayer mod that I will be ONLY using with about 6-7 people tops ever...so keep that in mind (:
I am making a special area that is roughly a live monument of the players as they are in game. a wax museum in so many words.
so i have a ground trigger that stores (StoreCampaignObject) the pc that triggered it. and sets them up within a numerical sequential index., first one is (1) , 2nd is (2), so on and so forth.
roughly this:
StoreCampaignObject("DATABSE", "DATABSEARRAY" + IntToString(nIndex), oPC);
then on module load I have it retrieve object, so on...and it all works just like it should more or less.
my question is this, is there anyway to actually OVERWRITE an index with the same PC?
see the reason is if the same PC walks over the trigger more than once it creates a new index and stores them as well.
so if the pc walks over trigger three times, I have three duplicate copies stored in database.
I COULD use a local int stored on a persistant item in inventory to STOP the script after the first time, but I would really like it to continually overwrite the old PC with the newer one everytime they trigger it.
so any thoughts?
could I somehow maybe store the INT given when first triggered to the persistant item and then do a compare statement(wouldnt know how to really) between whats on the item and whats in databse and if they are same overwrite?
or is there a simpler way to do it?
here is the scripts in the entirety.
ON ENTER
[nwscript]
#include "x2_inc_switches"
// Some string constants that could be placed in an include file.
const string HeroDB = "HeroDatabase";
const string HeroDBCount = "HeroCount";
const string HeroDBArray = "HeroArray";
const string HeroDBLocationArray = "HeroLocation";
const string HeroLocalIndex = "HeroDatabaseIndex";
void main()
{
location lLocation;
object oItem = GetEnteringObject();
object oHeroCount = GetObjectByTag("HERO_COUNTS");
// Get the next index.
int nIndex = GetCampaignInt(HeroDB, HeroDBCount) + 1;
// Give this Hero the next index.
SetLocalInt(oHeroCount, HeroLocalIndex, nIndex);
// Save the Hero and its location to the database.
StoreCampaignObject(HeroDB, HeroDBArray + IntToString(nIndex), oItem);
SetCampaignLocation(HeroDB, HeroDBLocationArray + IntToString(nIndex),GetLocation(oItem));
SetCampaignInt(HeroDB, HeroDBCount, nIndex);
}
[/nwscript]
ON USE of placeable object (will eventually edit for on mod load)
[nwscript]
// Some string constants that could be placed in an include file.
const string HeroDB = "HeroDatabase";
const string HeroDBCount = "HeroCount";
const string HeroDBArray = "HeroArray";
const string HeroDBLocationArray = "HeroLocation";
const string HeroLocalIndex = "HeroDatabaseIndex";
void main()
{
object oHero = OBJECT_INVALID;
location lHero;
int nCount = 0; // Count of Heros restored.
int nIndex = GetCampaignInt(HeroDB, HeroDBCount);
// Restore Heros from the database.
while ( nIndex > 0 )
{
// Retrieve the next Hero.
lHero = GetCampaignLocation(HeroDB, HeroDBLocationArray + IntToString(nIndex));
oHero = RetrieveCampaignObject(HeroDB, HeroDBArray + IntToString(nIndex),lHero);
// See if this Hero is valid.
if ( oHero != OBJECT_INVALID )
{
// Count this Hero.
nCount++;
}
// "Next" index.
nIndex--;
}
}
[/nwscript]
sorry for being such a noob and not really explaining myself clearly.
in a nutshell
i want every pc that triggers this event to be stored as campaign-object, BUT if same pc runs over it a second time, the stored object is replaced with the newer one rather then creating a new reference.
I have tried the following with headbanging results..
tried setting up insead of index using PCName and PublicCDkey to make a unique reference, which worked but I wasnt able to do a while loop to get them all, it would always just create the last object stored.
(I am horrible horrible horrible at while loops and such)
also lastly, this script was totally hashed together from these (well the old) forums so I cant take credit for the scripts but I did peice them together and i understand what i did/have done...so I am learning (: