Naviehs

Member
I wanted to add a few simple bools to playermobile.cs but now its deleting playermobiles on restart. Im guessing I need to modify serialize/deserialize, anyone can explain me like Im 5 or has a tutorial on how to do so? Thank you!
 
 
Serialize...

writer.Write(34); // change the version number by increasing it by 1. If it was 33, for example, change it to 34.

writer.Write(myBoolVariableOne);
writer.Write(myBoolVariableTwo);

writer.Write...// all of the other stuff that was here before...


Deserialize...

int version = reader.ReadInt(); // this will read 33 when you first load the server, but later after you save, it will read 34 because that is what you saved

switch( version )
{
case 34: // this is your new case
{
myBoolVariableOne = reader.ReadBool();
myBoolVariableTwo = reader.ReadBool();
goto case 33; // make sure you send it to the next (previously saved) case below
}
case 33:
...
}
 
Very well explained!

About the "writer.Write(34); "
do I need to increase it by one for every bool/int I add?
 
I believe I did everything like you said.. Not sure why Im still getting the error (I even tried with the brackets)
 

Attachments

  • playermobileerror.png
    playermobileerror.png
    97.5 KB · Views: 10
OK. So, can you show me what the Serialize and Deserialize methods looked like before you tried to make any changes?
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back