Help needed for making personal database table for each playerID

buildbuild Member, PRO Posts: 45

I'm trying to create a character creation process which will create a personal table for each players unique playerID.

Let say that you want to play the game.

  • You need to create a character with a chosen name and a given playerID.
  • Your name and playerID will then be stored onto a database table.
    (Now here is where i desperately need help.)

  • After the player have gotten his/her player name and playerID stored in the database table. I want to create a new personal table for each playerID in the original database table.

How can i do this? Can it be done or not? Please help me, i have been stuck with this issue for days.

NOTE: Im kinda noob with both coding and english. bare with me.

Comments

  • NNterprisesNNterprises Member, PRO Posts: 387

    SO just when you say "database" does that mean in-game database that will be used with anyone who plays on that device or online database that can be used/viewed with anyone around the world?

  • buildbuild Member, PRO Posts: 45

    i mean an online database server

  • buildbuild Member, PRO Posts: 45

    Yes i have seen that. But It cant really be done properly with mySQL. So i am using a noSQL database "DynamoDB".

    I'm gonna start over..

    lets say a new character starts the game on an island, with just a homebase and a bit of gold. And here you will be given a completely empty personal database for the placement data of all your future buildings.
    When you place a new building at a certain location X,Y on the map/scene, That buildings' coordinates and object index number will then be saved to that personal table owned by that players unique player ID.

    Then the map could be visited by other online players. And all of the map's object data, ( X,Y and index number), would then be retrieved from that visited players unique table. That could be found through the players unique player ID

    TLDR; I want to somehow use the "One-to-many" table method, to make a personal table for each unique player ID.

    Im just asking if its possible.
    Or should i just create a massive second table that held every unique players placement data?

  • MantoManto Member Posts: 796

    Ok, now I understand better what you're asking.

    Based on the database course I've taken, I wouldn't make a table for each user. I would say make a table for users and another for buildings.

    Users table contains playerID, player name, amount of gold, etc.

    Buildings table contains playerID, building type, x and y.

    Here's a couple of example cases with this database structure:
    When new player joins a row is added to the users table containing the new playerID. When user places a new building, a row is added to the buildings table also with the player's ID. When a player's base is viewed by the player or others, all buildings with the player's ID are retrieved from the database.

    What I don't understand is that why couldn't you do this in MySQL? I could help you with MySQL, but I haven't used DynamoDB.

  • buildbuild Member, PRO Posts: 45
    edited August 2016

    @Manto said:
    When a player's base is viewed by the player or others, all buildings with the player's ID are retrieved from the database.
    I could help you with MySQL, but I haven't used DynamoDB.

    I installed MAMP and i think i have set up the .php template file correctly.

    I typed in following (pictures in the link below):
    link1: https://gyazo.com/9a33d36b7d1394a9d892fda4db657f34
    link2: https://gyazo.com/508126e4281f9b5a5fac0862aa89a081

    So now i create a new database in my local mysql, named "test". Then i create 2 new tables called "playerTable" and "buildingTable".

    Table 1 is the regular style player table with: (ID, Name, Score, Level, valuta, etc).

    Here's where i cant go further. I create another table with: (ID, color, x, y, type, direction).
    But i dont know how to retrieve and spawn the ID specific building data.

    NOTE: I dont know how to implement a second database and tables into the .php file.

  • MantoManto Member Posts: 796

    @build said:

    @Manto said:
    When a player's base is viewed by the player or others, all buildings with the player's ID are retrieved from the database.
    I could help you with MySQL, but I haven't used DynamoDB.

    I installed MAMP and i think i have set up the .php template file correctly.

    I typed in following (pictures in the link below):
    link1: https://gyazo.com/9a33d36b7d1394a9d892fda4db657f34
    link2: https://gyazo.com/508126e4281f9b5a5fac0862aa89a081

    So now i create a new database in my local mysql, named "test". Then i create 2 new tables called "playerTable" and "buildingTable".

    Table 1 is the regular style player table with: (ID, Name, Score, Level, valuta, etc).

    Here's where i cant go further. I create another table with: (ID, color, x, y, type, direction).
    But i dont know how to retrieve and spawn the ID specific building data.

    NOTE: I dont know how to implement a second database and tables into the .php file.

    I think you should create a php file for each action, e.g. create new player, add new building, and retrieve buildings.

    Have you created the tables using phpmyadmin?

    The sql query for getting the buildings for one player goes somewhat like this: "SELECT * FROM buildingTable WHERE ID=playerId". You can see an example of how the data is changed to json in the php file from the tutorial.

  • buildbuild Member, PRO Posts: 45

    @Manto said:

    I think you should create a php file for each action, e.g. create new player, add new building, and retrieve buildings.

    I dont know how to correctly setup multiples databases, tables and table collumns, into a .php script. Could you maybe explain where and how to add the different names?

    Have you created the tables using phpmyadmin?

    Yes i have.

    The sql query for getting the buildings for one player goes somewhat like this: "SELECT * FROM buildingTable WHERE ID=playerId". You can see an example of how the data is changed to json in the php file from the tutorial.

    I will look into this.

    Btw, another question: Do you know why my actor spawns a white rectangle on top of itself, when i add a custom .json collision shape file?

  • NNterprisesNNterprises Member, PRO Posts: 387

    Sometimes the json collision messes with the actor... idk why or how but it does.
    In one of my games, I made a T shape in the collision editor and instead of moving, resizing, and everything and it just pops up large, doesn't moved, stretched out...
    I had to break up my actor into like 3 actors with custom rectangle/oval-like shapes...

    Yea idk

  • MantoManto Member Posts: 796

    @build
    Here's a short demo of retrieving buildings for players in GS based on the method I talked about in previous comments. Using XAMPP for PHP and MySQL.

Sign In or Register to comment.