SA-MP Forums Archive
Custom MySQLGetPlayerInt(playerid,field[]); Help! - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Custom MySQLGetPlayerInt(playerid,field[]); Help! (/showthread.php?tid=69829)



Custom MySQLGetPlayerInt(playerid,field[]); Help! - tom_jonez - 21.03.2009

K, so i just made my own command to get a field from a users row in the database.
Код:
public MySQLGetPlayerInt(playerid,field[])
{
	new name[28],query[1024],line[1024],fieldval[1024],destination[64];
	GetPlayerName(playerid,name,sizeof(name));
	format(query,sizeof(query),"SELECT * FROM `users` WHERE username='%s'",name);
	samp_mysql_query(query);
	samp_mysql_store_result();
	samp_mysql_fetch_row(line);
	samp_mysql_get_field(field,destination);
	format(fieldval,sizeof(fieldval),"%% ",destination);
	new Int = strval(fieldval);
	printf("Username: %s. Field: %s. Value: %%",name,fieldval,Int);
	return Int;
}
But it crashes my server using it in the command:
Код:
if(strcmp(cmd,"/adminlevel",true)==0)
	{
		format(string,sizeof(string),"%d",MySQLGetPlayerInt(playerid,"adminlevel"));
		new result;
		result = strval(string);
		format(string,sizeof(string),"%%",result);
	  SendClientMessage(playerid,COLOR_LIME,string);
	  return 1;
	}
It crashes somewhere in the MySQLGetPlayerInt command because it does not print that last line into the command prompt.


Re: Custom MySQLGetPlayerInt(playerid,field[]); Help! - Norn - 21.03.2009

A string is %s, where are you getting %% from?


Re: Custom MySQLGetPlayerInt(playerid,field[]); Help! - [RP]Rav - 21.03.2009

result is an integer, so it should be %d%% (if you want to show percentages) - it should print something like "43%"

%d = integer
%% = percent sign


Re: Custom MySQLGetPlayerInt(playerid,field[]); Help! - tom_jonez - 21.03.2009

%% stands for the real wildcard, it is saying it can be anything, string, integer, character.


Re: Custom MySQLGetPlayerInt(playerid,field[]); Help! - ICECOLDKILLAK8 - 21.03.2009

Quote:
Originally Posted by tom_jonez
%% stands for the real wildcard, it is saying it can be anything, string, integer, character.
Now thats just pure layzness


Re: Custom MySQLGetPlayerInt(playerid,field[]); Help! - tom_jonez - 22.03.2009

Quote:
Originally Posted by JeNkStAX
Quote:
Originally Posted by tom_jonez
%% stands for the real wildcard, it is saying it can be anything, string, integer, character.
Now thats just pure layzness
or bc the field could be anything from a string to a number....