Menu

#283 Player State Saving [HR]

open
nobody
2020-11-21
2020-08-11
Anonymous
No

Originally created by: PatheticMustan
Originally owned by: SwxtchCode

Describe the hack in 5 words or less:
Save player+inventory to LocalStorage

Have you made sure this hack isn't available yet?* (Yes/No)
Yes

Being able to save the player's state and inventory would allow users to undo hacks, and restore their account to it's initial state. It's also relatively easy to implement.

Discussion

1 2 > >> (Page 1 of 2)
  • Anonymous

    Anonymous - 2020-09-03
     
  • Anonymous

    Anonymous - 2020-09-03
     
  • Anonymous

    Anonymous - 2020-09-29
     
  • Anonymous

    Anonymous - 2020-10-03

    Originally posted by: PatheticMustan

    whatever

     
  • Anonymous

    Anonymous - 2020-10-22

    Originally posted by: SwxtchCode

    var playerStates = [];

    then save with

    saveState = (state) => {
      playerStates.push(state);
    }
    

    input into saveState's state param is _.player.data

    ik this is pretty basic, i don't have access to my laptop RN tho so I cant do much

     
  • Anonymous

    Anonymous - 2020-10-22

    Originally posted by: PatheticMustan

    the idea is to load/save into and from localStorage.

    We'd also need to get some things outside of _.player.data, but it shouldn't be too hard.

    I'll try doing this over the weekend, haha

     
  • Anonymous

    Anonymous - 2020-10-22
     
  • Anonymous

    Anonymous - 2020-10-22

    Originally posted by: SwxtchCode

    Hmm ok-

    localStorage.setItem(JSON.Stringify(playerState))

     
  • Anonymous

    Anonymous - 2020-10-22

    Originally posted by: ArcerionDev

    unfortunately, the only things that are saved globally are things under _.player, everything else doesn't work. Also, JSON.stringify isn't necessary, since a lot of the game data is circular. Just do

    localStorage.state = _
    

    then when we load in the hacked gamemin, do something like

    _ = localStorage.state
    

    Just a thought.

     
  • Anonymous

    Anonymous - 2020-10-22

    Originally posted by: PatheticMustan

    Arc, that's horrible... you should use localStorage.setItem

     
  • Anonymous

    Anonymous - 2020-10-22

    Originally posted by: ArcerionDev

    it doesn't matter tbh

     
  • Anonymous

    Anonymous - 2020-10-22

    Originally posted by: ArcerionDev

    Look,

    localStorage.setItem('owo','uwu')
    

    is 33 chars long,

    localStorage.owo = 'uwu'
    

    is 24.

    May I ask

     
  • Anonymous

    Anonymous - 2020-10-22

    Originally posted by: SwxtchCode

    Alr, I'm on my Linux machine now (my laptop is still broken).

    I'm going to work on this for a bit, gimme some time.

     
  • Anonymous

    Anonymous - 2020-10-22

    Originally posted by: SwxtchCode

    saveState = (state) => {
      playerStateHistory = JSON.parse(localStorage.getItem("playerStateHistory")) || [];
    
      if(typeof state == "object") {
          playerStateHistory.push(state);
          localStorage.setItem('playerStateHistory', JSON.stringify(state));
      } else {
        throw new TypeError(`Invalid state data. Expected object, got ${typeof state}.`);
      }
    }
    

    We'll need to add something to prevent Prodigy from screwing it up and wiping the player, of course.

     
  • Anonymous

    Anonymous - 2020-10-22

    Originally posted by: SwxtchCode

    Also, this should totally be a part of [#318] in my opinion (or is it there and I didn't realize it?), because this will be another WCM thing.

     
  • Anonymous

    Anonymous - 2020-10-22

    Originally posted by: ArcerionDev

    dont wanna be technical but do

    Expected object, got ${typeof state}.
    

    Instead of

    Expected object, got ${state}.
    

    lmao

     
  • Anonymous

    Anonymous - 2020-10-22

    Originally posted by: SwxtchCode

    Lmao- thanks. Updated.

     
  • Anonymous

    Anonymous - 2020-10-23

    Originally posted by: SwxtchCode

    K, so, there might be stuff we don't want to save (temporary values or something), I'll look into that soon.

     
  • Anonymous

    Anonymous - 2020-10-23

    Originally posted by: SwxtchCode

    Another thing:

    We'll either have to save this in the extension or add some kind of verification hash (explained how to do that in DMs with Arc) to prevent Prodigy from tampering with local storage, 'cause they can easily add some JS to overwrite the value.

     
  • Anonymous

    Anonymous - 2020-10-23
     
  • Anonymous

    Anonymous - 2020-10-27

    Originally posted by: SwxtchCode

    commenting to remind people to help

     
  • Anonymous

    Anonymous - 2020-10-27

    Originally posted by: PatheticMustan

    I promise I'll try doing it today.
    While we wait, a list of what to save would be nice.

    • Player data
    • player backpack
    • player name
    • kennel
    • quest progression
     
  • Anonymous

    Anonymous - 2020-10-27

    Originally posted by: ArcerionDev

    • Player data
    • player backpack
    • player name
    • kennel
    • quest progression
     
  • Anonymous

    Anonymous - 2020-10-27

    Originally posted by: ArcerionDev

    this is what we have done for now

     
  • Anonymous

    Anonymous - 2020-10-27

    Originally posted by: ArcerionDev

    these things all SHOULD save, but sometimes they don't, idk why

     
1 2 > >> (Page 1 of 2)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.