23.05.2020, 03:24
I'm using this filterscript but I want it in mysql
Firstly, I tried this :
There's no problem when i created the labels in game, and it's successfully saved in my table.
But when I restarted the server, the labels somehow didn't load.
Then I tried this :
And something worse came, it loads ton of labels and the server is so slow.
EDIT: Here are some defines and variables..
Firstly, I tried this :
pawn Code:
public OnGameModeInit()
{
print("\n--------------------------------------");
print("Ultimate Label Creator by -KillerThriller");
print("--------------------------------------\n");
for(new i = 0; i < MAX_LABELS;i++)
{
new Query[250];
mysql_format(mysql, Query, sizeof Query,"SELECT * FROM `labels` WHERE `LID` = '%i'",i);
mysql_tquery(mysql, Query, "LoadLabels1", "");
}
return 1;
}
pawn Code:
forward LoadLabels1();
public LoadLabels1()
{
for(new i = 0; i < MAX_LABELS;i++)
{
new rows,fields;
cache_get_data(rows, fields, mysql);
if(rows) {
new color[64],text[200];
cache_get_field_content(0, "Color", color, mysql, 128);
cache_get_field_content(0, "Text", text, mysql, 256);
LInfo[i][POSX] = cache_get_field_content_float(0, "X");
LInfo[i][POSY] = cache_get_field_content_float(0, "Y");
LInfo[i][POSZ] = cache_get_field_content_float(0, "Z");
LInfo[i][LDistance] = cache_get_field_content_float(0, "LDistance");
LInfo[i][World] = cache_get_field_content_int(0, "World");
format(LInfo[i][Text],200,"%s",text);
if(strcmp(color,"Red") == 0)
{
LInfo[i][Color] = llred;
LabelID[i] = Create3DTextLabel(LInfo[i][Text],LInfo[i][Color],LInfo[i][POSX],LInfo[i][POSY],LInfo[i][POSZ],LInfo[i][LDistance],LInfo[i][World],DEFAULT_LABEL_VIEW_THREW_OBJECTS);
}
if(strcmp(color,"Green") == 0)
{
LInfo[i][Color] = llgreen;
LabelID[i] = Create3DTextLabel(LInfo[i][Text],LInfo[i][Color],LInfo[i][POSX],LInfo[i][POSY],LInfo[i][POSZ],LInfo[i][LDistance],LInfo[i][World],DEFAULT_LABEL_VIEW_THREW_OBJECTS);
}
if(strcmp(color,"Yellow") == 0)
{
LInfo[i][Color] = llyellow;
LabelID[i] = Create3DTextLabel(LInfo[i][Text],LInfo[i][Color],LInfo[i][POSX],LInfo[i][POSY],LInfo[i][POSZ],LInfo[i][LDistance],LInfo[i][World],DEFAULT_LABEL_VIEW_THREW_OBJECTS);
}
if(strcmp(color,"Blue") == 0)
{
LInfo[i][Color] = llblue;
LabelID[i] = Create3DTextLabel(LInfo[i][Text],LInfo[i][Color],LInfo[i][POSX],LInfo[i][POSY],LInfo[i][POSZ],LInfo[i][LDistance],LInfo[i][World],DEFAULT_LABEL_VIEW_THREW_OBJECTS);
}
if(strcmp(color,"Pink") == 0)
{
LInfo[i][Color] = llpink;
LabelID[i] = Create3DTextLabel(LInfo[i][Text],LInfo[i][Color],LInfo[i][POSX],LInfo[i][POSY],LInfo[i][POSZ],LInfo[i][LDistance],LInfo[i][World],DEFAULT_LABEL_VIEW_THREW_OBJECTS);
}
if(strcmp(color,"White") == 0)
{
LInfo[i][Color] = llwhite;
LabelID[i] = Create3DTextLabel(LInfo[i][Text],LInfo[i][Color],LInfo[i][POSX],LInfo[i][POSY],LInfo[i][POSZ],LInfo[i][LDistance],LInfo[i][World],DEFAULT_LABEL_VIEW_THREW_OBJECTS);
}
Labelcount++;
}
}
printf("Labels loaded: %i",Labelcount);
return 1;
}
But when I restarted the server, the labels somehow didn't load.
Then I tried this :
pawn Code:
public OnGameModeInit()
{
print("\n--------------------------------------");
print("Ultimate Label Creator by -KillerThriller");
print("--------------------------------------\n");
LoadLabels();
return 1;
}
pawn Code:
stock LoadLabels()
{
for(new i = 0; i < MAX_LABELS;i++)
{
new Query[250];
mysql_format(mysql, Query, sizeof Query,"SELECT * FROM `labels` WHERE `LID` = '%i'",i);
mysql_tquery(mysql, Query, "LoadLabels1", "");
}
}
forward LoadLabels1();
public LoadLabels1()
{
for(new i = 0; i < MAX_LABELS;i++)
{
new rows,fields;
cache_get_data(rows, fields, mysql);
if(rows) {
new color[64],text[200];
cache_get_field_content(0, "Color", color, mysql, 128);
cache_get_field_content(0, "Text", text, mysql, 256);
LInfo[i][POSX] = cache_get_field_content_float(0, "X");
LInfo[i][POSY] = cache_get_field_content_float(0, "Y");
LInfo[i][POSZ] = cache_get_field_content_float(0, "Z");
LInfo[i][LDistance] = cache_get_field_content_float(0, "LDistance");
LInfo[i][World] = cache_get_field_content_int(0, "World");
format(LInfo[i][Text],200,"%s",text);
if(strcmp(color,"Red") == 0)
{
LInfo[i][Color] = llred;
LabelID[i] = Create3DTextLabel(LInfo[i][Text],LInfo[i][Color],LInfo[i][POSX],LInfo[i][POSY],LInfo[i][POSZ],LInfo[i][LDistance],LInfo[i][World],DEFAULT_LABEL_VIEW_THREW_OBJECTS);
}
if(strcmp(color,"Green") == 0)
{
LInfo[i][Color] = llgreen;
LabelID[i] = Create3DTextLabel(LInfo[i][Text],LInfo[i][Color],LInfo[i][POSX],LInfo[i][POSY],LInfo[i][POSZ],LInfo[i][LDistance],LInfo[i][World],DEFAULT_LABEL_VIEW_THREW_OBJECTS);
}
if(strcmp(color,"Yellow") == 0)
{
LInfo[i][Color] = llyellow;
LabelID[i] = Create3DTextLabel(LInfo[i][Text],LInfo[i][Color],LInfo[i][POSX],LInfo[i][POSY],LInfo[i][POSZ],LInfo[i][LDistance],LInfo[i][World],DEFAULT_LABEL_VIEW_THREW_OBJECTS);
}
if(strcmp(color,"Blue") == 0)
{
LInfo[i][Color] = llblue;
LabelID[i] = Create3DTextLabel(LInfo[i][Text],LInfo[i][Color],LInfo[i][POSX],LInfo[i][POSY],LInfo[i][POSZ],LInfo[i][LDistance],LInfo[i][World],DEFAULT_LABEL_VIEW_THREW_OBJECTS);
}
if(strcmp(color,"Pink") == 0)
{
LInfo[i][Color] = llpink;
LabelID[i] = Create3DTextLabel(LInfo[i][Text],LInfo[i][Color],LInfo[i][POSX],LInfo[i][POSY],LInfo[i][POSZ],LInfo[i][LDistance],LInfo[i][World],DEFAULT_LABEL_VIEW_THREW_OBJECTS);
}
if(strcmp(color,"White") == 0)
{
LInfo[i][Color] = llwhite;
LabelID[i] = Create3DTextLabel(LInfo[i][Text],LInfo[i][Color],LInfo[i][POSX],LInfo[i][POSY],LInfo[i][POSZ],LInfo[i][LDistance],LInfo[i][World],DEFAULT_LABEL_VIEW_THREW_OBJECTS);
}
Labelcount++;
}
}
printf("Labels loaded: %i",Labelcount);
return 1;
}
Code:
... [10:01:13] Labels loaded: 10000 [10:01:13] Labels loaded: 10000 [10:01:13] Labels loaded: 10000 [10:01:13] Labels loaded: 10000 [10:01:13] Labels loaded: 10000 [10:01:13] Labels loaded: 10000 [10:01:13] Labels loaded: 10000 [10:01:13] Labels loaded: 10000 [10:01:13] Labels loaded: 10000 [10:01:13] Labels loaded: 10000 [10:01:13] Labels loaded: 10000 [10:01:13] Labels loaded: 10000 [10:01:13] Labels loaded: 10000 [10:01:13] Labels loaded: 10000 [10:01:13] Labels loaded: 10000 ...
pawn Code:
#define MAX_LABELS 5000
#define MAIN_DIALOG 2402
#define DEFAULT_LABEL_VIEW_THREW_OBJECTS 0
#define DEFAULT_LABEL_VIEW_DISTANCE 20.0
#define llgreen 0x00FF28FF
#define lldarkgreen 0x5FB700FF
#define lllightgreen 0x23FF00FF
#define llred 0xFF0000FF
#define llyellow 0xF5FF00FF
#define llpink 0xFF00FFC8
#define lldarkyellow 0xF5DE00FF
#define llorange 0xF5A300FF
#define lldarkblue 0x0037FFFF
#define llblue 0x1400FFFF
#define lllightblue 0x00FFF0FF
#define llgrey 0xB4B4B4FF
#define llwhite 0xF0F0F0FF
#define llpurple 0x9C00AFFF
#define lgreen1 "{6EF83C}"
#define lwhite1 "{FFFFFF}"
#define lyellow1 "{FFFF22}"
#define lblue1 "{2255FF}"
#define lpink1 "{FF00FF}"
#define lorange1 "{FF6622}"
#define lred1 "{FF0000}"
#define lyellow12 "{E1DE1C}"
enum labelsinfo
{
Text[256],
Color,
Float:POSX,
Float:POSY,
Float:POSZ,
Float:LDistance,
World
}
new Text3D:LInfo[MAX_LABELS][labelsinfo];
new Labelcount;
new Text3D:LabelID[MAX_LABELS];
new EditingLabel[MAX_PLAYERS] = -1;