how to fix warning 219
#1

LARP_20100311.pwn(1982) : warning 219: local variable "query" shadows a variable at a preceding level

Код:
public MySQLUpdatePlayerFlo(query[], sqlplayerid, sqlvalname[], Float:sqlupdateflo) // by Luk0r
{
	new query[256];
	format(query, sizeof(query), "UPDATE players SET %s=%f WHERE id=%d", sqlvalname, sqlupdateflo, sqlplayerid);
	samp_mysql_query(query);
	new flotostr[32];
	format(flotostr, sizeof(flotostr), "%f", sqlupdateflo);
	MySQLUpdatePlayerStr(query, sqlplayerid, sqlvalname, flotostr);
	return 1;
}
How to fix this warning? who can help me.
Reply
#2

You can't have two variables with the same name, rename one of them.
Reply
#3

Quote:

public MySQLUpdatePlayerFlo(query[], sqlplayerid, sqlvalname[], Floatqlupdateflo) // by Luk0r
{
new query[256];
format(query, sizeof(query), "UPDATE players SET %s=%f WHERE id=%d", sqlvalname, sqlupdateflo, sqlplayerid);
samp_mysql_query(query);
new flotostr[32];
format(flotostr, sizeof(flotostr), "%f", sqlupdateflo);
MySQLUpdatePlayerStr(query, sqlplayerid, sqlvalname, flotostr);
return 1;
}

this line:

Quote:

new query[256];

is somewhere further up the script
Reply
#4

Quote:
Originally Posted by adsy
this line:

Quote:

new query[256];

is somewhere further up the script
It's here - MySQLUpdatePlayerFlo(query[], sqlplayerid, sqlvalname[], Floatqlupdateflo)
Reply
#5

Quote:
Originally Posted by Don Correlli
Quote:
Originally Posted by adsy
this line:

Quote:

new query[256];

is somewhere further up the script
It's here - MySQLUpdatePlayerFlo(query[], sqlplayerid, sqlvalname[], Floatqlupdateflo)
thats not "new"

its using the new from further up the script
Reply
#6

Quote:
Originally Posted by adsy
thats not "new"
It's doesn't have to be. It has the same name as the other query variable.
Reply
#7

going on that basis then just delete line

Код:
new query[256];
Reply
#8

Quote:
Originally Posted by Don Correlli
You can't have two variables with the same name, rename one of them.
But, othe public have use new query[256];. i need rename all of then?

Код:
public MySQLUpdatePlayerIntSingle(sqlplayerid, sqlvalname[], sqlupdateint) // by Luk0r
{
	new query[128];
	format(query, sizeof(query), "UPDATE players SET %s=%d WHERE id=%d", sqlvalname, sqlupdateint, sqlplayerid);
	samp_mysql_query(query);
	return 1;
}

public MySQLCheckAccount(sqlplayersname[]) // by Luk0r
{
	new query[128];
	new escstr[MAX_PLAYER_NAME];
	samp_mysql_real_escape_string(sqlplayersname, escstr);
	format(query, sizeof(query), "SELECT id FROM players WHERE LOWER(Name) = LOWER('%s') LIMIT 1", escstr);
	samp_mysql_query(query);
	samp_mysql_store_result();
	if (samp_mysql_num_rows()==0)
	{
		return 0;
	}
	else
	{
		new strid[32];
		new intid;
		samp_mysql_fetch_row(strid);
		intid = strval(strid);
		return intid;
	}
}

public MySQLCheckAccountLocked(sqlplayerid)
{
	new query[64];
	new lockedboolstr[4];
	format(query, sizeof(query), "SELECT Locked FROM players WHERE id = %d LIMIT 1", sqlplayerid);
	samp_mysql_query(query);
	samp_mysql_store_result();
	samp_mysql_fetch_row(lockedboolstr);
	if (strval(lockedboolstr) != 0)
	{
		return 1;
	}
	return 0;
}

public MySQLCheckIPBanned(ip[])
{
	new query[64];
	format(query, sizeof(query), "SELECT type FROM bans WHERE ip = '%s' AND inactive = 0 ORDER BY id DESC LIMIT 1", ip);
	samp_mysql_query(query);
	samp_mysql_store_result();
	if (samp_mysql_num_rows() != 0)
	{
		new bantypestr[4];
		new bantypeint;
		samp_mysql_fetch_row(bantypestr);
		bantypeint = strval(bantypestr);
		samp_mysql_free_result();
		return bantypeint;
	}
	return 0;
}

public MySQLFetchAcctSingle(sqlplayerid, sqlvalname[], sqlresult[])
{
	new query[128];
	format(query, sizeof(query), "SELECT %s FROM players WHERE id = %d LIMIT 1", sqlvalname, sqlplayerid);
	samp_mysql_query(query);
	samp_mysql_store_result();
	if(samp_mysql_fetch_row(sqlresult)==1)
	{
		return 1;
	}
	return 0;
}

public MySQLFetchAcctRecord(sqlplayerid, sqlresult[]) // by Luk0r
{
	new query[64];
	format(query, sizeof(query), "SELECT * FROM players WHERE id = %d LIMIT 1", sqlplayerid);
	samp_mysql_query(query);
	samp_mysql_store_result();
	if(samp_mysql_fetch_row(sqlresult)==1)
	{
		return 1;
	}
	return 0;
}

public MySQLCreateAccount(newplayersname[], newpassword[]) // by Luk0r
{
	new query[128];
	new sqlplyname[64];
	new sqlpassword[64];
	samp_mysql_real_escape_string(newplayersname, sqlplyname);
	samp_mysql_real_escape_string(newpassword, sqlpassword);
	format(query, sizeof(query), "INSERT INTO players (Name, Password) VALUES ('%s', '%s')", sqlplyname, sqlpassword);
	samp_mysql_query(query);
	new newplayersid = MySQLCheckAccount(newplayersname);
	if (newplayersid != 0)
	{
		return newplayersid;
	}
	return 0;
}

public MySQLAddLoginRecord(sqlplayerid, ipaddr[]) // by Luk0r
{
	new query[128];
	new escip[16];
	samp_mysql_real_escape_string(ipaddr, escip);
	format(query, sizeof(query), "INSERT INTO logins (time,ip,userid) VALUES (UNIX_TIMESTAMP(),'%s',%d)", escip, sqlplayerid);
	samp_mysql_query(query);
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)