SA-MP Forums Archive
Debugging my car loading - 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: Debugging my car loading (/showthread.php?tid=448969)



Bad queries - thimo - 06.07.2013

Okay so i was working on my car loading wich doesnt work because of this:
pawn Код:
if(!sscanf(str, "d", integer))
What is wrong with this? The rest of the code:
pawn Код:
GetPlayerName(playerid, name, sizeof(name));
    format(str, sizeof(str), "SELECT `HouseID` FROM `Houses` WHERE `Owner`='%s'", name);
    mysql_query(str); //Send the query to the SQLite system integrated in SA:MP
    mysql_get_field("HouseID", str); //Gets the first field of the row returned (HouseID)
    if(!sscanf(str, "d", integer))
    {
        if(integer != 0) //Player has a house...
        {



Re: Debugging my car loading - thimo - 06.07.2013

Okay i fixed the query but now the server just simply crashes.


Re: Debugging my car loading - SuperViper - 06.07.2013

The column Owner doesn't exist in the Houses table.


Re: Debugging my car loading - Konstantinos - 06.07.2013

"Send the query to the SQLite system integrated in SA:MP". That's MySQL, not SQLite..

I'd convert with valstr, does sscanf do that? Anyway, the "Owner" field name is possible incorrect. Make sure you use the correct name (exact).


Re: Debugging my car loading - thimo - 06.07.2013

Fixed the query that was my dumbface again but now the server just simply crashes when i log in... After the login dialog.
The log:
Код:
[22:01:37] Number of vehicle models: 17
[22:02:00] Incoming connection: 127.0.0.1:64246
[22:02:01] [join] Thimo has joined the server (0:127.0.0.1)
[22:02:01] Doesnt work
But still i have a house but it still wont load the car and keeps saying Doesnt work and then when i login via the dialog it crashes.
My crashinfo.txt:
Код:
Loaded Modules:

samp-server.exe	A: 0x00400000 - 0x004F5000	(C:\Users\Thimo\SkyDrive\GTA sa-mp\Sa-mp 0.3d\samp-server.exe)

ntdll.dll	A: 0x778C0000 - 0x77A40000	(C:\Windows\SysWOW64\ntdll.dll)

kernel32.dll	A: 0x76770000 - 0x76880000	(C:\Windows\syswow64\kernel32.dll)

KERNELBASE.dll	A: 0x76DB0000 - 0x76DF7000	(C:\Windows\syswow64\KERNELBASE.dll)

SHELL32.dll	A: 0x75380000 - 0x75FCA000	(C:\Windows\syswow64\SHELL32.dll)

msvcrt.dll	A: 0x76D00000 - 0x76DAC000	(C:\Windows\syswow64\msvcrt.dll)

SHLWAPI.dll	A: 0x76600000 - 0x76657000	(C:\Windows\syswow64\SHLWAPI.dll)

GDI32.dll	A: 0x76320000 - 0x763B0000	(C:\Windows\syswow64\GDI32.dll)

USER32.dll	A: 0x76030000 - 0x76130000	(C:\Windows\syswow64\USER32.dll)

ADVAPI32.dll	A: 0x768D0000 - 0x76970000	(C:\Windows\syswow64\ADVAPI32.dll)

sechost.dll	A: 0x765E0000 - 0x765F9000	(C:\Windows\SysWOW64\sechost.dll)

RPCRT4.dll	A: 0x773D0000 - 0x774C0000	(C:\Windows\syswow64\RPCRT4.dll)

SspiCli.dll	A: 0x75310000 - 0x75370000	(C:\Windows\syswow64\SspiCli.dll)

CRYPTBASE.dll	A: 0x75300000 - 0x7530C000	(C:\Windows\syswow64\CRYPTBASE.dll)

LPK.dll	A: 0x77890000 - 0x7789A000	(C:\Windows\syswow64\LPK.dll)

USP10.dll	A: 0x76690000 - 0x7672D000	(C:\Windows\syswow64\USP10.dll)

WSOCK32.dll	A: 0x72E50000 - 0x72E57000	(C:\Windows\system32\WSOCK32.dll)

WS2_32.dll	A: 0x76730000 - 0x76765000	(C:\Windows\syswow64\WS2_32.dll)

NSI.dll	A: 0x76E10000 - 0x76E16000	(C:\Windows\syswow64\NSI.dll)

WINMM.dll	A: 0x72DE0000 - 0x72E12000	(C:\Windows\system32\WINMM.dll)

IMM32.DLL	A: 0x76580000 - 0x765E0000	(C:\Windows\system32\IMM32.DLL)

MSCTF.dll	A: 0x77300000 - 0x773CC000	(C:\Windows\syswow64\MSCTF.dll)

sscanf.DLL	A: 0x10000000 - 0x1000C000	(C:\Users\Thimo\SkyDrive\GTA sa-mp\Sa-mp 0.3d\plugins\sscanf.DLL)

MSVCR100.dll	A: 0x727B0000 - 0x7286F000	(C:\Windows\system32\MSVCR100.dll)

streamer.DLL	A: 0x616E0000 - 0x6171F000	(C:\Users\Thimo\SkyDrive\GTA sa-mp\Sa-mp 0.3d\plugins\streamer.DLL)

MSVCP100.dll	A: 0x72870000 - 0x728D9000	(C:\Windows\system32\MSVCP100.dll)

mysql.DLL	A: 0x00320000 - 0x00333000	(C:\Users\Thimo\SkyDrive\GTA sa-mp\Sa-mp 0.3d\plugins\mysql.DLL)

LIBMYSQL.dll	A: 0x02520000 - 0x02661000	(C:\Users\Thimo\SkyDrive\GTA sa-mp\Sa-mp 0.3d\LIBMYSQL.dll)

MSVCR90.dll	A: 0x730D0000 - 0x73173000	(C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_50934f2ebcb7eb57\MSVCR90.dll)

MSVCP90.dll	A: 0x61650000 - 0x616DE000	(C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_50934f2ebcb7eb57\MSVCP90.dll)

NLAapi.dll	A: 0x71A90000 - 0x71AA0000	(C:\Windows\system32\NLAapi.dll)

napinsp.dll	A: 0x71A80000 - 0x71A90000	(C:\Windows\system32\napinsp.dll)

pnrpnsp.dll	A: 0x71A60000 - 0x71A72000	(C:\Windows\system32\pnrpnsp.dll)

WLIDNSP.DLL	A: 0x71BE0000 - 0x71C07000	(C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live\WLIDNSP.DLL)

PSAPI.DLL	A: 0x763B0000 - 0x763B5000	(C:\Windows\syswow64\PSAPI.DLL)

mswsock.dll	A: 0x72AB0000 - 0x72AEC000	(C:\Windows\System32\mswsock.dll)

DNSAPI.dll	A: 0x71220000 - 0x71264000	(C:\Windows\system32\DNSAPI.dll)

winrnr.dll	A: 0x71BD0000 - 0x71BD8000	(C:\Windows\System32\winrnr.dll)

mdnsNSP.dll	A: 0x711F0000 - 0x71211000	(C:\Program Files (x86)\Bonjour\mdnsNSP.dll)

Iphlpapi.DLL	A: 0x72460000 - 0x7247C000	(C:\Windows\system32\Iphlpapi.DLL)

WINNSI.DLL	A: 0x72450000 - 0x72457000	(C:\Windows\system32\WINNSI.DLL)

rasadhlp.dll	A: 0x70F40000 - 0x70F46000	(C:\Windows\system32\rasadhlp.dll)

Whirlpool.DLL	A: 0x00360000 - 0x0036C000	(C:\Users\Thimo\SkyDrive\GTA sa-mp\Sa-mp 0.3d\plugins\Whirlpool.DLL)

MSVCR80.dll	A: 0x72FA0000 - 0x7303B000	(C:\Windows\WinSxS\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.6195_none_d09154e044272b9a\MSVCR80.dll)

wshtcpip.dll	A: 0x72AA0000 - 0x72AA5000	(C:\Windows\System32\wshtcpip.dll)
My SQL query log:
Код:
[22:04:41] CMySQLHandler::Query(SELECT `HouseID` FROM `Houses` WHERE `Houseowner`='Thimo') - Successfully executed.

[22:04:41] >> mysql_fetch_field_row( Connection handle: 1 )

[22:04:41] CMySQLHandler::FetchField(HouseID) - You cannot call this function now. (Reason: Fields/Rows are empty.)

[22:04:41] >> mysql_free_result( Connection handle: 1 )

[22:04:41] CMySQLHandler::FreeResult() - The result is already empty.

[22:04:42] >> mysql_query( Connection handle: 1 )

[22:04:42] CMySQLHandler::Query(UPDATE Users SET LastIP = '127.0.0.1' WHERE Name='Thimo') - An error has occured. (Error ID: 2014, Commands out of sync; you can't run this command now)

[22:04:42] >> mysql_ping( Connection handle: 1 )
It says field rows are empty but its not Empty!
Hope you can help me :S


Re: Debugging my car loading - thimo - 06.07.2013

When i tag it with /* */ and run it without the script it works fine.. :S
Okay i tagged out all get fields in the loop.. Now it still crashes... That means its something with the query not being excecuted properly D: How to get it fixed?
This still crashes me:
pawn Код:
// Setup local variables
    new cModel[15], cx[15], cy[15], cz[15], crot[15], Col1[15], Col2[15], string[128];

    GetPlayerName(playerid, name, sizeof(name));
//  new Float:cx, Float:cy, Float:cz, Float:crot, cModel;
    format(string, sizeof(string), "SELECT `HouseID` FROM `Houses` WHERE `Houseowner`='%s'", name);
    mysql_query(string); //Send the query to the SQLite system integrated in SA:MP
    mysql_get_field("HouseID", string); //Gets the first field of the row returned (HouseID)
    mysql_free_result();
    if(!sscanf(string, "d", integer))
    {
        if(integer != 0) //Player has a house...
        {
            format(string, sizeof(string), "SELECT * FROM `Vehicles` WHERE `HouseID`= '%d'", integer);
            mysql_query(string);
            if(mysql_num_rows() != 0)
            {
                while(mysql_num_rows()) //Loop xD
                {
    /*              //Do what you want with the vehicle :P
                    //Use db_get_field or db_get_field_assoc
                    //Remember to store the vehicle IDs in a variable so you can delete them in OnPlayerDisconnect
                    mysql_get_field("Model", cModel);
                    mysql_get_field("X", cx);
                    mysql_get_field("Y", cy);
                    mysql_get_field("Z", cz);
                    mysql_get_field("Rot", crot);
                    mysql_get_field("Color1", Col1);
                    mysql_get_field("Color2", Col2);
                    new hId = strval(str);
                    House_AddVehicle(hId, strval(cModel), floatstr(cx), floatstr(cy), floatstr(cz), floatstr(crot), strval(Col1), strval(Col2));*/

                }
                print("Does work");
            }

        }
    }



Re: Debugging my car loading - thimo - 07.07.2013

Does anyone know why the query is giving an empty row out when it is not empty?