SA-MP Forums Archive
How to save items which you gain - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to save items which you gain (/showthread.php?tid=535398)



How to save items which you gain - LocMax - 03.09.2014

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?


Re: How to save items which you gain - Ox1gEN - 03.09.2014

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


Re: How to save items which you gain - LocMax - 03.09.2014

Also I'm using SQLite, still same opinion?


Re: How to save items which you gain - Fred1993 - 03.09.2014

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


Re: How to save items which you gain - Fred1993 - 03.09.2014

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


Re: How to save items which you gain - LocMax - 03.09.2014

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.


Re: How to save items which you gain - Pottus - 03.09.2014

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


Re: How to save items which you gain - Fred1993 - 03.09.2014

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


Re: How to save items which you gain - Rifa4life - 03.09.2014

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.