1. This forum is ARCHIVED! Visit the new Cloud Sixteen forums, codename Eden, at https://eden.cloudsixteen.com. These forums will remain archived for a few months before being closed down, so try to encourage plugin developers to begin moving their content across to the new forums.
Dismiss Notice
Hi Guest, you need a Steam account to register and post on these forums. Login with Steam at the top of the forums to get started!
Dismiss Notice
Hi Guest, do you want to buy HL2RP or another Clockwork schema? Visit the Cloud Sixteen Store to get started!

Difference between Set/GetSharedVar and Set/GetCharacterData

Discussion in 'Development' started by Crater, Nov 25, 2014.

  1. Crater

    Crater Hostell Roleplay

    Title says it all. I asked Arbiter on Steam and got most of what I'm looking for - that SetCharacterData sends information to MySQL and that he believes SetSharedVar is temporary storage - but I'm still a bit confused as I've seen it used in several different ways.

    [member=5482]duck[/member] uses both in his aging plugin to save the same(?) age value to both SharedVar and CharacterData

    [member=5522]Atebite[/member] uses both in his disease framework to store the disease table, but the SharedVar's value is actually set to a GetCharacterData.

    The names of the functions are fairly self explanatory, but from what I've observed from poking around in the libraries and framework they have similar functions. I also have a basic understanding of how both functions work, and that they're used to easily request data from pretty much anywhere. I'm just confused on what exactly is so different about the two, and how/when they're stored.
     
  2. NightAngel

    NightAngel Fuck off Lev

    You can't get character data client side, so while it is temporary, as the name implies, it's shared. So you can have the same values be networked for client and server with SharedVars.
     
  3. Crater

    Crater Hostell Roleplay

    Excellent, thanks.
     
  4. duck

    duck Phant0m Legend

    You can actually get the client's character data, provided the data was added using Clockwork.player:AddCharacterData. Setting the character data on the server will additionally set the character data on the client, and also set it as a shared var.

    Example
    Code:
    Clockwork.player:AddCharacterData("PhysDesc", NWTYPE_STRING, "");
    I actually forgot that function even existed.
     
  5. Crater

    Crater Hostell Roleplay

    Considering it requires the specific data type (NWTYPE_), would there be any way to store a table using that function or can it only store strings (and the other datatypes, of course)?

    e.g. if I wanted to use that function in place of player:SetCharacterData("test", testTable)
     
  6. duck

    duck Phant0m Legend

    Unfortunately, no. I briefly talked to kurozael about that, though. It's not hard to network tables, but I'm trying to think of the best way to make it integrate easily with the shared vars system.

    What you can do for now is use Clockwork.kernel:Serialize on the table and then use Clockwork.kernel:Deserialize on a string. Serialize transforms a table into a string, and Deserialize does the opposite. In a future update, maybe it will automatically detect if what you entered is a table, and then perform the serialization for you.

    EDIT: Or maybe another parameter would be added to the function so it would know you wanted it to do the serialization stuff.
     

Previous Readers (Total: 0)