Posts: 340
Threads: 56
Joined: Jul 2012
Reputation:
0
So I'm gonna start working on a survival server which basically isn't about zombies, but just pure survival after some kind of disaster which struck SA.
I however want to know what's the best way to save items which player will receive like stone, wood, plastic etc..
Should I just save it like:
player name, IP, password, item1, item2, item3, item4, item5, item6...
or is there a better way?
Posts: 364
Threads: 41
Joined: Aug 2014
Reputation:
0
To me, the way you said how it should is the best imo.
Posts: 340
Threads: 56
Joined: Jul 2012
Reputation:
0
Also I'm using SQLite, still same opinion?
Posts: 71
Threads: 2
Joined: May 2014
Reputation:
0
what do you mean by saving information ?
You can use database for it. Its the most safest thing i can suggest, use md5 hash for passwords or maybe some other methods. and on player disconnect you can save the whole things he has on your database by calling queries
Posts: 71
Threads: 2
Joined: May 2014
Reputation:
0
new query[128];
format(query, sizeof(query), "UPDATE `accounts` SET `password` = MD5(\"%s\") IP = \"%s\", item1 = %d, item2 = %d, item3= %d, item4= %d, item5= %d, item6= %d WHERE `name` = %s", pass,ip,item1,item2,item3,item4,item5,item6,player name);
mysql_function_query(g_mysql_handle, query, true, "EmptyCallback", "");
Posts: 340
Threads: 56
Joined: Jul 2012
Reputation:
0
I know, and what you mentioned above is MySQL.
I'm just asking if I should save items separately one by one or if there's other way to save amount of columns.
Posts: 71
Threads: 2
Joined: May 2014
Reputation:
0
well there's a way you can store items on 1 column,
EG:
name id
Item1 = 0
Item2 = 1
Item3 = 2
you can store it in sql as "012" under "items" column.
But i'm not into it so i can't help. store them seperatly , that will save your mind :P
Posts: 86
Threads: 4
Joined: Jul 2012
Reputation:
0
Don't save items in the same table as you save player variables, it's pointless, ineffective and limits the number of items held to the number of fields you have.
The better way to do it is to create a separate table storing all items and create a foreign key called player_id that will link all items to their respective players.