* I AM MAD BECAUSE OF MYSQL
#1

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.
Reply
#2

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
Reply
#3

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.
Reply
#4

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.
Reply
#5

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.
Reply
#6

EDITED, SOLVED
Reply
#7

My mistake... again .xD
Reply
#8

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.
Reply
#9

Aright... too short "query" string.
Reply
#10

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;

?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)