ItsMods

Full Version: Shop system for Infected gametype
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13
Hash tables are stored in memory, once plugin is closed, it cleans up all memory used by that plugin. Therefore, restarting the server will close it, clean up memory used by it, then when restarted it will allocate new memory space for a new hash table.

As pointed above a SQL database is the way to go when it comes to tracking players, points, chat, kills, connections, etc. This way its never deleted upon server restarts, the only bad thing you have to worry about is if the database becomes corrupted, hence why you dump it every day or so, then upload it off site or to another drive.

Someone said about writing files and reading them which would work as well but a database offers a much more organized view of the data if done correctly. Although you have to be careful with SQL databases and make sure you escape " ' " (apostrophes) correctly or someone can SQL inject your database and cause some havoc @_@
(12-24-2012, 23:47)yokai134 Wrote: [ -> ]Hash tables are stored in memory, once plugin is closed, it cleans up all memory used by that plugin. Therefore, restarting the server will close it, clean up memory used by it, then when restarted it will allocate new memory space for a new hash table.

As pointed above a SQL database is the way to go when it comes to tracking players, points, chat, kills, connections, etc. This way its never deleted upon server restarts, the only bad thing you have to worry about is if the database becomes corrupted, hence why you dump it every day or so, then upload it off site or to another drive.

Someone said about writing files and reading them which would work as well but a database offers a much more organized view of the data if done correctly. Although you have to be careful with SQL databases and make sure you escape " ' " (apostrophes) correctly or someone can SQL inject your database and cause some havoc @_@
How to find a SQL database to shop mod?
Currently on these forums there aren't any zombie mod plugins that have a database backbone, the few on here are reliant on hash tables or files.
In OnPlayerDamaged:
CSHARP Code
  1. try
  2. {
  3. Points[Attacker.XUID] = (((int)Points[Attacker.XUID]) + 100);
  4.  
  5. StreamWriter writer = new StreamWriter("C:\\Mw3\\shop\\" + Attacker.XUID + ".txt");
  6.  
  7. int points = (int)Points[Attacker.XUID];
  8.  
  9. writer.WriteLine(Attacker.XUID + "=" + points.ToString());
  10. writer.Dispose();
  11. writer.Close();
  12. }

In OnPlayerConnect
CSHARP Code
  1. try
  2. {
  3. StreamReader reader = new StreamReader("C:\\Mw3\\shop\\" + Client.XUID + ".txt");
  4.  
  5. string read = reader.ReadLine();
  6. string read2 = read;
  7.  
  8. string[] readArray = read2.Split('=');
  9. Points[Client.XUID] = int.Parse(readArray[1]);
  10. }


I think I release the code because many people want the point saving stuff. This will create a .txt file for every player who got points and it's updating it every kill. It will read the file OnPlayerConnect and add the points. It isn't as good as a SQL database but it's working pretty good.
Depending on how popular your server becomes that will create thousands of files @_@
That's why you normally use a SQL-DB

Again for a quick usage guide see my Source code from EpicZombie Mod
How I said it isn't as good as a SQL DB but it's working and 1 file is like 1kb so even if you get over a thousand file it isn't that big
(12-27-2012, 21:55)yokai134 Wrote: [ -> ]Depending on how popular your server becomes that will create thousands of files @_@

I like it, offcourse it isn't the best, that's why I will try to make later with a SQL database.
I'm very happy about hes release Smile
Can Admins give Players Points with a command like add <Points> name?
(01-04-2013, 18:17)Hallla Wrote: [ -> ]Can Admins give Players Points with a command like add <Points> name?

Yes It's possible you need to code it :p
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13