MySQL Login/Register problem
#1

Hello everyone. I'm seeking your help since I cannot figure out the following issue. I've recently started to learn scripting once more since a had a break since 0.1 of SAMP. And I'm completely lost. I used a ******* tutorial and followed along, trying to learn on how to make the basics of a MySQL Login/Register system. But after doing so it gives me the following errors. Here's my includes code with the errors. I hope you can help me and that I am not a pest, trying to learn. Thanks!

Код:
public OnPlayerConnect(playerid)
{
	new query[126], pName[MAX_PLAYER_NAME];
	
	GetPlayerName(playerid, pName, sizeof(pName));
	
	format(query, sizeof(query), "SELECT * FROM accounts where Name = '%s'", pName);
	mysql_query(query);
	mysql_store_result();
	
	if(mysql_num_rows() == 1)
	{
	    SendClientMessage(playerid, -1, "That username is registered already!");
	    ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Login", "Please login with the password you made", "Login", "Cancel");
	}
	else
	    return SendClientMessage(playerid, -1, "That username is not registered. You may register it!");
		ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Login", "Please enter a password you will remember", "Register", "Cancel");
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext())
{
	switch(dialogid)
	{
		case 0:
		{
			if(response)
			{
				new query[126], pName[MAX_PLAYER_NAME]
				GetPlayerName(playerid, pName, sizeof{pName));
				
				format(query, sizeof(query), "SELECT * FROM accounts WHERE name = '%s' AND password = '%s'", pName, inputtext);
				mysql_query(query);
				mysql_store_result();
				
				if(mysql_num_rows() == 1)
				{
					SendClientMessage(playerid, -1, "You have successfully signed in!");
					SpawnPlayer(playerid);
				}
				else
				(
					SendClientMessage(playerid, -1, "Incorrect password!"
				    ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Login", "Please login with the password you made", "Login", "Cancel");
				}
			} 
		}
		case 1:
		{
			if(response)
			{
				new query[126], pName[MAX_PLAYER_NAME]
				GetPlayerName(playerid, pName, sizeof{pName));
				
				format(query, sizeof(query), "INSTERT INTO accounts VALUES ('%s', '%s')", pName, inputtext);
				mysql_query(query);
				
				SendClientMessage(playerid, -1, "You have registered!");
				SpawnPlayer(playerid);
			}
		}
	}	
	return 1;
}
Код:
/Server/Publics/OnPlayerConnect.pwn(3) : warning 219: local variable "query" shadows a variable at a preceding level
/Server/Publics/OnPlayerConnect.pwn(3) : warning 219: local variable "pName" shadows a variable at a preceding level
/Server/Publics/OnPlayerConnect.pwn(18) : warning 217: loose indentation
/Server/Publics/OnPlayerConnect.pwn(19) : warning 217: loose indentation
/Server/Publics/OnPlayerConnect.pwn(22) : error 025: function heading differs from prototype
/Server/Publics/OnPlayerConnect.pwn(22) : error 029: invalid expression, assumed zero
/Server/Publics/OnPlayerConnect.pwn(24) : error 010: invalid function or declaration
/Server/Publics/OnPlayerConnect.pwn(26) : error 010: invalid function or declaration
/Server/Publics/OnPlayerConnect.pwn(28) : error 010: invalid function or declaration
/Server/Publics/OnPlayerConnect.pwn(31) : error 001: expected token: ";", but found "-identifier-"
/Server/Publics/OnPlayerConnect.pwn(33) : error 021: symbol already defined: "format"
/Server/Publics/OnPlayerConnect.pwn(37) : error 010: invalid function or declaration
/Server/Publics/OnPlayerConnect.pwn(42) : error 010: invalid function or declaration
/Server/Publics/OnPlayerConnect.pwn(49) : error 010: invalid function or declaration
/Server/Publics/OnPlayerConnect.pwn(51) : error 010: invalid function or declaration
/Server/Publics/OnPlayerConnect.pwn(53) : error 021: symbol already defined: "query"
/Server/Publics/OnPlayerConnect.pwn(56) : error 021: symbol already defined: "format"
/Server/Publics/OnPlayerConnect.pwn(59) : error 021: symbol already defined: "SendClientMessage"
/Server/Publics/OnPlayerConnect.pwn(64) : error 010: invalid function or declaration
Reply
#2

Shameless self bump. Anyone?
Reply
#3

pawn Код:
warning 219: local variable "pName" shadows a variable at a preceding level //THIS MEANS YOU HAVE ALREADY THE SAME VARIABLE USED!

warning 217: loose indentation //USE TAB! OR use ignoring the problem
[B]#pragma Tabsize 0
#pragma Unused Check [/B]
SO about the rest please point out the lines.. Thank you!
Reply


Forum Jump:


Users browsing this thread: