PDA

View Full Version : mysql_pquery crashing server


GoldenLion
19/07/2017, 11:09 AM
Hi, I'm making an inventory system, but when it's supposed to load the inventory the server crashes at the mysql_pquery part where it selects the items from the database.
Here's the code:
forward OnCharacterLoaded(playerid);
public OnCharacterLoaded(playerid)
{
new rows;

cache_get_row_count(rows);

if (!rows)
{
PlayerInfo[playerid][pCharacterID] = 0;
ShowCharacters(playerid);
}
else
{
new name[MAX_PLAYER_NAME], query[80];

cache_get_value_name(0, "Name", name, sizeof(name));
cache_get_value_name_int(0, "Gender", PlayerInfo[playerid][pGender]);
cache_get_value_name(0, "Birthdate", PlayerInfo[playerid][pBirthdate], 11);
cache_get_value_name_int(0, "Skin", PlayerInfo[playerid][pSkin]);
cache_get_value_name_float(0, "PosX", PlayerInfo[playerid][pPos][0]);
cache_get_value_name_float(0, "PosY", PlayerInfo[playerid][pPos][1]);
cache_get_value_name_float(0, "PosZ", PlayerInfo[playerid][pPos][2]);
cache_get_value_name_float(0, "PosA", PlayerInfo[playerid][pPos][3]);

SetPlayerName(playerid, name);

mysql_format(database, query, sizeof(query), "SELECT * FROM inventories WHERE CharacterID = %d LIMIT %d", PlayerInfo[playerid][pCharacterID], MAX_INVENTORY);
mysql_pquery(database, query, "OnInventoryLoaded", "d", playerid);
}
for (new i = 6; i <= 13; i++) PlayerTextDrawHide(playerid, PlayerInfo[playerid][pTextdraw][i]);
TextDrawHideForPlayer(playerid, g_Textdraw[4]);
}
I've been trying to figure out this for an hour now, but I can't find any mistakes, because the query works, I tried it in phpmyadmin, I have the "OnInventoryLoaded" callback and I have the table.
This is what crashdetect prints:
[13:50:55] [debug] Server crashed while executing nrp.amx
[13:50:55] [debug] AMX backtrace:
[13:50:55] [debug] #0 native mysql_pquery () from mysql.DLL
[13:50:55] [debug] #1 00021348 in public OnCharacterLoaded (playerid=0) at C:\Users\dell\Desktop\Nevada Roleplay\gamemodes\nrp.pwn:1267
[13:50:55] [debug] Native backtrace:
[13:50:55] [debug] #0 5d278120 in ?? () from plugins\mysql.DLL
[13:50:55] [debug] #1 5d297e69 in ?? () from plugins\mysql.DLL
[13:50:55] [debug] #2 5d29f0a1 in ?? () from plugins\mysql.DLL
[13:50:55] [debug] #3 004010b6 in ?? () from samp-server.exe
[13:50:55] [debug] #4 5da3c6fa in ?? () from plugins\crashdetect.DLL
[13:50:55] [debug] #5 5da42278 in ?? () from plugins\crashdetect.DLL
[13:50:55] [debug] #6 5da3a0d7 in ?? () from plugins\crashdetect.DLL
[13:50:55] [debug] #7 5da3c74a in ?? () from plugins\crashdetect.DLL
[13:50:55] [debug] #8 5d524629 in ?? () from plugins\streamer.DLL
[13:50:55] [debug] #9 5d2789c0 in ?? () from plugins\mysql.DLL
[13:50:55] [debug] #10 5d29677d in ?? () from plugins\mysql.DLL
[13:50:55] [debug] #11 5d29910c in ?? () from plugins\mysql.DLL
[13:50:55] [debug] #12 5d27cfb1 in ?? () from plugins\mysql.DLL
[13:50:55] [debug] #13 5d27d1e3 in ?? () from plugins\mysql.DLL
[13:50:55] [debug] #14 5d27eaae in ?? () from plugins\mysql.DLL
[13:50:55] [debug] #15 00469a66 in ?? () from samp-server.exe
[13:50:55] [debug] #16 0048d4db in ?? () from samp-server.exe
[13:50:55] [debug] #17 0049b4a1 in ?? () from samp-server.exe
[13:50:55] [debug] #18 0049b4b1 in ?? () from samp-server.exe
What's wrong here?

EDIT: By the way the query works anywhere except OnCharacterLoaded.

Arbico
19/07/2017, 01:47 PM
I suggest you using dini, because it never crashes the server, Its really easy and fast to use
MySQL......
I hate it, I'll never ever use mySQL in my life
NEVER!

GoldenLion
19/07/2017, 01:48 PM
I suggest you using dini, because it never crashes the server, Its really easy and fast to use
MySQL......
I hate it, I'll never ever use mySQL in my life
NEVER!
That's not the answer I expected lol.

skuller12
19/07/2017, 01:52 PM
Try with this code

mysql_tquery(database, query, "OnInventoryLoaded", "d", playerid);

Eoussama
19/07/2017, 01:54 PM
I suggest you using dini, because it never crashes the server, Its really easy and fast to use
MySQL......
I hate it, I'll never ever use mySQL in my life
NEVER!.
LOL DUDE, are you serious? You're just too afraid to learn SQL, I really encourage you to get rid of the dini shell you're hiding under, and go learn something that's not outdated,

On topic: is the OnInventoryLoaded public forwarded?

GoldenLion
19/07/2017, 01:59 PM
On topic: is the OnInventoryLoaded public forwarded?
Of course, as I said above the query works everywhere except OnCharacterLoaded. It only crashes when I execute the query under OnCharacterLoaded.

GoldenLion
20/07/2017, 10:15 AM
Bumping this.

Dayrion
20/07/2017, 10:17 AM
Can you show your mysql debug logs?

GoldenLion
20/07/2017, 10:28 AM
If the logs had something useful I would've fixed it already, but this is where it ends every time:
[13:16:17] [DEBUG] mysql_format(1, 0x02F49EBC, 80, "SELECT * FROM inventories WHERE CharacterID = %d LIMIT %d") (C:\Users\dell\Desktop\Nevada Roleplay\gamemodes\nrp.pwn:1596)
[13:16:17] [DEBUG] mysql_format: return value: '56' (C:\Users\dell\Desktop\Nevada Roleplay\gamemodes\nrp.pwn:1596)
[13:16:17] [DEBUG] mysql_pquery(1, "SELECT * FROM inventories WHERE CharacterID = 3 LIMIT 15", "OnInventoryLoaded", "d") (C:\Users\dell\Desktop\Nevada Roleplay\gamemodes\nrp.pwn:1597)
[13:16:17] [DEBUG] CCallback::Create(amx=0x1f5a890, name='OnInventoryLoaded', format='d', params=0x2f49ea4, param_offset=5)
[13:16:17] [DEBUG] CCallback::Create - callback index for 'OnInventoryLoaded': 19
[13:16:17] [DEBUG] processing specifier 'd' with parameter index 0
and this is in the errors or log-core logs file:
[13:16:17] [log-core] exception 0XC0000005 (ACCESS_VIOLATION) from Vectored Exception Handler catched; shutting log-core down

jlalt
20/07/2017, 10:37 AM
it can be mysql plugin bug or smth. I would like to suggest you to use a timer with 100ms interval and see result.

SetTimerEx("CallTheQueryPlease", 100, false, "d", playerid);

// later
forward public CallTheQueryPlease(playerid);
public CallTheQueryPlease(playerid)
{
mysql_format(database, query, sizeof(query), "SELECT * FROM inventories WHERE CharacterID = %d LIMIT %d", PlayerInfo[playerid][pCharacterID], MAX_INVENTORY);
mysql_pquery(database, query, "OnInventoryLoaded", "d", playerid);
}

maddinat0r
20/07/2017, 10:47 AM
Can you show us the code where that call to "OnCharacterLoaded" is happening? (it's probably a mysql_pquery call too)

GoldenLion
20/07/2017, 10:58 AM
Can you show us the code where that call to "OnCharacterLoaded" is happening? (it's probably a mysql_pquery call too)
Thank you, you just solved my problem. I forgot to add "playerid" here:
mysql_pquery(database, query, "OnCharacterLoaded");

Vince
20/07/2017, 02:55 PM
I suggest you using dini, because it never crashes the server, Its really easy and fast to use
MySQL......
I hate it, I'll never ever use mySQL in my life
NEVER!

Oh, yeah, it's easy. Piss off. And it's not fast. It's the slowest system in existence. In your words:

Dini.....
I hate it, I'll never ever use dini in my life
NEVER!

ISmokezU
20/07/2017, 03:00 PM
I suggest you using dini, because it never crashes the server, Its really easy and fast to use
MySQL......
I hate it, I'll never ever use mySQL in my life
NEVER!

That's not the answer I expected lol.

Double lol.

Hansrutger
20/07/2017, 03:57 PM
Oh, yeah, it's easy. Piss off. And it's not fast. It's the slowest system in existence. In your words:

Dini.....
I hate it, I'll never ever use dini in my life
NEVER!

https://puu.sh/wfHOX/7310278478.png

Couldn't resist lmao