Storing string information on PC (PERMANENT)
#1
Posté 24 janvier 2014 - 12:32
I have got a small question. I would like to store some string information on PC character. I know i can use:
SetLocalString(oPC,
sTag, sInformation); Does those variables disapear after restart of
the serwer? Is there any other option to store information on PC? I
heard that it can by saved on Hide (INVENTORY_SLOT_CARMOUR) Is it true?
How it can be done?
#2
Posté 24 janvier 2014 - 05:41
You can, however, place variables onto inventory items and those will persist after a restart (including your creature armor suggestion, but it also applies to all items in inventory - weapons, tokens, torches, etc...).
So, an easy option for you would to be to create an inventory item, such as a "Player Token" (name it something relevant to your module) and give it to all new players (make the item plot, stolen, and undroppable to prevent your players from losing it). I prefer this option over the idea of the creature armor slot, as there may be times when that creature hide gets displaced, whereas an inventory item that is small and weightless is almost inconsequential, can be named something relevant to the story of your module, and wouldn't need to be touched.
However you proceed, you can store strings, ints, floats, etc.. onto inventory items. So, when you need to apply or retrieve persistent information to/from a player, you just reference that item rather than the PC.
Saving data is as simple as using the SetLocalString function onto the item. Retrieving data uses GetLocalString function. Instead of setting it on the PC, you set and retreive it from the inventory item.
For example:
Set the string
object oPC = GetPCSpeaker();
object oDatabase = GetItemPossessedBy(oPC, "database");
string sName = GetName(oPC);
SetLocalString(oDatabase, "Name", sName);
Retrieve the string:
object oPC = GetPCSpeaker();
object oDatabase = GetItemPossessedBy(oPC, "database");
string sName = GetLocalString(oDabatase, "Name");
Hope that helps.
Modifié par BelowTheBelt, 24 janvier 2014 - 05:41 .
#3
Posté 24 janvier 2014 - 09:29
If you're a novice scripter, BtB's suggested approach is probably the best (though I didn't check his code, just his suggestion). There are a few problems with undroppable items (they can, for example, often be forced out of inventory by clever players), but by and large this solution works.
Funky
#4
Posté 25 janvier 2014 - 04:14
I wrote as you said, using hide:
To save data,
object oPC = GetItemActivator();
object oHide = GetItemInSlot(INVENTORY_SLOT_CARMOUR,oPC);
string sTag = "TAG";
string sString = "abc";
SetLocalString(oHide, sTag, sString);
To get data
object oPC = GetItemActivator();
object oHide = GetItemInSlot(INVENTORY_SLOT_CARMOUR,oPC);
string sTag = GetLocalString(oHide, "TAG");
And it works. But when I save and export the character, exit the game and create a new game (using saved character) it does not work. (I tried also using INVENTORY_SLOT_NECK, and the result was the same.)
What am I doing wrong?
#5
Posté 25 janvier 2014 - 06:48
Thamiar wrote...
Thank you very much!
I wrote as you said, using hide:
To save data,
object oPC = GetItemActivator();
object oHide = GetItemInSlot(INVENTORY_SLOT_CARMOUR,oPC);
string sTag = "TAG";
string sString = "abc";
SetLocalString(oHide, sTag, sString);
To get data
object oPC = GetItemActivator();
object oHide = GetItemInSlot(INVENTORY_SLOT_CARMOUR,oPC);
string sTag = GetLocalString(oHide, "TAG");
And it works. But when I save and export the character, exit the game and create a new game (using saved character) it does not work. (I tried also using INVENTORY_SLOT_NECK, and the result was the same.)
What am I doing wrong?
I think 1.69 introduced the player's hide to change to PC Properties for the sake of the horses. So if this other module you're loading and importing your character into still has this feature in the scripts, the hide on your imported character is being replaced by PC Properties, which would not have the variable stored on it from your other module.
FP!
#6
Posté 25 janvier 2014 - 07:10
Fester Pot wrote...
Thamiar wrote...
Thank you very much!
I wrote as you said, using hide:
To save data,
object oPC = GetItemActivator();
object oHide = GetItemInSlot(INVENTORY_SLOT_CARMOUR,oPC);
string sTag = "TAG";
string sString = "abc";
SetLocalString(oHide, sTag, sString);
To get data
object oPC = GetItemActivator();
object oHide = GetItemInSlot(INVENTORY_SLOT_CARMOUR,oPC);
string sTag = GetLocalString(oHide, "TAG");
And it works. But when I save and export the character, exit the game and create a new game (using saved character) it does not work. (I tried also using INVENTORY_SLOT_NECK, and the result was the same.)
What am I doing wrong?
I think 1.69 introduced the player's hide to change to PC Properties for the sake of the horses. So if this other module you're loading and importing your character into still has this feature in the scripts, the hide on your imported character is being replaced by PC Properties, which would not have the variable stored on it from your other module.
FP!
You need to use characters stored in an actual server vault and launch your games as if launching a server as well. Information stored on items does not transfer with local vault saves.
#7
Posté 28 janvier 2014 - 07:09
It works now
#8
Posté 08 février 2014 - 07:28
==============================================
// gen_skin_inc
//////////////////////////////////////////////////
// Created By: Genisys / Guile
// Created On: 2/06/2014
////////////////////////////////////////////////////////////////////////////////
/*
This will handle ALL PC Skin Functions & Persistent Variable Storage...
This is a very simplified script include! (Tested Thoroughly!)
*/
////////////////////////////////////////////////////////////////////////////////
// Required Includes
// (NONE & Don't Add Any!)
////////////////////////////////////////////////////////////////////////////////
// Declare All Prototypes...
// Returns the Bioware PC Skin (if one doesn't exist, it creates it)
object GetSkin(object oPC);
// Returns an Int Set on the PC Skin by the variable name sVar
int GetSkinInt(object oPC, string sVar);
// Returns an Int Set on the PC Skin by the variable name sVar
float GetSkinFloat(object oPC, string sVar);
// Returns a String Set on the PC Skin by the variable name sVar
string GetSkinString(object oPC, string sVar);
// Returns an Object Set on the PC Skin by the variable name sVar
object GetSkinObject(object oPC, string sVar);
// Returns a Location Set on the PC Skin by the variable name sVar
location GetSkinLocation(object oPC, string sVar);
void DeleteSkinInt(object oPC, string sVar);
void DeleteSkinFloat(object oPC, string sVar);
void DeleteSkinString(object oPC, string sVar);
void DeleteSkinObject(object oPC, string sVar);
void DeleteSkinLocation(object oPC, string sVar);
void SetSkinInt(object oPC, string sVar, int nInt);
void SetSkinFloat(object oPC, string sVar, float fFloat);
void SetSkinString(object oPC, string sVar, string sString);
void SetSkinObject(object oPC, string sVar, object oObject);
void SetSkinLocation(object oPC, string sVar, location lLoc);
////////////////////////////////////////////////////////////////////////////////
//Define all prototypes...
//-------------------------------------------------------------------------
object GetSkin(object oPC){
object oSkin = GetItemInSlot(INVENTORY_SLOT_CARMOUR, oPC);
if(oSkin == OBJECT_INVALID) { oSkin = CreateItemOnObject("x3_it_pchide", oPC);
AssignCommand(oPC, ActionEquipItem(oSkin, INVENTORY_SLOT_CARMOUR)); }
return oSkin;}
//-------------------------------------------------------------------------
int GetSkinInt(object oPC, string sVar){
object oSkin = GetSkin(oPC); return GetLocalInt(oSkin, sVar);}
//-------------------------------------------------------------------------
float GetSkinFloat(object oPC, string sVar){
object oSkin = GetSkin(oPC); return GetLocalFloat(oSkin, sVar);}
//-------------------------------------------------------------------------
string GetSkinString(object oPC, string sVar){
object oSkin = GetSkin(oPC); return GetLocalString(oSkin, sVar);}
//-------------------------------------------------------------------------
object GetSkinObject(object oPC, string sVar){
object oSkin = GetSkin(oPC); return GetLocalObject(oSkin, sVar);}
//-------------------------------------------------------------------------
location GetSkinLocation(object oPC, string sVar){
object oSkin = GetSkin(oPC); return GetLocalLocation(oSkin, sVar);}
//-------------------------------------------------------------------------
void DeleteSkinInt(object oPC, string sVar){
object oSkin = GetSkin(oPC); DeleteLocalInt(oSkin, sVar);}
//-------------------------------------------------------------------------
void DeleteSkinFloat(object oPC, string sVar){
object oSkin = GetSkin(oPC); DeleteLocalFloat(oSkin, sVar);}
//-------------------------------------------------------------------------
void DeleteSkinString(object oPC, string sVar){
object oSkin = GetSkin(oPC); DeleteLocalString(oSkin, sVar);}
//-------------------------------------------------------------------------
void DeleteSkinObject(object oPC, string sVar){
object oSkin = GetSkin(oPC); DeleteLocalObject(oSkin, sVar);}
//-------------------------------------------------------------------------
void DeleteSkinLocation(object oPC, string sVar){
object oSkin = GetSkin(oPC); DeleteLocalLocation(oSkin, sVar);}
//-------------------------------------------------------------------------
void SetSkinInt(object oPC, string sVar, int nInt){
object oSkin = GetSkin(oPC);
DeleteSkinInt(oPC, sVar); // Prevent Bloat!
SetLocalInt(oSkin, sVar, nInt);}
//-------------------------------------------------------------------------
void SetSkinFloat(object oPC, string sVar, float fFloat){
object oSkin = GetSkin(oPC);
DeleteSkinFloat(oPC, sVar); // Prevent Bloat!
SetLocalFloat(oSkin, sVar, fFloat);}
//-------------------------------------------------------------------------
void SetSkinString(object oPC, string sVar, string sString){
object oSkin = GetSkin(oPC);
DeleteSkinString(oPC, sVar); // Prevent Bloat!
SetLocalString(oSkin, sVar, sString);}
//-------------------------------------------------------------------------
void SetSkinObject(object oPC, string sVar, object oObject){
object oSkin = GetSkin(oPC);
DeleteSkinObject(oPC, sVar); // Prevent Bloat!
SetLocalObject(oSkin, sVar, oObject);}
//-------------------------------------------------------------------------
void SetSkinLocation(object oPC, string sVar, location lLoc){
object oSkin = GetSkin(oPC);
DeleteSkinLocation(oPC, sVar); // Prevent Bloat!
SetLocalLocation(oSkin, sVar, lLoc);}
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// End Include...
//-------------------------------------------------------------------------
Modifié par _Guile, 08 février 2014 - 10:56 .
#9
Posté 08 février 2014 - 10:48
Modifié par MrZork, 08 février 2014 - 10:50 .





Retour en haut






