Problem with Login/Register
#1

Hello, when someone connect to the server, it's showing me the dialog.

Code:
Код:
forward OnPlayerChecked(playerid); 
public OnPlayerChecked(playerid)
{
	new DB_Query[115], pname[MAX_PLAYER_NAME];
	GetPlayerName(playerid, pname, sizeof(pname));
	mysql_format(Database, DB_Query, sizeof(DB_Query), "SELECT * FROM `users` WHERE `Username` = '%e'", pname);
	mysql_tquery(Database, DB_Query, "OnPlayerChecked2", "i", pInfo[playerid]);
}

forward OnPlayerChecked2(playerid);
public OnPlayerChecked2(playerid)
{
	new rows;
        cache_get_row_count(rows);
	if(rows)
	{	
		SendClientMessage(playerid, COLOR_WHITE, ""alb"SERVER: "w"You already have a registered account, please enter your password into the dialog box.");
		cache_get_value(0, "Password", pInfo[playerid][Password], 65);
		ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "SERVER: Login", "Welcome to OldStyle RPG.\n\nPlease enter your password below.", "Login", "Cancel");
	}
	else
	{
		SendClientMessage(playerid, COLOR_WHITE, ""alb"SERVER: "w"You aren't registered yet, please your desired password in the dialog box to register.");
		ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "SERVER: Registration", "Welcome to OldStyle RPG.\n\nPlease enter your desired password below.", "Register", "Cancel");
	}
	TextDrawShowForPlayer(playerid, Text:blackbox);
	return 1;
}
Reply
#2

PHP код:
mysql_tquery(DatabaseDB_Query"OnPlayerChecked2""i"pInfo[playerid]); 
I don't see pInfo[playerid] getting any value there, thus the ID forwarded is 0 and the dialogs show to you (or any ID 0).

PHP код:
mysql_tquery(DatabaseDB_Query"OnPlayerChecked2""i"playerid); 
Reply
#3

If i put like that the server it's crashing. In server_log with crashdetect is that:

Код:
SA-MP Dedicated Server
----------------------
v0.3.7-R2, ©2005-2015 SA-MP Team

[23:09:58] 
[23:09:58] Server Plugins
[23:09:58] --------------
[23:09:58]  Loading plugin: crashdetect
[23:09:58]   CrashDetect v4.18.1 is OK.
[23:09:58]   Loaded.
[23:09:58]  Loading plugin: mysql
[23:09:58]  >> plugin.mysql: R41-4 successfully loaded.
[23:09:58]   Loaded.
[23:09:58]  Loading plugin: sscanf
[23:09:58] 

[23:09:58]  ===============================

[23:09:58]       sscanf plugin loaded.     

[23:09:58]          Version:  2.8.2        

[23:09:58]    © 2012 Alex "******" Cole  

[23:09:58]  ===============================

[23:09:58]   Loaded.
[23:09:58]  Loaded 3 plugins.

[23:09:58] 
[23:09:58] Filterscripts
[23:09:58] ---------------
[23:09:58]   Loading filterscript 'fly.amx'...
[23:09:58] =========================================

[23:09:58] Fly include demo FS by Norck
[23:09:58]  
[23:09:58] =========================================

[23:09:58]   Loading filterscript 'int.amx'...
[23:09:58] 
--------------------------------------
[23:09:58]  Loading . . . FS Interior Houses By Junkbuster
[23:09:58] --------------------------------------

[23:09:58]   Loaded 2 filterscripts.

[23:09:58] [MySQL]: Conexiunea cu baza de date (OldStyle) a fost stabilita.
[23:09:58] Number of vehicle models: 0
[23:09:58] House 1, x: 1317643552, y:1317666723, z:1317170944
[23:09:58] Loaded 1 houses from Database.
[23:10:14] [connection] 127.0.0.1:56400 requests connection cookie.
[23:10:15] [connection] incoming connection: 127.0.0.1:56400 id: 0
[23:10:16] [join] 0To= has joined the server (0:127.0.0.1)
[23:10:20] [debug] Server crashed while executing RPG-C0oL3r.amx
[23:10:20] [debug] AMX backtrace:
[23:10:20] [debug] #0 native mysql_tquery () from mysql.DLL
[23:10:20] [debug] #1 00007b3c in public OnPlayerChecked () from RPG-C0oL3r.amx
[23:10:20] [debug] Native backtrace:
[23:10:20] [debug] #0 6fa474d3 in ?? () from plugins\mysql.DLL
[23:10:20] [debug] #1 6fa65035 in ?? () from plugins\mysql.DLL
[23:10:20] [debug] #2 6fa6d7d1 in ?? () from plugins\mysql.DLL
[23:10:20] [debug] #3 004010b6 in ?? () from samp-server.exe
[23:10:20] [debug] #4 70afd60a in ?? () from plugins\crashdetect.DLL
[23:10:20] [debug] #5 70b04078 in ?? () from plugins\crashdetect.DLL
[23:10:20] [debug] #6 70afa767 in ?? () from plugins\crashdetect.DLL
[23:10:20] [debug] #7 70afd65a in ?? () from plugins\crashdetect.DLL
[23:10:20] [debug] #8 00482a68 in ?? () from samp-server.exe
[23:10:20] [debug] #9 004912ba in ?? () from samp-server.exe
[23:10:20] [debug] Registers:
[23:10:20] [debug] EAX: 00000000 EBX: 04d529d0 ECX: 0019f9ac EDX: 04cdf674
[23:10:20] [debug] ESI: 0019fb1c EDI: 0019fadc EBP: 00000000 ESP: 0019fe18
[23:10:20] [debug] EIP: 004912ba EFLAGS: 00010246
[23:10:20] [debug] Stack:
[23:10:20] [debug] ESP+00000000: 00000005 7719dd70 7719dd20 00000000
[23:10:20] [debug] ESP+00000020: 0019ff80 00350000 0001401c 00010101
[23:10:20] [debug] ESP+00000040: 04339df0 656d6167 65646f6d 00003531
[23:10:20] [debug] ESP+00000060: 0019fe68 0019ff70 0019ff70 0049d208
[23:10:20] [debug] ESP+00000080: 004ab4a0 0019ff70 004ab0e1 ffffffff
[23:10:20] [debug] ESP+000000a0: 00000094 00000006 00000002 000023f0
[23:10:20] [debug] ESP+000000c0: 00000000 00000000 00000000 00000000
[23:10:20] [debug] ESP+000000e0: 00000000 00000000 00000000 00000000
[23:10:20] [debug] ESP+00000100: 00000000 00000000 00000000 00000000
[23:10:20] [debug] ESP+00000120: 00000000 00000000 00000000 00000000
[23:10:20] [debug] ESP+00000140: 00000000 00000000 c0000005 00000000
[23:10:20] [debug] ESP+00000160: 004ba530 00000000 0019ff94 77148654
[23:10:20] [debug] ESP+00000180: 77534a77 00350000 c926f655 00000000
[23:10:20] [debug] ESP+000001a0: 00000000 00000000 c926f655 0019ffa0
[23:10:20] [debug] ESP+000001c0: 00000000 0019ffec 77534a47 ffffffff
[23:10:20] [debug] ESP+000001e0: 00350000 00000000 78746341 00000020
[23:10:20] [debug] ESP+00000200: 00000020 00000000 00000014 00000001
[23:10:20] [debug] ESP+00000220: 00000000 00000000 00000000 00000000
[23:10:20] [debug] ESP+00000240: 00000044 000002e0 0000025c 00000000
[23:10:20] [debug] ESP+00000260: 00000342 00000000 2d59495b 000008cc
[23:10:20] [debug] ESP+00000280: 32ceeacd 00000bfc 00000042 00000c40
[23:10:20] [debug] ESP+000002a0: 0000005e 00000fd0 00000362 00000000
[23:10:20] [debug] ESP+000002c0: 00000392 00000010 00000009 000000ec
[23:10:20] [debug] ESP+000002e0: 00000001 00000002 00001758 000007a0
[23:10:20] [debug] ESP+00000300: 00000001 00000004 00002d84 00000314
[23:10:20] [debug] ESP+00000320: 00000002 00000006 00003130 000000cc
[23:10:20] [debug] ESP+00000340: 00000001 00000009 000032ec 00000028
[23:10:20] [debug] ESP+00000360: 00000001 64487353 0000002c 00000001
[23:10:20] [debug] ESP+00000380: 00000001 000015a4 0000002c 0000005e
[23:10:20] [debug] ESP+000003a0: 00000000 00000000 00000000 00000000
[23:10:20] [debug] ESP+000003c0: 00000038 00000000 003a0043 0057005c
[23:10:20] [debug] ESP+000003e0: 006e0069 00780053 005c0073 00000000
[23:10:20] [debug] Loaded modules:
[23:10:20] [debug] 00400000 - 00519000 samp-server.exe
[23:10:20] [debug] 774d0000 - 7765d000 ntdll.dll
[23:10:20] [debug] 77130000 - 77200000 KERNEL32.DLL
[23:10:20] [debug] 75450000 - 75627000 KERNELBASE.dll
[23:10:20] [debug] 75c00000 - 76f33000 SHELL32.dll
[23:10:20] [debug] 77410000 - 774cd000 msvcrt.dll
[23:10:20] [debug] 74020000 - 74058000 cfgmgr32.dll
[23:10:20] [debug] 772f0000 - 77407000 ucrtbase.dll
[23:10:20] [debug] 75a00000 - 75a88000 shcore.dll
[23:10:20] [debug] 749d0000 - 74a8e000 RPCRT4.dll
[23:10:20] [debug] 73ef0000 - 73f10000 SspiCli.dll
[23:10:20] [debug] 73ee0000 - 73eea000 CRYPTBASE.dll
[23:10:20] [debug] 77290000 - 772e7000 bcryptPrimitives.dll
[23:10:20] [debug] 75400000 - 75443000 sechost.dll
[23:10:20] [debug] 757b0000 - 759f6000 combase.dll
[23:10:20] [debug] 74de0000 - 753a6000 windows.storage.dll
[23:10:20] [debug] 77200000 - 77278000 advapi32.dll
[23:10:20] [debug] 74cf0000 - 74d35000 shlwapi.dll
[23:10:20] [debug] 74d40000 - 74d62000 GDI32.dll
[23:10:20] [debug] 740d0000 - 7422e000 gdi32full.dll
[23:10:20] [debug] 770b0000 - 7712c000 msvcp_win.dll
[23:10:20] [debug] 74a90000 - 74c05000 USER32.dll
[23:10:20] [debug] 75630000 - 75646000 win32u.dll
[23:10:20] [debug] 73f10000 - 73f1e000 kernel.appcore.dll
[23:10:20] [debug] 753b0000 - 753f5000 powrprof.dll
[23:10:20] [debug] 77090000 - 770a4000 profapi.dll
[23:10:20] [debug] 63b20000 - 63b28000 WSOCK32.dll
[23:10:20] [debug] 74d70000 - 74dd6000 WS2_32.dll
[23:10:20] [debug] 72370000 - 72394000 WINMM.dll
[23:10:20] [debug] 70ab0000 - 70ad3000 WINMMBASE.dll
[23:10:20] [debug] 742d0000 - 742f5000 IMM32.DLL
[23:10:20] [debug] 70ae0000 - 70b30000 crashdetect.DLL
[23:10:20] [debug] 6fee0000 - 6ff49000 MSVCP100.dll
[23:10:20] [debug] 6fe20000 - 6fedf000 MSVCR100.dll
[23:10:20] [debug] 6fa40000 - 6fa8e000 mysql.DLL
[23:10:20] [debug] 723c0000 - 723da000 log-core.dll
[23:10:20] [debug] 6f6d0000 - 6f79d000 libmariadb.dll
[23:10:20] [debug] 6f650000 - 6f6c1000 MSVCP140.dll
[23:10:20] [debug] 74360000 - 744e2000 CRYPT32.dll
[23:10:20] [debug] 74060000 - 7406e000 MSASN1.dll
[23:10:20] [debug] 72350000 - 72365000 VCRUNTIME140.dll
[23:10:20] [debug] 722d0000 - 722da000 Secur32.dll
[23:10:20] [debug] 6d580000 - 6d591000 napinsp.dll
[23:10:20] [debug] 6d560000 - 6d576000 pnrpnsp.dll
[23:10:20] [debug] 6d540000 - 6d553000 NLAapi.dll
[23:10:20] [debug] 73090000 - 730e5000 mswsock.dll
[23:10:20] [debug] 72ac0000 - 72b54000 DNSAPI.dll
[23:10:20] [debug] 77280000 - 77287000 NSI.dll
[23:10:20] [debug] 73cd0000 - 73d00000 IPHLPAPI.DLL
[23:10:20] [debug] 70aa0000 - 70aac000 winrnr.dll
[23:10:20] [debug] 6fd60000 - 6fd70000 wshbth.dll
[23:10:20] [debug] 70070000 - 70078000 rasadhlp.dll
[23:10:20] [debug] 10000000 - 1000f000 sscanf.DLL
[23:10:20] [debug] 70020000 - 7006e000 fwpuclnt.dll
[23:10:20] [debug] 737e0000 - 737f9000 bcrypt.dll
[23:10:20] [debug] 72980000 - 729f9000 uxtheme.dll
[23:10:20] [debug] 73f20000 - 74017000 ole32.dll
[23:10:20] [debug] 70cb0000 - 70e2a000 PROPSYS.dll
[23:10:20] [debug] 756f0000 - 75783000 OLEAUT32.dll
[23:10:20] [debug] 75650000 - 756d2000 clbcatq.dll
[23:10:20] [debug] 55230000 - 55507000 OneCoreUAPCommonProxyStub.dll
[23:10:20] [debug] 70e70000 - 70e86000 CLDAPI.dll
[23:10:20] [debug] 70e30000 - 70e6b000 AEPIC.dll
[23:10:20] [debug] 72e60000 - 72e68000 FLTLIB.DLL
[23:10:20] [debug] 722f0000 - 72318000 ntmarta.dll
[23:10:20] [debug] 72330000 - 72343000 cryptsp.dll
[23:10:20] [debug] 6fd90000 - 6fdcd000 edputil.dll
[23:10:20] [debug] 5b590000 - 5b614000 Windows.StateRepositoryPS.dll
[23:10:20] [debug] 6de90000 - 6e01c000 urlmon.dll
[23:10:20] [debug] 75790000 - 757a9000 imagehlp.dll
[23:10:20] [debug] 6dc70000 - 6de89000 iertutil.dll
[23:10:20] [debug] 6f9a0000 - 6f9fe000 msiso.dll
Reply
#4

What is pInfo then?
Reply
#5

Код:
enum ENUM_PLAYER_DATA
{
	ID,
	Name[MAX_PLAYER_NAME],
	Password[65],
	WrongPass,
	RemainingAtt,
	pLogged,

	pHouse,

	pAdmin,
	pHelper,

	pRespect,
	pHours,

	pCash,
}
new pInfo[MAX_PLAYERS][ENUM_PLAYER_DATA];
Reply
#6

I don't understand how it works if there's no specific value assigned to pInfo (it normally returns 0), though post the MySQL log and see if there's anything interesting over there.
Reply
#7

No logs or any error in mysql_log

But i don't understand why it's crashing when the player join with "playerid"

EDIT: I changed code to:

Код:
public OnPlayerConnect(playerid)
{
	TogglePlayerSpectating(playerid, true);

	GetPlayerName(playerid, pInfo[playerid][Name], MAX_PLAYER_NAME);
	pInfo[playerid][RemainingAtt] = 3;
	pInfo[playerid][pCash] = 120000;
	pInfo[playerid][pAdmin] = 0;
	pInfo[playerid][pHelper] = 0;
	pInfo[playerid][pRespect] = 0;
	pInfo[playerid][pHours] = 0;

	SendClientMessage(playerid, COLOR_DEFAULT, " ");
	SendClientMessage(playerid, COLOR_DEFAULT, " ");
	SendClientMessage(playerid, COLOR_DEFAULT, " ");
	SendClientMessage(playerid, COLOR_DEFAULT, " ");
	SendClientMessage(playerid, COLOR_DEFAULT, " ");
	SendClientMessage(playerid, COLOR_DEFAULT, " ");
	SendClientMessage(playerid, COLOR_DEFAULT, " ");
	SendClientMessage(playerid, COLOR_DEFAULT, " ");
	SendClientMessage(playerid, COLOR_DEFAULT, " ");
	SendClientMessage(playerid, COLOR_DEFAULT, " ");
	SendClientMessage(playerid, COLOR_DEFAULT, " ");
	SendClientMessage(playerid, COLOR_DEFAULT, " ");
	SendClientMessage(playerid, COLOR_DEFAULT, " ");
	SendClientMessage(playerid, COLOR_DEFAULT, " ");
	SendClientMessage(playerid, COLOR_DEFAULT, " ");
	SendClientMessage(playerid, COLOR_DEFAULT, ""alb"SERVER: "w"Welcome to OldStyle RPG.");
	
	GameTextForPlayer(playerid, "~r~CHECKING BAN STATUS...", 3000, 3);
	SetTimer("OnPlayerChecked", 3500, 0);
	return 1;
}

forward OnPlayerChecked(playerid); 
public OnPlayerChecked(playerid)
{
	new DB_Query[115], pname[MAX_PLAYER_NAME];
	GetPlayerName(playerid, pname, sizeof(pname));
	mysql_format(Database, DB_Query, sizeof(DB_Query), "SELECT * FROM `users` WHERE `Username` = '%e'", pname);
	mysql_query(Database, DB_Query);

	new rows;
    cache_get_row_count(rows);
	if(rows)
	{	
		SendClientMessage(playerid, COLOR_WHITE, ""alb"SERVER: "w"You already have a registered account, please enter your password into the dialog box.");
		cache_get_value(0, "Password", pInfo[playerid][Password], 65);
		ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "SERVER: Login", "Welcome to OldStyle RPG.\n\nPlease enter your password below.", "Login", "Cancel");
	}
	else
	{
		SendClientMessage(playerid, COLOR_WHITE, ""alb"SERVER: "w"You aren't registered yet, please your desired password in the dialog box to register.");
		ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "SERVER: Registration", "Welcome to OldStyle RPG.\n\nPlease enter your desired password below.", "Register", "Cancel");
	}
	TextDrawShowForPlayer(playerid, Text:blackbox);
	return 1;
}
And still not working, it will show me the dialogs again
Reply
#8

I solved, i used
Код:
SetTimerEx("OnPlayerChecked", 3500, false, "i", playerid)
instead
Код:
SetTimer("OnPlayerChecked", 3500, false)
Reply
#9

You were using a global timer for a player; forwarding playerid when you weren't even assigning it a value. My answer on that SetTimerEx would indeed solve the problem.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)