SQLite loading problem
#1

Hey all! I have a problem with loading data from my table.
I got table 'users' which contains 311 fields. I've created so far login and register system in my GM but I have one major problem. After player logs in, system loads data from fields "Age" and "Gender" so it can check if the player has completed the tutorial or not. But I have no idea why it won't load anything from that two fields. This is my code:
pawn Код:
WP_Hash(password, sizeof(password), inputtext);
            format(string, sizeof(string), "SELECT * FROM `USERS` WHERE `NAME`='%s' AND `PASSWORD`='%s'", DB_Escape(RPN(playerid)), password);
            result = db_query(UserDatabase, string);
            if(db_num_rows(result) > 0) // so far everything works just fine
            {
                new szValue[64];
                db_get_field_assoc(result, "AGE", szValue, 3);
                PlayerInfo[playerid][pAge] = strval(szValue);
                db_get_field_assoc(result, "GENDER", szValue, 6);
                PlayerInfo[playerid][pGender] = strval(szValue);
                if(!PlayerInfo[playerid][pGender] || !PlayerInfo[playerid][pAge])
                {
                    ShowDialog(playerid, 3);
                }
                else
                {
                    LoadChar(playerid);
                    SpawnPlayer(playerid);
                }
And one more thing. Two fields that I mentioned, Age and Gender are not written with upper case, but when I try to write Age (db_get_field_assoc(result, "Age"..) with lower case, my server crashes. I really don't know how to fix this, so can somebody please help me? I appreciate it.
Reply
#2

The password has length of 129 so make sure the string is large enough to store the whole query because if the query was cut in, it won't execute anything.

The server can crash because the data of that field is NULL/empty. Make sure that none of the fields are empty while trying to load.

One last thing, use crashdect and compile with debug info so you can find what caused the crash in the future.

It can be found: https://github.com/Zeex/samp-plugin-...ases/tag/v4.12
About debug info: https://github.com/Zeex/samp-plugin-...ith-debug-info
Reply
#3

oh man, I have no clue which size to pick of the string so it will store so many characters. Is there some other way of loading table in pieces so I don't have to store everything in one string?
Thanks btw
EDIT: .inc files go into includes in pawno map and .pdb and .dll goes just into pawno map, right?
Reply
#4

Quote:
Originally Posted by dominik523
Посмотреть сообщение
oh man, I have no clue which size to pick of the string so it will store so many characters. Is there some other way of loading table in pieces so I don't have to store everything in one string?
Thanks btw
EDIT: .inc files go into includes in pawno map and .pdb and .dll goes just into pawno map, right?
I didn't understand what you meant. Did you mean the string to store the data of each field?

---

.inc files go to -> pawno\include folder
.dll files (if they're plugins for the scripts) into plugins folder unless are files that are useful for a plugin so in the main directory. An example would be libmysql.dll

I don't know about the .pdb
Reply
#5

Yeah, one massive string which contains data from each field.
I'll try the plugin now, thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)