playMaker

Author Topic: player pref has key - weird behavior  (Read 2094 times)

elusiven

  • Full Member
  • ***
  • Posts: 233
  • Debt we all must pay...
player pref has key - weird behavior
« on: June 12, 2017, 10:44:31 AM »
Hi there

I'm getting a very weird behavior on player pref has key and get int.

Basically, even though the has key should be false, it's always true even if the key shows blank....

And get int always returns 1 when the key is blank...



http://imgur.com/WtjG70c

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: player pref has key - weird behavior
« Reply #1 on: June 12, 2017, 11:13:45 AM »
Hi,
Are you sure the variable is empty?

I just tested a bit and if the variable has a space (" " space still looks empty but it is registered) it will set a key and also find the key.

But if there is no space then it will not register a key and also will find a key.

elusiven

  • Full Member
  • ***
  • Posts: 233
  • Debt we all must pay...
Re: player pref has key - weird behavior
« Reply #2 on: June 12, 2017, 07:30:17 PM »
the variable is taken out from xml, it has no space in actual XML file. just empty attribute

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: player pref has key - weird behavior
« Reply #3 on: June 12, 2017, 10:46:32 PM »
Can you try a "string Length" after you got it from the xml?
the result should be 0

elusiven

  • Full Member
  • ***
  • Posts: 233
  • Debt we all must pay...
Re: player pref has key - weird behavior
« Reply #4 on: June 13, 2017, 04:51:25 AM »
Sure,

Bundle ID variable is empty and string length is 0.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: player pref has key - weird behavior
« Reply #5 on: June 13, 2017, 05:05:11 AM »
Strange, i can't seem to repo this.

Did you try to clear all playerprefs data with "playerprefs Delete All"

You could use the string length and a int compare as a work around for now.
so that if the length is 0 do the same as the key 'false' event.

Maybe you can send a bug report (you can find it under Playmaker/Tools)

elusiven

  • Full Member
  • ***
  • Posts: 233
  • Debt we all must pay...
Re: player pref has key - weird behavior
« Reply #6 on: June 13, 2017, 05:30:35 AM »
After cleaning the prefs, they all stay locked, however as soon as I purchase a bundle that unlocks two categories it goes crazy again. It seems like a dirty workaround I might look into creating an action for this and see if it makes a difference.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: player pref has key - weird behavior
« Reply #7 on: June 13, 2017, 11:45:12 AM »
hmm tbh i would not use playerprefs at all for this delicate info.

playerprefs is very easy to hack and is only good to save settings (preferences)

i use easy save from moodkie on all my games, it has a very complete pm actions and encryption.