PDA

View Full Version : Server crashes when player connects(MySQL R6)


Binx
05/04/2014, 12:39 PM
I was making a MySQL Register and Login system, it inserts data into the databse but crashes when the player logs in.

case THREAD_REGISTER_SPAWN:
{
PlayerInfo[extraid][pDBID] = mysql_insert_id(iConnectionHandle);

mysql_store_result(iConnectionHandle);

mysql_retrieve_row();

mysql_fetch_field_row(GlobalString, "PosX", connectionHandle);
PlayerInfo[extraid][pPos][0] = floatstr(GlobalString);

mysql_fetch_field_row(GlobalString, "PosY", connectionHandle);
PlayerInfo[extraid][pPos][1] = strval(GlobalString);

mysql_fetch_field_row(GlobalString, "PosZ", connectionHandle);
PlayerInfo[extraid][pPos][2] = floatstr(GlobalString);

mysql_fetch_field_row(GlobalString, "PosA", connectionHandle);
PlayerInfo[extraid][pPos][3] = floatstr(GlobalString);

mysql_fetch_field_row(GlobalString, "Health", connectionHandle);
PlayerInfo[extraid][pHealth] = strval(GlobalString);

mysql_fetch_field_row(GlobalString, "Armour", connectionHandle);
PlayerInfo[extraid][pArmour] = strval(GlobalString);

mysql_fetch_field_row(GlobalString, "Skin", connectionHandle);
PlayerInfo[extraid][pSkin] = strval(GlobalString);

mysql_free_result(iConnectionHandle);

PlayerInfo[extraid][pStatus] = 1;

SendClientMessage(extraid, -1, "Registered successful, no spawn set!"); // This was debugging!

}
This inserts data into the database.



case DIALOG_LOGIN:
{
new HashedPassword[129];
if(!response) return Kick(playerid);

WP_Hash(HashedPassword, 129, inputtext);

if(!strcmp(PlayerInfo[playerid][pPassword], HashedPassword, true, 128))
{
PlayerInfo[playerid][pStatus] = 1;

SendClientMessage(playerid, COLOR_YELLOW, "You're now logged into the server.");


}
else
{
format(GlobalString, sizeof(GlobalString), "This account (%s) is registered.\n\nPlease enter the account password to login.\n\nIf you did not register this account beforehand, please pick another name.", PlayerInfo[playerid][pUsername]);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Registeration: Login", GlobalString, "Login", "Cancel");
}
return true;
}

OnPlayerConnect:
format(GlobalQuery, sizeof(GlobalQuery), "SELECT * FROM players WHERE Username = '%s'", PlayerInfo[playerid][pUsername]);
mysql_query(GlobalQuery, THREAD_USERNAME_LOOKUP, playerid, iConnectionHandle);
THEAD_USERNAME_LOOKUP:
case THREAD_USERNAME_LOOKUP:
{
mysql_store_result(connectionHandle);

if(mysql_num_rows(connectionHandle) > 0)
{
mysql_retrieve_row();

mysql_fetch_field_row(PlayerInfo[extraid][pPassword], "Password", connectionHandle);

mysql_fetch_field_row(GlobalString, "ID", connectionHandle);
PlayerInfo[extraid][pDBID] = strval(GlobalString);

mysql_fetch_field_row(GlobalString, "PosX", connectionHandle);
PlayerInfo[extraid][pPos][0] = floatstr(GlobalString);

mysql_fetch_field_row(GlobalString, "PosY", connectionHandle);
PlayerInfo[extraid][pPos][1] = floatstr(GlobalString);

mysql_fetch_field_row(GlobalString, "PosZ", connectionHandle);
PlayerInfo[extraid][pPos][2] = floatstr(GlobalString);

mysql_fetch_field_row(GlobalString, "PosA", connectionHandle);
PlayerInfo[extraid][pPos][3] = floatstr(GlobalString);

mysql_fetch_field_row(GlobalString, "Health", connectionHandle);
PlayerInfo[extraid][pHealth] = strval(GlobalString);

mysql_fetch_field_row(GlobalString, "Armour", connectionHandle);
PlayerInfo[extraid][pArmour] = strval(GlobalString);

mysql_fetch_field_row(GlobalString, "Interior", connectionHandle);
PlayerInfo[extraid][pInterior] = strval(GlobalString);

mysql_fetch_field_row(GlobalString, "VirtualWorld", connectionHandle);
PlayerInfo[extraid][pVirtualWorld] = strval(GlobalString);

mysql_fetch_field_row(GlobalString, "Skin", connectionHandle);
PlayerInfo[extraid][pSkin] = strval(GlobalString);

PlayerInfo[extraid][pStatus] = 2;

mysql_free_result(connectionHandle);

format(GlobalString, sizeof(GlobalString), "The account %s is registered.\n\nPlease enter the account password to login.\n\nIf you did not register this account beforehand, please pick another name.", PlayerInfo[extraid][pUsername]);
ShowPlayerDialog(extraid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Registration: Login", GlobalString, "Login", "Cancel");
}
else
{
format(GlobalString, sizeof(GlobalString), "This account (%s) is not yet registered. Please enter a password to register a new account.", PlayerInfo[extraid][pUsername]);
ShowPlayerDialog(extraid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "SERVER: Register", GlobalString, "Register", "Cancel");
}
}

Binx
05/04/2014, 04:03 PM
Anyone?

Vortrex
05/04/2014, 04:28 PM
I doubt that either of these is causing your crash issue, but I noticed in the DIALOG_LOGIN, you mismatch cell sizes.

You have HashedPassword[129], but your strcmp function says 128.
I'm not an expert in the Whirlpool plugin, but I believe this will cause your passwords to be one character short during the login check, eventually leading to an incorrect password even though the password is correctly typed.
__________________________________________________ __________________________________

Also, a bit off topic, but the argument in strcmp that defines whether the check should be case sensitive, should be false. For example, the passwords Test123 and test123 are different.

Binx
05/04/2014, 04:35 PM
I doubt that either of these is causing your crash issue, but I noticed in the DIALOG_LOGIN, you mismatch cell sizes.

You have HashedPassword[129], but your strcmp function says 128.
I'm not an expert in the Whirlpool plugin, but I believe this will cause your passwords to be one character short during the login check, eventually leading to an incorrect password even though the password is correctly typed.
__________________________________________________ __________________________________

Also, a bit off topic, but the argument in strcmp that defines whether the check should be case sensitive, should be false. For example, the passwords Test123 and test123 are different.

that wouldn't cause the error. And I'm not really bothered about any of that right now.

Binx
05/04/2014, 05:24 PM
Sorry to bump, but I found this in the crashinfo log.
--------------------------

SA-MP Server: 0.3z



Exception At Address: 0x7247B9F0 Module: (MSVCR90.dll)



Registers:

EAX: 0x0343F468 EBX: 0x03130644 ECX: 0x00000000 EDX: 0x023F6E18

ESI: 0x0018FC3C EDI: 0x0298EB80 EBP: 0x0018FC00 ESP: 0x0018FBF4

EFLAGS: 0x00010246



Stack:

+0000: 0x72535DB4 0x00000000 0x0298EB80 0x0018FC34

+0010: 0x0030952E 0x00000000 0xC06BF475 0x0018FC3C

+0020: 0x03130644 0x023F6E18 0x725372AA 0x00000001

+0030: 0x00000000 0x0018FC98 0x00309FFD 0x00000000

+0040: 0x0018FCA4 0x003067D3 0x00309EDB 0x58736F50

+0050: 0x0018FC00 0x003067AF 0x0018FC70 0x00000004

+0060: 0x0000000F 0xC06BF4E5 0x01F972ED 0x0018FC3C

+0070: 0x0343D478 0x034395B8 0x0018FC3C 0xC06BF4C5

+0080: 0x58736F50 0xC06BF400 0x00309F3C 0x0298EB80

+0090: 0x00000004 0x0000000F 0xC06BF4E5 0x023F6E18

+00A0: 0x00000000 0x0018FEA0 0x0030A150 0x00000000

+00B0: 0x0313779C 0x004010B6 0x0298EB80 0x03191AE0

+00C0: 0x0313964C 0x00402B63 0x0298EB80 0x00000014

+00D0: 0x0018FCDC 0x03191AE0 0x0018FE20 0x01FF7E78

+00E0: 0x01FF8B08 0x00000000 0x00000000 0x000584A4

+00F0: 0x00058494 0x00058BC0 0x00054C50 0x00058BA4

+0100: 0x00054C50 0x03130644 0x0313964C 0x00000000

+0110: 0x03130048 0x00009008 0x00308147 0x0298EB80

+0120: 0x0018FD48 0x00000009 0x023F63A0 0x023F11A8

+0130: 0x00000000 0x00000000 0x00000000 0x00000000



--------------------------



Loaded Modules:

samp-server.exe A: 0x00400000 - 0x004F5000 (C:\Users\Jamie\Desktop\SAMP\samp-server.exe)

ntdll.dll A: 0x77300000 - 0x77457000 (C:\Windows\SYSTEM32\ntdll.dll)

KERNEL32.DLL A: 0x75DB0000 - 0x75EE0000 (C:\Windows\SYSTEM32\KERNEL32.DLL)

KERNELBASE.dll A: 0x76E00000 - 0x76EA6000 (C:\Windows\SYSTEM32\KERNELBASE.dll)

SHELL32.dll A: 0x749A0000 - 0x75A66000 (C:\Windows\SYSTEM32\SHELL32.dll)

USER32.dll A: 0x75F30000 - 0x76046000 (C:\Windows\SYSTEM32\USER32.dll)

WSOCK32.dll A: 0x72DE0000 - 0x72DE8000 (C:\Windows\SYSTEM32\WSOCK32.dll)

WINMM.dll A: 0x74170000 - 0x74191000 (C:\Windows\SYSTEM32\WINMM.dll)

msvcrt.dll A: 0x75B40000 - 0x75BF1000 (C:\Windows\SYSTEM32\msvcrt.dll)

combase.dll A: 0x76690000 - 0x767C6000 (C:\Windows\SYSTEM32\combase.dll)

SHLWAPI.dll A: 0x76F60000 - 0x76FA0000 (C:\Windows\SYSTEM32\SHLWAPI.dll)

GDI32.dll A: 0x76FB0000 - 0x770AD000 (C:\Windows\SYSTEM32\GDI32.dll)

WS2_32.dll A: 0x75EE0000 - 0x75F30000 (C:\Windows\SYSTEM32\WS2_32.dll)

WINMMBASE.dll A: 0x72F00000 - 0x72F2B000 (C:\Windows\SYSTEM32\WINMMBASE.dll)

RPCRT4.dll A: 0x76B70000 - 0x76C1C000 (C:\Windows\SYSTEM32\RPCRT4.dll)

NSI.dll A: 0x76050000 - 0x76058000 (C:\Windows\SYSTEM32\NSI.dll)

cfgmgr32.dll A: 0x76B20000 - 0x76B66000 (C:\Windows\SYSTEM32\cfgmgr32.dll)

DEVOBJ.dll A: 0x76A20000 - 0x76A3E000 (C:\Windows\SYSTEM32\DEVOBJ.dll)

SspiCli.dll A: 0x74930000 - 0x7494C000 (C:\Windows\SYSTEM32\SspiCli.dll)

CRYPTBASE.dll A: 0x74920000 - 0x74929000 (C:\Windows\SYSTEM32\CRYPTBASE.dll)

sechost.dll A: 0x75A70000 - 0x75AA4000 (C:\Windows\SYSTEM32\sechost.dll)

bcryptPrimitives.dll A: 0x748C0000 - 0x74911000 (C:\Windows\SYSTEM32\bcryptPrimitives.dll)

IMM32.DLL A: 0x76210000 - 0x76230000 (C:\Windows\system32\IMM32.DLL)

MSCTF.dll A: 0x76A40000 - 0x76B1E000 (C:\Windows\SYSTEM32\MSCTF.dll)

sscanf.DLL A: 0x10000000 - 0x1000C000 (C:\Users\Jamie\Desktop\SAMP\plugins\sscanf.DLL)

MSVCR100.dll A: 0x5AA10000 - 0x5AACF000 (C:\Users\Jamie\Desktop\SAMP\MSVCR100.dll)

Whirlpool.DLL A: 0x002E0000 - 0x002EC000 (C:\Users\Jamie\Desktop\SAMP\plugins\Whirlpool.DLL )

MSVCR80.dll A: 0x6E280000 - 0x6E31B000 (C:\Windows\WinSxS\x86_microsoft.vc80.crt_1fc8b3b9 a1e18e3b_8.0.50727.6910_none_d089c358442de345\MSVC R80.dll)

mysql.DLL A: 0x00300000 - 0x00313000 (C:\Users\Jamie\Desktop\SAMP\plugins\mysql.DLL)

LIBMYSQL.dll A: 0x02470000 - 0x026AE000 (C:\Users\Jamie\Desktop\SAMP\LIBMYSQL.dll)

MSVCR90.dll A: 0x72440000 - 0x724E3000 (C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9 a1e18e3b_9.0.30729.6871_none_50944e7cbcb706e5\MSVC R90.dll)

MSVCP90.dll A: 0x72530000 - 0x725BE000 (C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9 a1e18e3b_9.0.30729.6871_none_50944e7cbcb706e5\MSVC P90.dll)

ADVAPI32.dll A: 0x76230000 - 0x762DE000 (C:\Windows\SYSTEM32\ADVAPI32.dll)

napinsp.dll A: 0x712B0000 - 0x712C0000 (C:\Windows\system32\napinsp.dll)

pnrpnsp.dll A: 0x71290000 - 0x712A4000 (C:\Windows\system32\pnrpnsp.dll)

NLAapi.dll A: 0x712C0000 - 0x712D0000 (C:\Windows\system32\NLAapi.dll)

mswsock.dll A: 0x72D60000 - 0x72DAA000 (C:\Windows\System32\mswsock.dll)

DNSAPI.dll A: 0x716C0000 - 0x71735000 (C:\Windows\SYSTEM32\DNSAPI.dll)

winrnr.dll A: 0x71280000 - 0x71289000 (C:\Windows\System32\winrnr.dll)

wshbth.dll A: 0x70C30000 - 0x70C40000 (C:\Windows\system32\wshbth.dll)

mdnsNSP.dll A: 0x70C00000 - 0x70C21000 (C:\Program Files (x86)\Bonjour\mdnsNSP.dll)

Iphlpapi.DLL A: 0x72A50000 - 0x72A70000 (C:\Windows\SYSTEM32\Iphlpapi.DLL)

WINNSI.DLL A: 0x728B0000 - 0x728B8000 (C:\Windows\SYSTEM32\WINNSI.DLL)

rasadhlp.dll A: 0x71230000 - 0x71237000 (C:\Windows\System32\rasadhlp.dll)

streamer.DLL A: 0x5A9D0000 - 0x5AA0E000 (C:\Users\Jamie\Desktop\SAMP\plugins\streamer.DLL)

MSVCP100.dll A: 0x5A960000 - 0x5A9C9000 (C:\Users\Jamie\Desktop\SAMP\MSVCP100.dll)

SHCORE.dll A: 0x72E80000 - 0x72EF3000 (C:\Windows\SYSTEM32\SHCORE.dll)

uxtheme.dll A: 0x71B40000 - 0x71BC8000 (C:\Windows\system32\uxtheme.dll)

saHook.dll A: 0x70C40000 - 0x70C47000 (c:\PROGRA~2\mcafee\SITEAD~1\saHook.dll)

OLEAUT32.dll A: 0x76400000 - 0x7648B000 (C:\Windows\SYSTEM32\OLEAUT32.dll)

PROPSYS.dll A: 0x712D0000 - 0x713E9000 (C:\Windows\SYSTEM32\PROPSYS.dll)

SETUPAPI.dll A: 0x76060000 - 0x7620F000 (C:\Windows\SYSTEM32\SETUPAPI.dll)

Secur32.dll A: 0x72010000 - 0x72019000 (C:\Windows\SYSTEM32\Secur32.dll)