Aller au contenu

Photo

Database on an item?


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

#26
Who said that I

Who said that I
  • Members
  • 492 messages

FunkySwerve wrote...

The solution I described above will store anything you want it to. The ONLY difficulty is making sure that the player has an undroppable 'storage' item, which you can accomplish with a few lines of code when they enter the server. You then set and get all variables relating to that player on that item. Here's the code for entering the server. All of my code will assume the resref and tag of the undroppable storage item you'll need to make are 'pc_storage'.


object oPC = GetEnteringObject();
object oStorage = GetItemPossessedBy(oPC, "pc_storage");
if (!GetIsObjectValid(oStorage)) {
    oStorage = CreateItemOnObject("pc_storage", oPC);
    SetItemCursedFlag(oStorage, TRUE);
}

Then, whenever you would set or get a variable on the pc, instead get the storage item and set it on that instead, using GetItemPossessedBy(oPC, "pc_storage");  As mentioned, you'll want to ExportSingleCharacter(oPC); after you do this.

So, instead of:
SetLocalInt(oPC, "SomeVarName", 3);

you would do:

object oStorage = GetItemPossessedBy(oPC, "pc_storage");
SetLocalInt(oStorage, "SomeVarName", 3);

This is no where near as difficult as you seem to think it should be. :P

Funky



Okay got it to compile, What I did, there was already onentering oPC line so I simply added the rest under it ^^ 

So now its compiled and stuff I won't have to do anything else right?
(sometimes takes a while till my little brain understands it)

#27
Who said that I

Who said that I
  • Members
  • 492 messages
okay works like a little fire on new years eve!



awesome guys thank you so much!

#28
Knight_Shield

Knight_Shield
  • Members
  • 444 messages
Hmm I dont like to butt in but if you store local HP on the dmfi dice bag will this work too if char is dead or do I still need the death token script?


void main()
{
object oPC = GetExitingObject();
object oStorage = GetItemPossessedBy(oPC, "dmfi_dicebag");
SetLocalInt(oStorage, "CurrentHitPoints", 3);
ExportSingleCharacter(oPC);
  }

I put that in my onclientexit and it didnt work ...is there a script I need to put in the onclient enter to recall the HP?

EDIT: I found these a they work nicely     http://nwn.bioware.c...625285&forum=47

Modifié par Knight_Shield, 22 décembre 2010 - 11:18 .