Mysql 3dtext label
#1

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;
}
Reply
#2

help!
Reply
#3

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();
Reply
#4

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;
}
Reply
#5

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

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)