• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
LawedanComputer

Inventory System

9 posts in this topic

Hello,

I find myself trying to script a realistic inventory system, and I am having trouble, so I thought this was the best place to ask for aid. Basically it's a multi-player game, "hardcore Roleplaying" (basically it's actually with a local chat and Roleplaying rules), it's in the modern era, therefore, for example, people can steal a badge from a police officer and use it to fake being a cop, people can craft stuff if they are in the primary sector (agriculture).

Therefore, each item will have different values, as of badges, IDs, vehicle registrations and ownerships, everything may be robbed and everything can be shared.

I have been trying to figure the best way to do this, maybe anyone has something in mind?

Thank you in advance for your unconditional help,

Matthew Striker.
0

Share this post


Link to post
Share on other sites
It helps if you tell us in what language you are working.

But i would simply add and remove the items from a binary file stored on the server to prevent cheating. You just have to serialize the item class and add it to a inventory XML file belonging to the player, once used or dropped remove it.
0

Share this post


Link to post
Share on other sites
It's PAWN for San Andreas Multiplayer, it's kind of like C, but I am experienced on the language and If you guys talk to me in another language like C, C#, C++ I can script it into PAWN. I honestly just need the basics on what variables to use and what functions would be needed, specially in unique items like badges that can be changed (like, my name is deskoft, I can give deskoft's ID to another player, and he can fake being deskoft).
0

Share this post


Link to post
Share on other sites
Well i can help you with writing/reading XML data in C#.

Let's say this is your item class that uses a string for the type of the item and a int for the player ID.

[code]public class TheData
{
public string SomeName;
public int SomeNumber;
}[/code]

Here is a simple class i could serialize this data into xml and load it back in.

[code]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.Serialization;

class Serializer
{
TheData data = new TheData();
public Serializer(string theName, int theNumber)
{
data.SomeName = theName;
data.SomeNumber = theNumber;
}
public void Save(string fileName)
{
Stream stream = File.Create(fileName);
XmlSerializer serialize = new XmlSerializer(typeof(TheData));
serialize.Serialize(stream, data);
stream.Close();
}
public static TheData Load(string fileName)
{
Stream stream = File.OpenRead(fileName);
XmlSerializer serialize = new XmlSerializer(typeof(TheData));
return (TheData)serialize.Deserialize(stream);
}
}[/code]
1

Share this post


Link to post
Share on other sites
[quote name='menyo' timestamp='1329335513' post='4913441']
Well i can help you with writing binary data in C#.

Let's say this is your item class that uses a string for the type of the item and a int for the player ID.

[code]public class TheData
{
public string SomeName;
public int SomeNumber;
}[/code]

Here is a simple class i could serialize this data into xml and load it back in.

[code]class Serializer
{
TheData data = new TheData();
public Serializer(string theName, int theNumber)
{
data.SomeName = theName;
data.SomeNumber = theNumber;
}
public void Save(string fileName)
{
Stream stream = File.Create(fileName);
XmlSerializer serialize = new XmlSerializer(typeof(TheData));
serialize.Serialize(stream, data);
stream.Close();
}
public static TheData Load(string fileName)
{
Stream stream = File.OpenRead(fileName);
XmlSerializer serialize = new XmlSerializer(typeof(TheData));
return (TheData)serialize.Deserialize(stream);
}
}[/code]

Using these .net references in the serialization class.

using System.Xml;
using System.Xml.Serialization;
[/quote]

Thank you very much, I'll give that a try and see how I go.
0

Share this post


Link to post
Share on other sites
With the Load method?

You don't need someones inventory if someone is offline right? If you do want that then the filename should not be thisplayer.xml but otherplayer.xml. You could also make a dictionary that uses userID's that point to filenames or something like that. You could serialize that dictionary too and do something like this:

1. Player wants to do something with another persons inventory:
2. Load inventory dictionary.
3. Lookup that persons ID in the dictionary.
4. Load the inventory attached to this ID.
5. Do something with that inventory.
1

Share this post


Link to post
Share on other sites
That is the problem, we are trying to script exchangable items. Include IDs, maybe car plates that you can craft into the cars or send them to a specialized place, basically if the player has another player's item, the other player won't have it back, if it's stolen the police will have to find out.
0

Share this post


Link to post
Share on other sites
Well, since you always know from what player your going to steal something you have it's ID. You just need to find a way to link that ID to the file that holds his inventory like a dictionary. Or call your files something like inventory_<ID_NR>.xml.

Then you just remove the Stolen object from that user and add it to the user that stole it and tag it stolen within the item object so the police have a way to catch this petty criminal :D.

You can also serialize lists so when you have an item class and give each playerclass a List<item> inventory; you can save this to XML. Then when something needs to be removed and added to another players inventory list. you just switch it to another players list.
1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0