Jump to content

Archived

This topic is now archived and is closed to further replies.

Monkuar

Temporary Storage for RPG Items

Recommended Posts

My users table on my forum is what gets checked everytime a user refreshes to authentic them. 

 

When killing a monster, I want users to be able to grab items and it will insert them into their inventory. I have this part done already. But I want them to have a plethora of loot available that drops from a mob, and once they click the specific item it will then be inserted into their inventory (server database).

 

I'm storing the Temporary Item Data in a PHP session variable. Once they kill a monster, the Tempory Item Data variable get's filled with the specific loot and then the user will have the option to choose what items they want to go into their inventory.

 

My problem is, if they open the game in a new browser they will get a new session id. Since I'm authenticating them through my users table, can I just make a new column called session_id and just use php's session_id() before every session start so no matter which browser they're on they will have the same session right? 

 

You might think, well why dont you just store the temporary item data in a mysql field or rows instead? I want to try to minimize mysql usage as much as possible, as players will be CLICKING a lot to kill mobs, it is most likely very mysql demanding as well and I want to be intuitive about it. I just want to use temporary session data for the loot. Then once the user clicks an item they want, it is EXTRACTED from their tempory item data variable, then I will use MYSQL to insert those items into their inventory. 

 

Is this a fair and intuitive way to do temporary data for item loot? For example, in action RPG's like Path of Exile you kill a group of mobs and you see a shit ton of loot on the floor. (I imagine that loot is just temporary waiting for someone to pick it up right?) Once you do pick it up, mysql is then called to save it right? That's the same logic I have with my web based game. Is using a session variable to store that temporay loot.

 

Is this an intuitive way to do this, or are there other ways?

Share this post


Link to post
Share on other sites

Sessions are coupled to cookies. Cookies are coupled to browsers. Browsers do not share cookies, so a different browser means the user will have to authenticate again.

 

If your concern is load on the database, this is not the solution.

Share this post


Link to post
Share on other sites

Sessions are coupled to cookies. Cookies are coupled to browsers. Browsers do not share cookies, so a different browser means the user will have to authenticate again.

 

If your concern is load on the database, this is not the solution.

 

Yeah, that's how it works. The system checks the users cookie to validate it against the users table to authenticate them.

 

But my question is for loot management. I need to store a huge amount of loot that drops from monsters. Using a php session temporary variable would work, but I need it to NOT change when someone logs in on a different browser. That's why I need to use session_id('sessionidhere') before every session_start right? (user is still authenticated ofc but I do not want to store the temporary data in a mysql column, maybe I should?) 

Share this post


Link to post
Share on other sites

Yes, it is better to store it in a database then simply relying on the fact whether or not the session ID still exists.

 

Which you will have to store in the database anyhow, if you would want to re-use it on re-authentication.

 

Also storing it into a database allows for multiplayer shared loot and making sure the same drop item is not taken more then once.

Share this post


Link to post
Share on other sites

Yes, it is better to store it in a database then simply relying on the fact whether or not the session ID still exists.

 

Which you will have to store in the database anyhow, if you would want to re-use it on re-authentication.

 

Also storing it into a database allows for multiplayer shared loot and making sure the same drop item is not taken more then once.

 

Never thought about the multiplayer shared loot option. I'm not at the multiplayer stage yet though. I do want to add PvP, but I am not using socket.io, so it's mostly real time turn based via AJAX requests.

 

I guess I could store the item data in Json format in a field called "tempdatastorage" in my characters table, and just use that. One extra UPDATE query per mob kill might hinder performance though, but we'll see. Thanks for the tips.

Share this post


Link to post
Share on other sites

It's a game played in a browser online. It is possible for 2 people to be at the same place at the same time thus they both could attack the same monster thus the loot dropped should not be awarded 2 times.

 

It's a multiplayer PvE, adding PvP is merely allowing one to also attack other players.

Share this post


Link to post
Share on other sites

It's a game played in a browser online. It is possible for 2 people to be at the same place at the same time thus they both could attack the same monster thus the loot dropped should not be awarded 2 times.

 

It's a multiplayer PvE, adding PvP is merely allowing one to also attack other players.

 

I moved to socket.io for my attack monster system. Problem is I do not like how the serverside scripting language has to be written in javascript. Do you know any PHP modules that are available so we can use PHP as a WebSocket backend instead? I really dislike this javascript stuff, plus I would have to convert my whole attackmob.php file as well into javascript. No thanks.

Share this post


Link to post
Share on other sites

 

Thanks, I bookmarked this.

 

I switched away from socket.io as I believe my attack system will be more based upon just turn based activities. I really want to incorporate attack speed, but have no idea how with socket.io or PHP. I have a feeling it would be easier with socket.io, but that thing loops the mysql database intensively too. (I'm sure I'll use socket.io for a chat system, but nothing more). 

 

Here is an example of my game with the loot animation / explosion: I made design edits to the left toolbar and top, disregard those for now :)

 

Edit: I'll be pushing those temporary items into a temp variable session as well, so there is TONS of loot for the user to choose from. Similar to path of exile or Diablo 2, when you're killing a pack of mobs.

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.