PDA

View Full Version : creating 3d text labels with mysql


OuDayas
06/05/2019, 06:46 PM
Hi guys, I trying to create a simple system for creating some 3DTextLabel Saved in MySQL...

but that script didn't set correctly the text, if I want insert a break (the \n) the result is all text with the code
(ex: "Hi bro\nThis is a 3dtextlabel" the result is "Hi bro\nThis is a 3dtextlabel")
After the text the color if I want to save in the db on loading don't set any color, but in the gm set the color that I want.
How i can fix that?
This is the code

the enum:

enum TextLabelDB
{ // tabella nel Database: 3dtextlabes
SQLID,
Text[512],
Colore[256],
Float:PosX,
Float:PosY,
Float:PosZ,
Float:Distanza,
Interior,
WorldID
};
new TextLabelsDataBase[MAX_TL][TextLabelDB], total3dtext;

the public with forward

forward Load3DTextLabel();
public Load3DTextLabel()
{
// CreateDynamic3DTextLabel(const text[], color, Float:x, Float:y, Float:z, Float:drawdistance, attachedplayer = INVALID_PLAYER_ID, attachedvehicle = INVALID_VEHICLE_ID, testlos = 0, worldid = -1, interiorid = -1, playerid = -1, Float:distance = 100.0);
// Create3DTextLabel(text[], color, Float:X, Float:Y, Float:Z, Float:DrawDistance, virtualworld, testLOS);
if(cache_num_rows())
{
for(new i = 0; i<cache_num_rows(); i++)
{
cache_get_value_int(i, "SQLID", TextLabelsDataBase[i][SQLID]);
cache_get_value_name(i, "Text", TextLabelsDataBase[i][Text], 512);
cache_get_value_name(i, "Colore", TextLabelsDataBase[i][Colore], 256);
cache_get_value_float(i, "PosX", TextLabelsDataBase[i][PosX]);
cache_get_value_float(i, "PosY", TextLabelsDataBase[i][PosY]);
cache_get_value_float(i, "PosZ", TextLabelsDataBase[i][PosZ]);
cache_get_value_float(i, "Distanza", TextLabelsDataBase[i][Distanza]);
cache_get_value_int(i, "Interior", TextLabelsDataBase[i][Interior]);
cache_get_value_int(i, "WorldID", TextLabelsDataBase[i][WorldID]);
new str[512];
format(str, 512, TextLabelsDataBase[i][Text]);
CreateDynamic3DTextLabel(str, TextLabelsDataBase[i][Colore],
TextLabelsDataBase[i][PosX], TextLabelsDataBase[i][PosY], TextLabelsDataBase[i][PosZ], TextLabelsDataBase[i][Distanza],
INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, TextLabelsDataBase[i][WorldID], TextLabelsDataBase[i][Interior]);

total3dtext ++;
}
}
printf("[MySQL - 3D text label]: Sono stati caricati %d 3d text label con successo dal database", total3dtext);
return 1;
}

and the code in the gamemodeinit

mysql_tquery(g_SQL, "SELECT * FROM `3dtextlabel`", "Load3DTextLabel"); // 3DTextLabel

Mugala
06/05/2019, 09:30 PM
from the database, you're taking whole string in unicode, which is not affected at the game.
in pawn, you're compiling this color code, but in a middle game, it can't be re-compiled, so the compile does the whole job here.

OuDayas
06/05/2019, 11:42 PM
from the database, you're taking whole string in unicode, which is not affected at the game.
in pawn, you're compiling this color code, but in a middle game, it can't be re-compiled, so the compile does the whole job here.

Then i can't set the text with some codes, and the same for the code right?

Mugala
07/05/2019, 11:20 AM
Yeah that's right, but in some cases (not in 3dtextlabel) it's working, for example in a NumberPlates.