hello my friends,
i am now working on fps multiplayer game with my team,
i am already did the login and registration system and the connection to database was successful ,
the problem is every player has inventory in c# which contain his items id and this list should be sent to the
database in the items table, and when the player logon the items id must be loaded to the again.
and if there is another way to store the player items id and load it again pls tell me,
sorry for my weak language
thanks in advance
Put a row in the table for every item that every player owns. Basically use a foreach statement to loop over your list and insert each item (although if you’re sending to a PHP script first then you should put the foreach loop in your PHP code and use JSON or XML to transmit the whole list to the PHP script).
thanks jamster,
what i did >>> create list in the inventory.c# which collect the items and it will store the items id when the player exit the game …i converted the list to string with “,” after every id and its easy to send string to the database.
then when the player login again it will search for the items id on the player row then send it to inventory wich will convert it again to list <<< so it is done.
if you dont mind i have another question …
how to find a texture by name ? even if it is in asset folder or it is assigned on gameobject in a list ? which easy and how ?
resources.load(doesnt work).
Resources.Load will work (afaik), I’m fairly sure I’ve used it for textures
The other options you have are an asset bundle or assigning references to them in your script and iterating over them until you find the correctly named Texture
Are you having each client connect to the Database? If so you really don’t want to do that. It should all go through a Central Server that you control and have the server connect to the Database.
jamster, thanks again for your help and you are right i made it. MMOlnteractive Rep , actually i have now each client connected to the database and i am almost done. so what is the deference between connecting directly to the database or over the central server (same result i think)?
lol The Database is very sensitive Information… Players can hack the client and alter their inventory, cheat, or worse wipe the database all together. You NEVER want to put sensitive information like that on the Client. Always run it through a central Server you control. Basically the Client should ONLY be a window into the Game World. All of the important calculations, AI, ect. should all be on the server. Basically if a player can hack it to give him self a unfair advantage it should be controlled by the Server. How things are displayed can be on the client.