How to save items which you gain
#1

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?
Reply
#2

To me, the way you said how it should is the best imo.
Reply
#3

Also I'm using SQLite, still same opinion?
Reply
#4

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
Reply
#5

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", "");
Reply
#6

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.
Reply
#7

Just use SQLitei https://sampforum.blast.hk/showthread.php?tid=303682 you can save/load arrays which makes storing item data a lot easier.
Reply
#8

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
Reply
#9

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)