SA-MP Forums Archive
Mysql 3dtext label - 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: Mysql 3dtext label (/showthread.php?tid=409339)



Mysql 3dtext label - PaulDinam - 21.01.2013

How can I load the labels?.. as I save them.

This is my saving.
Код:
stock AddLabelToFile(LabelInfo[], Float:LX, Float:LY, Float:LZ)
{
	new Query[200];

	format(Query, sizeof(Query), "INSERT INTO `labels` (LabelX, LabelY, LabelZ, LabelInfo) VALUES(%f, %f, %f, '%s')",
	LX, LY, LZ, LabelInfo);

	mysql_function_query(dbHandle, Query, true, "", "");
	return 1;
}
I made something for start to load..

Код:
stock AddLabelsFromFile()
{
	mysql_function_query(dbHandle, "SELECT * FROM `labels`", true, "AddLabels", "");
	return 1;
}



Re: Mysql 3dtext label - PaulDinam - 21.01.2013

help!


Re: Mysql 3dtext label - [MG]Dimi - 21.01.2013

Something like this:

pawn Код:
new result[100],Float:Pos[3],Info[50];
mysql_function_query(dbHandle, "SELECT * FROM `labels`", true, "AddLabels", "");
mysql_store_result();
while(mysql_fetch_row_format(result,"|"))
{
     sscanf(result,"p<|>fffs[50]",Pos[0],Pos[1],Pos[2],Info);
     Create3DtextLabel(Info,-1,Pos[0],Pos[1],Pos[2],30.0,0,1);
}
mysql_free_result();



Re: Mysql 3dtext label - PaulDinam - 21.01.2013

i did something like this , it doesn't work
Код:
forward AddLabels();
public AddLabels()
{
	new result[100],Float:Pos[3],Info[128];
	mysql_store_result();
	while(mysql_fetch_row_format(result,"|"))
	{
		 sscanf(result,"p<|>fffs[50]",Pos[0],Pos[1],Pos[2],Info);
		 CreateDynamic3DTextLabel(Info, RColors[random(sizeof(RColors))], Pos[0], Pos[1], Pos[2], 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, TEXTLABELDISTANCE);
	}
	mysql_free_result();
}

stock AddLabelsFromFile()
{
	mysql_function_query(dbHandle, "SELECT * FROM `labels`", false, "AddLabels", "");
	return 1;
}



Re: Mysql 3dtext label - [MG]Dimi - 22.01.2013

Quote:
Originally Posted by PaulDinam
Посмотреть сообщение
i did something like this , it doesn't work
Код:
forward AddLabels();
public AddLabels()
{
	new result[100],Float:Pos[3],Info[128];
	mysql_store_result();
	while(mysql_fetch_row_format(result,"|"))
	{
		 sscanf(result,"p<|>fffs[50]",Pos[0],Pos[1],Pos[2],Info);
		 CreateDynamic3DTextLabel(Info, RColors[random(sizeof(RColors))], Pos[0], Pos[1], Pos[2], 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, TEXTLABELDISTANCE);
	}
	mysql_free_result();
}

stock AddLabelsFromFile()
{
	mysql_function_query(dbHandle, "SELECT * FROM `labels`", false, "AddLabels", "");
	return 1;
}
You didn't query anything from MySQL. You can't do it like what you did.

pawn Код:
public AddLabels()
{
    new result[100],Float:Pos[3],Info[50];
    mysql_function_query(dbHandle, "SELECT * FROM `labels`", false, "", "");
    mysql_store_result();
    while(mysql_fetch_row_format(result,"|"))
    {
         sscanf(result,"p<|>fffs[50]",Pos[0],Pos[1],Pos[2],Info);
         CreateDynamic3DTextLabel(Info, RColors[random(sizeof(RColors))], Pos[0], Pos[1], Pos[2], 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, TEXTLABELDISTANCE);
    }
    mysql_free_result();
}
This should work. Why would you make it like that when you can simply make all in one callback.


Re: Mysql 3dtext label - FUNExtreme - 22.01.2013

Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
You didn't query anything from MySQL. You can't do it like what you did.
Incorrect. He is using threaded queries, that's how they work.


On topic: Have you checked if the data in your database is correct?
Have you debugged if the query is correct?
Have you checked if what the retreived information is by printing the values?