Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Save kits and purchases on MySQL

Comments in 'Plugin Development' started by MyNameIsTriXz, Oct 2, 2016.

  1. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    I know how to save all the kits a player bought. But I wonder how to set the selected kit of a player for each minigame. I mean I need to create 6 columns (for 6 minigames), just for the selected kits... isnt there any othet way to do it? And if its the case, should I save the kits on an own kits table?
  2. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    that's your decision, it's only a question of design. And can't mysql save arrays too?
    applqpak likes this.
  3. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Well idk
  4. Thunder33345
    Offline

    Thunder33345 Notable Member

    Joined:
    Apr 3, 2014
    Posts:
    755
    Minecraft User:
    Thunder33345
    tables(players)
    (key),(kits)
    (name) , (json string array of kits name)
    MyNameIsTriXz likes this.
  5. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Sounds good, better than making a column for each game
  6. Thunder33345
    Offline

    Thunder33345 Notable Member

    Joined:
    Apr 3, 2014
    Posts:
    755
    Minecraft User:
    Thunder33345
    you could try PHP sterilize but i think json is better
  7. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    I would use serialize because it can store objects and other stuff. Json only save strings and arrays, also Json saves everything into stdClass while serialize saves the array.
  8. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    I have found a good way to save it: - with prefix and suffix, I save it like this [TW]EggThrower[TW][OITC]Knockback[OITC].
    To get it I will do explode("[OITC]", $kits);
  9. Thunder33345
    Offline

    Thunder33345 Notable Member

    Joined:
    Apr 3, 2014
    Posts:
    755
    Minecraft User:
    Thunder33345
    you can decode it into a array FYI like
    Code:
     json_decode($json, true) 
  10. Thunder33345
    Offline

    Thunder33345 Notable Member

    Joined:
    Apr 3, 2014
    Posts:
    755
    Minecraft User:
    Thunder33345
    You can store them into a string with
    [Prefix](name). {repeat}
    the dot is use as separator and [Prefix] is used for sorting
    you can sort it by [SW] is inside foreach ranks
    that is if you rather store things in a string

Share This Page

Advertisement