SA:MP Need help with Undefined symbol connectionHandle
#1

I have this error undefined symbol "connectionHandle"
I'm using BlueG's R6 mysql plugin.
How can I define connectionHandle?
This is my code:
Код:
	new Query[80],pName[24],string[164];
	GetPlayerName(playerid,pName,24);
	mysql_format(connectionHandle, Query,"SELECT `Name` FROM `accounts` WHERE `Name` = '%s' LIMIT 1;",pName);
	mysql_tquery(Query);
Reply
#2

Below includes
pawn Код:
new connectionHandle;
OnGameModeInit
pawn Код:
connectionHandle = mysql_connect(enter your mysql connection details here)
Reply
#3

Quote:
Originally Posted by biker122
Посмотреть сообщение
Below includes
pawn Код:
new connectionHandle;
OnGameModeInit
pawn Код:
connectionHandle = mysql_connect(enter your mysql connection details here)
This is what i get
Код:
C:\Program Files (x86)\Compiler\include\a_mysql.inc(286) : warning 219: local variable "connectionHandle" shadows a variable at a preceding level
C:\Program Files (x86)\Compiler\include\a_mysql.inc(294) : warning 219: local variable "connectionHandle" shadows a variable at a preceding level
C:\Program Files (x86)\Compiler\include\a_mysql.inc(300) : warning 219: local variable "connectionHandle" shadows a variable at a preceding level
C:\Program Files (x86)\Compiler\include\a_mysql.inc(304) : warning 219: local variable "connectionHandle" shadows a variable at a preceding level
C:\Program Files (x86)\Compiler\include\a_mysql.inc(308) : warning 219: local variable "connectionHandle" shadows a variable at a preceding level
C:\Program Files (x86)\Compiler\include\a_mysql.inc(312) : warning 219: local variable "connectionHandle" shadows a variable at a preceding level
C:\Program Files (x86)\Compiler\include\a_mysql.inc(323) : warning 219: local variable "connectionHandle" shadows a variable at a preceding level
C:\Program Files (x86)\Compiler\include\a_mysql.inc(332) : warning 219: local variable "connectionHandle" shadows a variable at a preceding level
C:\Program Files (x86)\Compiler\include\a_mysql.inc(337) : warning 219: local variable "connectionHandle" shadows a variable at a preceding level
C:\Program Files (x86)\Compiler\include\a_mysql.inc(343) : warning 219: local variable "connectionHandle" shadows a variable at a preceding level
Reply
#4

Because, connectionHandle is declared again inside the callback/command.
Can you show the line 286, or someother which has the warnings?
Reply
#5

Quote:
Originally Posted by biker122
Посмотреть сообщение
Because, connectionHandle is declared again inside the callback/command.
Can you show the line 286, or someother which has the warnings?
Here you go.
Код:
stock LoginPlayer(playerid,const password[])
{
	new EscapedText[60], string[256];
	new Query[80];
	new pName[MAX_PLAYER_NAME];
	GetPlayerName(playerid, pName, sizeof(pName));
	mysql_real_escape_string(password, EscapedText);
	format(Query, sizeof(Query),"SELECT * FROM `accounts` WHERE `Name` = '%s' AND `Password` = '%s'",GetPName(playerid),EscapedText);
	mysql_query(Query);
	mysql_store_result();
	if(mysql_num_rows() != 0)
	{
		SendClientMessage(playerid,COLOR_MAXZONE,"[MaxZone]: {FFFFFF}You have been logged in!");
		LoadStats(playerid);
	}
	else
	{
		SendClientMessage(playerid, COLOR_ERROR, "Ai introdus o parola gresita. Va rugam sa incercati din nou.");
		format(string,sizeof(string),"Bun venit %s!\n\nAcest cont este deja inregistrat.\n\nIntrodu parola.",pName);
		ShowPlayerDialog(playerid,0,DIALOG_STYLE_INPUT,"{2788C4}L{A9C4E4}ogin",string,"Login","Cancel");
	}
	mysql_free_result();
	return 1;
}
Reply
#6

Why using connectionHandle variable name ?
Use other names! like handle, pandle, khandle || ...
Reply
#7

Got it fixed, but for some reason the user won't save when registering..
Do you have a good WORKING tutorial on how to make a registering system?
Here is the code if you think you can fix it. Thanks.
Код:
#include <a_samp>
#include <a_mysql>
#include <zcmd>
#include <sscanf2>

new connectionGG;

#define MYSQL_HOST		"localhost"
#define MYSQL_USER		"root"
#define MYSQL_DB		"maxzone"
#define MYSQL_PASS		""

#define COLOR_MAXZONE		0xFF2788C4FF
#define COLOR_ERROR			0xFFFF4040FF

#undef MAX_PLAYERS
#define MAX_PLAYERS 50

#define LOGIN_DIALOG 0
#define REGISTER_DIALOG 1

enum pEnum
{
	Name[MAX_PLAYER_NAME],
	Password[32],
	Money
}
new pInfo[MAX_PLAYERS][pEnum];
	
main()
{
	print("\n----------------------------------");
	print(" Blank Gamemode by your name here");
	print("----------------------------------\n");
}

public OnGameModeInit()
{
	connectionGG = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DB ,MYSQL_PASS);
	SetGameModeText("MXZ v0.1");
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	return 1;
}

public OnGameModeExit()
{
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	return 1;
}

public OnPlayerConnect(playerid)
{
	new szDestination[100],pName[24],string[164];
	GetPlayerName(playerid,pName,24);
	mysql_format(connectionGG, szDestination, sizeof(szDestination),"SELECT `Name` FROM `accounts` WHERE `Name` = '%s' LIMIT 1;",pName);
	mysql_query(connectionGG, szDestination);
	mysql_store_result();
	if(mysql_num_rows() != 0)//if number of rows is different from 0 then continue
	{
		format(string,sizeof(string),"Bun venit %s!\n\nAcest cont este deja inregistrat.\n\nIntrodu parola.",pName);
		ShowPlayerDialog(playerid,0,DIALOG_STYLE_INPUT,"{2788C4}L{A9C4E4}ogin",string,"Login","Cancel");
	}
	else
	{
		format(string,sizeof(string),"Bun venit %s!\n\nAcest cont este deja inregistrat.\n\nIntrodu parola.",pName);
		ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"{2788C4}R{A9C4E4}egister",string,"Register","Cancel");
	}
	mysql_free_result();
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	return 1;
}

public OnPlayerSpawn(playerid)
{
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	return 1;
}

public OnVehicleSpawn(vehicleid)
{
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	return 1;
}

public OnPlayerText(playerid, text[])
{
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/mycommand", cmdtext, true, 10) == 0)
	{
		// Do something here
		return 1;
	}
	return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
	return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
	return 1;
}

public OnRconCommand(cmd[])
{
	return 1;
}

public OnPlayerRequestSpawn(playerid)
{
	return 1;
}

public OnObjectMoved(objectid)
{
	return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
	return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
	return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
	return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
	return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
	return 1;
}

public OnPlayerExitedMenu(playerid)
{
	return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
	return 1;
}

public OnPlayerUpdate(playerid)
{
	return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
	return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
	return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
	return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(dialogid == 1)
	{
		if(strlen(inputtext) == 0)
		{
			new pName[MAX_PLAYER_NAME], string[256];
			GetPlayerName(playerid, pName, sizeof(pName));
			format(string,sizeof(string),"Bun venit %s!\n\nAcest cont este deja inregistrat.\n\nIntrodu parola.",pName);
			ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"{2788C4}R{A9C4E4}egister",string,"Register","Cancel");
		}
		else
		{
			new EscapedText[60];
			new Query[80];
			mysql_real_escape_string(inputtext, EscapedText);
			mysql_format(connectionGG, Query, sizeof(Query),"INSERT INTO `accounts` (Name,Password,Money) VALUES ('%s','%s,'0')",GetPName(playerid),EscapedText);
			mysql_query(connectionGG, Query);
			SendClientMessage(playerid,COLOR_MAXZONE,"[MaxZone]: {FFFFFF}You have been registered successfully!");
			GivePlayerMoney(playerid,5000);
			SetPlayerScore(playerid,100);
		}
	}
	if(dialogid == LOGIN_DIALOG)
	{
		if(strlen(inputtext) == 0)
		{
			new string[256];
			new pName[MAX_PLAYER_NAME];
			GetPlayerName(playerid, pName, sizeof(pName));
			format(string,sizeof(string),"Bun venit %s!\n\nAcest cont este deja inregistrat.\n\nIntrodu parola.",pName);
			ShowPlayerDialog(playerid,0,DIALOG_STYLE_INPUT,"{2788C4}L{A9C4E4}ogin",string,"Login","Cancel");
		}
		else
		{
			LoginPlayer(playerid,inputtext);
		}
	}
	return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
	return 1;
}
stock LoginPlayer(playerid,const password[])
{
	new EscapedText[60], string[256];
	new Query[80];
	new pName[MAX_PLAYER_NAME];
	GetPlayerName(playerid, pName, sizeof(pName));
	mysql_real_escape_string(password, EscapedText);
	mysql_format(connectionGG, Query, sizeof(Query),"SELECT * FROM `accounts` WHERE `Name` = '%s' AND `Password` = '%s'",GetPName(playerid),EscapedText);
	mysql_query(connectionGG, Query);
	mysql_store_result();
	if(mysql_num_rows() != 0)
	{
		SendClientMessage(playerid,COLOR_MAXZONE,"[MaxZone]: {FFFFFF}You have been logged in!");
		LoadStats(playerid);
	}
	else
	{
		SendClientMessage(playerid, COLOR_ERROR, "Ai introdus o parola gresita. Va rugam sa incercati din nou.");
		format(string,sizeof(string),"Bun venit %s!\n\nAcest cont este deja inregistrat.\n\nIntrodu parola.",pName);
		ShowPlayerDialog(playerid,0,DIALOG_STYLE_INPUT,"{2788C4}L{A9C4E4}ogin",string,"Login","Cancel");
	}
	mysql_free_result();
	return 1;
}
stock LoadStats(playerid)
{
	new pName[24],Query[80];
	GetPlayerName(playerid,pName,24);
	mysql_format(connectionGG, Query, sizeof(Query), "SELECT * FROM `accounts` WHERE `Name` = '%s' ", pName);
	mysql_query(connectionGG, Query);
	mysql_store_result();
	mysql_fetch_row_format(Query, "|");
	sscanf(Query, "e<p<|>s[24]s[23]i>", pInfo[playerid]);
	mysql_free_result();
	GivePlayerMoney(playerid,pInfo[playerid][Money]);
	return 1;
}
stock GetPName(playerid)
{
	new pName[MAX_PLAYER_NAME];
	GetPlayerName(playerid, pName, sizeof(pName));
	return pName;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)