SA-MP Forums Archive
* I AM MAD BECAUSE OF 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: * I AM MAD BECAUSE OF MYSQL (/showthread.php?tid=623753)



Problem with mysql, return value; - TheRohlikar - 04.12.2016

Hello everybody,

I am using Stricken Kid's MySQL plugin.

No problem at all, everything's fine... except for one.

Код HTML:
stock GetDialogText(id, what[]){
	new query[128], value[512], whatisit[25];
	strcat(whatisit, what);
	format(query, sizeof(query), "SELECT * FROM `dialogs` WHERE dialogid='%d'", id);
	mysql_query(query);
	mysql_store_result();
	if(mysql_num_rows() != 0) {
	    while(mysql_fetch_row(query)){
	        mysql_fetch_field(what, value);
	        printf("WHAT: %s | VALUE: %s", whatisit, value);
	        mysql_free_result();
	        return value;
	    }
	}else printf("DIALOG '%d' DOESN'T EXIST!", id);
	mysql_free_result();
	return value;
}
So... as you can see, I use my own function "GetDialogText" which should do, that it takes something (string) from database. Well, it doesn't work as I want.

When I used "print" just to be sure that everything works, it shows me... "printf("WHAT: second_button | VALUE: Disconnect");"... It would be great, but "second_button" is last thing I want.

Код HTML:
ShowPlayerDialog(playerid, DG_REG, strval(GetDialogText(DG_REG, "style")), GetDialogText(DG_REG, "caption"), GetDialogText(DG_REG, "text"), GetDialogText(DG_REG, "first_button"), GetDialogText(DG_REG, "second_button"));
And what is worse, it drops a server...

Thank you very much for your help, if you do not understand to my explanation, then... try it again.

OH.. btw. I used commands /log and /reg to take some values (from another table), before I made this creature. And it normally worked and there is any different between that.


Re: * I AM MAD BECAUSE OF MYSQL - Yaa - 04.12.2016

Outdated plugin and new MySQL Server 8.0 synatax aren't same i think

i suggest to u use BlueG R41-2 Lastest Plugin from github and update u script https://github.com/pBlueG/SA-MP-MySQL/releases


Re: * I AM MAD BECAUSE OF MYSQL - TheRohlikar - 05.12.2016

Alright... I have a question.

Do I have to use "threaded" queries? Or is there any way to avoid them ?

Because... it just looks for me so complicated then versions before.


Re: * I AM MAD BECAUSE OF MYSQL - Vince - 05.12.2016

No, you don't need to necessarily use threaded queries but it is the better practice. The practice is really not that different than for example setting a timer or using the HTTP() function since both require callbacks.

The major benefit in threaded queries is that you're not halting other server processes during query execution. As the database grows larger, so will the query execution time. Improper use of indexes, full table scans and full text searches will also increase query execution time quite significantly. Best to keep the query execution time for a query under 40 milliseconds. If it's more, use threaded. Average execution time for simple queries is 10 to 15 milliseconds.


Re: * I AM MAD BECAUSE OF MYSQL - TheRohlikar - 05.12.2016

Okay, so... I couldn't translate a few words you are saying, but if I understood correctly... It is better for server, database, speed and actually everything.

Thanks man! XD Im gonna try it.


Re: * I AM MAD BECAUSE OF MYSQL - TheRohlikar - 05.12.2016

EDITED, SOLVED


Re: * I AM MAD BECAUSE OF MYSQL - TheRohlikar - 05.12.2016

My mistake... again .xD


Re: * I AM MAD BECAUSE OF WHIRLPOOL - TheRohlikar - 05.12.2016

Aright... It comes. I am trying to use "Whirlpool".
Код HTML:
new query[256], password[256];
WP_Hash(password, 129, inputtext);
mysql_format(mysql, query, sizeof(query), "INSERT INTO `accounts` (username, password, ip, lastconnect, alvl, access) VALUES ('%s', '%s', '%s', '%s', '0', '0')", PlayerName(playerid), password, PlayerIP(playerid), globalLastConnect());
print(query);
mysql_tquery(mysql, query, "OnPlayerRegister", "d", playerid);
It doesn't work. print says: "(NULL)" and it doesn't continue... without WP_Hash, it works.


Re: * I AM MAD BECAUSE OF MYSQL - TheRohlikar - 05.12.2016

Aright... too short "query" string.


Re: * I AM MAD BECAUSE OF MYSQL - TheRohlikar - 06.12.2016

Hey. Mm..

Is there any way to "return name;" through mysql ?

"SetPlayerName(playerid, GetPlayerNameFromDb(1);"

1 ... ID

I use BlueG's Plugin

(don't want to use variables)

EXAMPLE:
PHP код:
stock GetPlayerNameFromDb(id){
 new 
name[MAX_PLAYER_NAME];
 
mysql_format...blablablaselect ID
 mysql_tquery
...blablathreaded query
 cache_get_value
(0"name"namesizeof(name));
 return 
name;

?