SA-MP Forums Archive
How to convert this code into mysql? - 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)
+--- Thread: How to convert this code into mysql? (/showthread.php?tid=584486)



How to convert this code into mysql? - JessThompson - 05.08.2015

Код:
	
	new sendername[MAX_PLAYER_NAME];
	GetPlayerName(playerid, sendername, sizeof(sendername));
	format(string, sizeof(string), "users/%s.ini", sendername);
	new File: hFile = fopen(string, io_read);
if (hFile) {
		gPlayerAccount[playerid] = 1;
		fclose(hFile);
	}
	else {
		gPlayerAccount[playerid] = 0;
 }
How would you convert that to mysql?


Re: How to convert this code into mysql? - MsgtHill - 05.08.2015

Have you set up your server with a MySQL plugin yet?


Re: How to convert this code into mysql? - perfectboy - 05.08.2015

Is this a register script you cant change only the part u posted if u r using ini system you have to change the whole script . So are you using mysql saving system or ini ?


Re: How to convert this code into mysql? - JessThompson - 05.08.2015

I am using ini and am converting it myself but I need to know how to convert that bit there.

Mysql is already set up plugin wise


Re: How to convert this code into mysql? - Beckett - 05.08.2015

Take a look.


Re: How to convert this code into mysql? - JessThompson - 05.08.2015

So I would do this?
Код:
	new sendername[MAX_PLAYER_NAME];
	GetPlayerName(playerid, sendername, sizeof(sendername));
	format(Query,sizeof(Query),"SELECT `Username` FROM `Users` WHERE `Username` = '%s' LIMIT 1;",sendername);
	mysql_query(Query);
	mysql_store_result();

	if(mysql_num_rows() != 0)//if number of rows is different from 0 then continue
	{
		gPlayerAccount[playerid] = 1;
	}
	else
	{
		gPlayerAccount[playerid] = 0;
 	}
 	mysql_free_result();
	return 1;



Re: How to convert this code into mysql? - Evocator - 05.08.2015

Quote:
Originally Posted by DaniceMcHarley
Посмотреть сообщение
This is an old, outdated tutorial. Do not use it.

JessThompson, the newest versions on BlueG's plugin allows you to thread your queries. Check this for a correct way to use the plugin.


Re: How to convert this code into mysql? - JessThompson - 05.08.2015

Quote:
Originally Posted by Ralfie
Посмотреть сообщение
This is an old, outdated tutorial. Do not use it.

JessThompson, the newest versions on BlueG's plugin allows you to thread your queries. Check this for a correct way to use the plugin.
Can I use the outdated one I understand it better?