One 3D Text Label in particular is NOT loading -
LiamM - 09.02.2014
Hello, everyone.
I have my own scripted business / house system which works fine with no problems. Other than one little thing that I just can't seem to work out what's causing it.
When I restart my server, I have a function called under "OnGameModeInit" to search my MySQL database's business table and place the business pickups down, alongside the business label that is placed at the same coordinates as the business pickup icon.
Everything works fine! Every business has it's labels and pickups, except just one... That one business.. What confuses me is.. It actually places the pickup but fails to place the label after it? Yet the business before it and after it both load the label and pickup perfectly. So it's totally left me with no idea on what's causing this..
Here is a picture just to help get over what I'm talking about
:
As you can see from the picture, the business on the left (which is loaded right before the business on the right) has successfully had it's pickup and label loaded. Yet the one on the right, has somehow only managed to have it's pickup loaded.
Although it can't be seen in the picture, the business right after the one on the right, loads everything fine. It's this ONE and ONLY business. Here is the code below:
pawn Код:
BusLabel[i] = CreateDynamic3DTextLabel(labeltext, COLOR_SNOW, BusInfo[i][CPX], BusInfo[i][CPY], BusInfo[i][CPZ], 15.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);
BizzEnter[i] = CreateDynamicPickup(1272, 23, BusInfo[i][CPX], BusInfo[i][CPY], BusInfo[i][CPZ], -1, -1, -1, 100.0);
BusCount ++;
Note: I only just tried Dynamic 3D Text Labels / pickups thinking it might have been caused by too many labels in the near by vicinity, but after attempting this, it still didn't fix the issue.
Any suggestions would be
greatly appreciated. Thank you.
Re: One 3D Text Label in particular is NOT loading -
LiamM - 10.02.2014
Bump, been over 24 hours.
Re: One 3D Text Label in particular is NOT loading -
ikbenremco - 10.02.2014
Show us the entire Loadbusiness function.
Re: One 3D Text Label in particular is NOT loading -
LiamM - 10.02.2014
pawn Код:
//This is the call under OnGameModeInit
LoadBus()
{
new query[500];
for(new i = 1; i < MAX_BUS; i++)
{
format(query, sizeof(query), "SELECT * FROM `Business` WHERE BusID='%d'", i);
mysql_function_query(dbHandle, query, true, "BusLoad", "i", i);
}
return 1;
}
pawn Код:
public BusLoad(i)
{
new rows,
fields,
temp[100],
busname[128],
owner[32];
cache_get_data(rows, fields);
if(rows)
{
cache_get_row(0, 0, busname);
format(BusInfo[i][BusName], 128, "%s", busname);
cache_get_row(0, 1, temp), BusInfo[i][BusIncome] = strval(temp);
cache_get_row(0, 2, temp), BusInfo[i][Price] = strval(temp);
BusInfo[i][CPX] = cache_get_row_float(0, 3);
BusInfo[i][CPY] = cache_get_row_float(0, 4);
BusInfo[i][CPZ] = cache_get_row_float(0, 5);
cache_get_row(0, 6, temp), BusInfo[i][BusID] = strval(temp);
cache_get_row(0, 7, owner);
format(BusInfo[i][Owner], 32, "%s", owner);
BusInfo[i][iX] = cache_get_row_float(0, 8);
BusInfo[i][iY] = cache_get_row_float(0, 9);
BusInfo[i][iZ] = cache_get_row_float(0, 10);
cache_get_row(0, 11, temp), BusInfo[i][Owned] = strval(temp);
cache_get_row(0, 12, temp), BusInfo[i][cIDOwner] = strval(temp);
cache_get_row(0, 13, temp), BusInfo[i][Interior] = strval(temp);
cache_get_row(0, 14, temp), BusInfo[i][VirtualWorld] = strval(temp);
new labeltext[220];
if(BusInfo[i][Owned] == 0)
{
if(BusInfo[i][iX] > 0 && BusInfo[i][iZ] > 0 && BusInfo[i][iZ] > 0)
{
format(labeltext, sizeof(labeltext), "{00FF33}%s\n{FFFFFF}Price: {33FF00}${FFFFFF}%d\n{00FF33}For Sale!", BusInfo[i][BusName], BusInfo[i][Price]);
}
else if(BusInfo[i][iX] == 0 && BusInfo[i][iZ] == 0 && BusInfo[i][iZ] == 0)
{
format(labeltext, sizeof(labeltext), "{FF0000}%s\n{FFFFFF}Price: {33FF00}${FFFFFF}%d\n{00FF33}For Sale!", BusInfo[i][BusName], BusInfo[i][Price]);
}
}
else
{
if(BusInfo[i][iX] > 0 && BusInfo[i][iZ] > 0 && BusInfo[i][iZ] > 0)
{
format(labeltext, sizeof(labeltext), "{00FF33}%s\n{FFFFFF}Owned By: %s", BusInfo[i][BusName], BusInfo[i][Owner]);
}
else if(BusInfo[i][iX] == 0 && BusInfo[i][iZ] == 0 && BusInfo[i][iZ] == 0)
{
format(labeltext, sizeof(labeltext), "{FF0000}%s\n{FFFFFF}Owned By: %s", BusInfo[i][BusName], BusInfo[i][Owner]);
}
}
BusLabel[i] = CreateDynamic3DTextLabel(labeltext, COLOR_SNOW, BusInfo[i][CPX], BusInfo[i][CPY], BusInfo[i][CPZ], 15.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);
BizzEnter[i] = CreateDynamicPickup(1272, 23, BusInfo[i][CPX], BusInfo[i][CPY], BusInfo[i][CPZ], -1, -1, -1, 100.0);
BusCount ++;
}
return 1;
}
Everything loops perfectly and displays every 3D text label BUT that one on the screenshot. I have no idea why!
Re: One 3D Text Label in particular is NOT loading -
PowerPC603 - 10.02.2014
Try this:
pawn Код:
//This is the call under OnGameModeInit
LoadBus()
{
new query[500];
format(query, sizeof(query), "SELECT * FROM `Business`");
mysql_function_query(dbHandle, query, true, "BusLoad", "");
return 1;
}
public BusLoad()
{
new rows,
fields,
temp[100],
busname[128],
owner[32];
cache_get_data(rows, fields);
for (new i; i < rows; i++)
{
cache_get_row(i, 0, busname), format(BusInfo[i][BusName], 128, "%s", busname);
cache_get_row(i, 1, temp), BusInfo[i][BusIncome] = strval(temp);
cache_get_row(i, 2, temp), BusInfo[i][Price] = strval(temp);
BusInfo[i][CPX] = cache_get_row_float(i, 3);
BusInfo[i][CPY] = cache_get_row_float(i, 4);
BusInfo[i][CPZ] = cache_get_row_float(i, 5);
cache_get_row(i, 6, temp), BusInfo[i][BusID] = strval(temp);
cache_get_row(i, 7, owner), format(BusInfo[i][Owner], 32, "%s", owner);
BusInfo[i][iX] = cache_get_row_float(i, 8);
BusInfo[i][iY] = cache_get_row_float(i, 9);
BusInfo[i][iZ] = cache_get_row_float(i, 10);
cache_get_row(i, 11, temp), BusInfo[i][Owned] = strval(temp);
cache_get_row(i, 12, temp), BusInfo[i][cIDOwner] = strval(temp);
cache_get_row(i, 13, temp), BusInfo[i][Interior] = strval(temp);
cache_get_row(i, 14, temp), BusInfo[i][VirtualWorld] = strval(temp);
new labeltext[220];
if(BusInfo[i][Owned] == 0)
{
if((BusInfo[i][iX] > 0) && (BusInfo[i][iZ] > 0) && (BusInfo[i][iZ] > 0))
{
format(labeltext, sizeof(labeltext), "{00FF33}%s\n{FFFFFF}Price: {33FF00}${FFFFFF}%d\n{00FF33}For Sale!", BusInfo[i][BusName], BusInfo[i][Price]);
}
else if((BusInfo[i][iX] == 0) && (BusInfo[i][iZ] == 0) && (BusInfo[i][iZ] == 0))
{
format(labeltext, sizeof(labeltext), "{FF0000}%s\n{FFFFFF}Price: {33FF00}${FFFFFF}%d\n{00FF33}For Sale!", BusInfo[i][BusName], BusInfo[i][Price]);
}
}
else
{
if((BusInfo[i][iX] > 0) && (BusInfo[i][iZ] > 0) && (BusInfo[i][iZ] > 0))
{
format(labeltext, sizeof(labeltext), "{00FF33}%s\n{FFFFFF}Owned By: %s", BusInfo[i][BusName], BusInfo[i][Owner]);
}
else if((BusInfo[i][iX] == 0) && (BusInfo[i][iZ] == 0) && (BusInfo[i][iZ] == 0))
{
format(labeltext, sizeof(labeltext), "{FF0000}%s\n{FFFFFF}Owned By: %s", BusInfo[i][BusName], BusInfo[i][Owner]);
}
}
BusLabel[i] = CreateDynamic3DTextLabel(labeltext, COLOR_SNOW, BusInfo[i][CPX], BusInfo[i][CPY], BusInfo[i][CPZ], 15.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);
BizzEnter[i] = CreateDynamicPickup(1272, 23, BusInfo[i][CPX], BusInfo[i][CPY], BusInfo[i][CPZ], -1, -1, -1, 100.0);
BusCount ++;
}
return 1;
}
You were also using multiple queries where one would suffice.
Re: One 3D Text Label in particular is NOT loading -
LiamM - 11.02.2014
Quote:
Originally Posted by PowerPC603
Try this:
pawn Код:
//This is the call under OnGameModeInit
LoadBus() { new query[500];
format(query, sizeof(query), "SELECT * FROM `Business`"); mysql_function_query(dbHandle, query, true, "BusLoad", "");
return 1; }
public BusLoad() {
new rows, fields, temp[100], busname[128], owner[32];
cache_get_data(rows, fields);
for (new i; i < rows; i++) { cache_get_row(i, 0, busname), format(BusInfo[i][BusName], 128, "%s", busname); cache_get_row(i, 1, temp), BusInfo[i][BusIncome] = strval(temp); cache_get_row(i, 2, temp), BusInfo[i][Price] = strval(temp); BusInfo[i][CPX] = cache_get_row_float(i, 3); BusInfo[i][CPY] = cache_get_row_float(i, 4); BusInfo[i][CPZ] = cache_get_row_float(i, 5); cache_get_row(i, 6, temp), BusInfo[i][BusID] = strval(temp); cache_get_row(i, 7, owner), format(BusInfo[i][Owner], 32, "%s", owner); BusInfo[i][iX] = cache_get_row_float(i, 8); BusInfo[i][iY] = cache_get_row_float(i, 9); BusInfo[i][iZ] = cache_get_row_float(i, 10); cache_get_row(i, 11, temp), BusInfo[i][Owned] = strval(temp); cache_get_row(i, 12, temp), BusInfo[i][cIDOwner] = strval(temp); cache_get_row(i, 13, temp), BusInfo[i][Interior] = strval(temp); cache_get_row(i, 14, temp), BusInfo[i][VirtualWorld] = strval(temp);
new labeltext[220]; if(BusInfo[i][Owned] == 0) { if((BusInfo[i][iX] > 0) && (BusInfo[i][iZ] > 0) && (BusInfo[i][iZ] > 0)) { format(labeltext, sizeof(labeltext), "{00FF33}%s\n{FFFFFF}Price: {33FF00}${FFFFFF}%d\n{00FF33}For Sale!", BusInfo[i][BusName], BusInfo[i][Price]); } else if((BusInfo[i][iX] == 0) && (BusInfo[i][iZ] == 0) && (BusInfo[i][iZ] == 0)) { format(labeltext, sizeof(labeltext), "{FF0000}%s\n{FFFFFF}Price: {33FF00}${FFFFFF}%d\n{00FF33}For Sale!", BusInfo[i][BusName], BusInfo[i][Price]); } } else { if((BusInfo[i][iX] > 0) && (BusInfo[i][iZ] > 0) && (BusInfo[i][iZ] > 0)) { format(labeltext, sizeof(labeltext), "{00FF33}%s\n{FFFFFF}Owned By: %s", BusInfo[i][BusName], BusInfo[i][Owner]); } else if((BusInfo[i][iX] == 0) && (BusInfo[i][iZ] == 0) && (BusInfo[i][iZ] == 0)) { format(labeltext, sizeof(labeltext), "{FF0000}%s\n{FFFFFF}Owned By: %s", BusInfo[i][BusName], BusInfo[i][Owner]); } }
BusLabel[i] = CreateDynamic3DTextLabel(labeltext, COLOR_SNOW, BusInfo[i][CPX], BusInfo[i][CPY], BusInfo[i][CPZ], 15.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0); BizzEnter[i] = CreateDynamicPickup(1272, 23, BusInfo[i][CPX], BusInfo[i][CPY], BusInfo[i][CPZ], -1, -1, -1, 100.0);
BusCount ++; }
return 1; }
You were also using multiple queries where one would suffice.
|
Wow... That makes me feel so un-professional now, making a loop of queries to load the business'. Thank you for this code. It has no doubt educated me & at the same time it will be beneficial to me at a later point when I implement new systems.
However the problem still remains, all the business' loaded except that one label.. It really has me wondering what the hell is causing it. Any further suggestions?
Re: One 3D Text Label in particular is NOT loading -
PowerPC603 - 11.02.2014
Your checks to create the textlabels seem a bit odd.
pawn Код:
if(BusInfo[i][Owned] == 0)
{
if((BusInfo[i][iX] > 0) && (BusInfo[i][iZ] > 0) && (BusInfo[i][iZ] > 0))
{
format(labeltext, sizeof(labeltext), "{00FF33}%s\n{FFFFFF}Price: {33FF00}${FFFFFF}%d\n{00FF33}For Sale!", BusInfo[i][BusName], BusInfo[i][Price]);
}
else if((BusInfo[i][iX] == 0) && (BusInfo[i][iZ] == 0) && (BusInfo[i][iZ] == 0))
{
format(labeltext, sizeof(labeltext), "{FF0000}%s\n{FFFFFF}Price: {33FF00}${FFFFFF}%d\n{00FF33}For Sale!", BusInfo[i][BusName], BusInfo[i][Price]);
}
}
else
{
if((BusInfo[i][iX] > 0) && (BusInfo[i][iZ] > 0) && (BusInfo[i][iZ] > 0))
{
format(labeltext, sizeof(labeltext), "{00FF33}%s\n{FFFFFF}Owned By: %s", BusInfo[i][BusName], BusInfo[i][Owner]);
}
else if((BusInfo[i][iX] == 0) && (BusInfo[i][iZ] == 0) && (BusInfo[i][iZ] == 0))
{
format(labeltext, sizeof(labeltext), "{FF0000}%s\n{FFFFFF}Owned By: %s", BusInfo[i][BusName], BusInfo[i][Owner]);
}
}
The values iX, iY, iZ are floats (you load them with "cache_get_row_float"), but you check them as if they were integers.
Even if you set them to 0, there is a chance due to binary limitations to represent floats accurately that those values won't be exactly 0.0000000000000...
It could be -0.0000000000000000000001 and your code to create the textlabels won't work, as you only check if it's higher than 0, or exactly equal to 0.
For any negative value (how small it may be), your textlabel won't be created and your textlabel won't show up as the labeltext is empty.
You can try to use printf to print those values to the server console to see if there is any value negative.
You can also print the labeltext to see if there is any business without a labeltext (which would explain why you don't see the label).
pawn Код:
BusInfo[i][iX] = cache_get_row_float(i, 8);
BusInfo[i][iY] = cache_get_row_float(i, 9);
BusInfo[i][iZ] = cache_get_row_float(i, 10);
printf("BusInfo[%i][iX] = %f", i, BusInfo[i][iX]);
printf("BusInfo[%i][iY] = %f", i, BusInfo[i][iY]);
printf("BusInfo[%i][iZ] = %f", i, BusInfo[i][iZ]);
// Other code
printf("LabelText: %s", labeltext);
BusLabel[i] = CreateDynamic3DTextLabel(labeltext, COLOR_SNOW, BusInfo[i][CPX], BusInfo[i][CPY], BusInfo[i][CPZ], 15.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);
BizzEnter[i] = CreateDynamicPickup(1272, 23, BusInfo[i][CPX], BusInfo[i][CPY], BusInfo[i][CPZ], -1, -1, -1, 100.0);
Re: One 3D Text Label in particular is NOT loading -
LiamM - 11.02.2014
Quote:
Originally Posted by PowerPC603
Your checks to create the textlabels seem a bit odd.
pawn Код:
if(BusInfo[i][Owned] == 0) { if((BusInfo[i][iX] > 0) && (BusInfo[i][iZ] > 0) && (BusInfo[i][iZ] > 0)) { format(labeltext, sizeof(labeltext), "{00FF33}%s\n{FFFFFF}Price: {33FF00}${FFFFFF}%d\n{00FF33}For Sale!", BusInfo[i][BusName], BusInfo[i][Price]); } else if((BusInfo[i][iX] == 0) && (BusInfo[i][iZ] == 0) && (BusInfo[i][iZ] == 0)) { format(labeltext, sizeof(labeltext), "{FF0000}%s\n{FFFFFF}Price: {33FF00}${FFFFFF}%d\n{00FF33}For Sale!", BusInfo[i][BusName], BusInfo[i][Price]); } } else { if((BusInfo[i][iX] > 0) && (BusInfo[i][iZ] > 0) && (BusInfo[i][iZ] > 0)) { format(labeltext, sizeof(labeltext), "{00FF33}%s\n{FFFFFF}Owned By: %s", BusInfo[i][BusName], BusInfo[i][Owner]); } else if((BusInfo[i][iX] == 0) && (BusInfo[i][iZ] == 0) && (BusInfo[i][iZ] == 0)) { format(labeltext, sizeof(labeltext), "{FF0000}%s\n{FFFFFF}Owned By: %s", BusInfo[i][BusName], BusInfo[i][Owner]); } }
The values iX, iY, iZ are floats (you load them with "cache_get_row_float"), but you check them as if they were integers.
Even if you set them to 0, there is a chance due to binary limitations to represent floats accurately that those values won't be exactly 0.0000000000000...
It could be -0.0000000000000000000001 and your code to create the textlabels won't work, as you only check if it's higher than 0, or exactly equal to 0.
For any negative value (how small it may be), your textlabel won't be created and your textlabel won't show up as the labeltext is empty.
You can try to use printf to print those values to the server console to see if there is any value negative.
You can also print the labeltext to see if there is any business without a labeltext (which would explain why you don't see the label).
pawn Код:
BusInfo[i][iX] = cache_get_row_float(i, 8); BusInfo[i][iY] = cache_get_row_float(i, 9); BusInfo[i][iZ] = cache_get_row_float(i, 10); printf("BusInfo[%i][iX] = %f", i, BusInfo[i][iX]); printf("BusInfo[%i][iY] = %f", i, BusInfo[i][iY]); printf("BusInfo[%i][iZ] = %f", i, BusInfo[i][iZ]);
// Other code
printf("LabelText: %s", labeltext); BusLabel[i] = CreateDynamic3DTextLabel(labeltext, COLOR_SNOW, BusInfo[i][CPX], BusInfo[i][CPY], BusInfo[i][CPZ], 15.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0); BizzEnter[i] = CreateDynamicPickup(1272, 23, BusInfo[i][CPX], BusInfo[i][CPY], BusInfo[i][CPZ], -1, -1, -1, 100.0);
|
Well you're right they are floats, but I generally check them to be over 0... 0.000000 still would if rounded off equal zero. I have thought this was the issue but. All this does is checks it the business has an interior, and if it does. The name of the business on the 3DTextLabel is
green, and if it doesn't. The name is
red.
All business' work the way they are meant to in game, even though the interior check is equal to zero as opposed to 0.00000. The labels show in the correct format with the correct colors, except this one business. Which has an interior but it fails to show it. HOWEVER. As I was typing this, I just realized it only prints it if the coordinates are
OVER 0.
The coordinates for that interior are in the negatives, making that the issue! You know! After this extensive trial and error. Without even testing it.. I think that is why it's having this issue.
It only shows a label for interiors with coordinates that are positive. Changing those to > 0 || < 0. Probably would be the best bet.. or > 0.0000000 || < 0.00000000 to be on the safe side.
Thank You! You're being repped! Appreciate the help, man!
Re: One 3D Text Label in particular is NOT loading -
PowerPC603 - 11.02.2014
Np, glad to be of assistance.
Re: One 3D Text Label in particular is NOT loading -
LiamM - 11.02.2014
Quote:
Originally Posted by PowerPC603
Np, glad to be of assistance.
|
You have been a great hand to me, I've been trying to resolve this issue for quite a while now, and to be honest... I don't know how I never noticed that.. I scripted this system myself and normally I don't look over stuff like that, but then again.. It's always the small things that trip you up.
P.S. Here's the photo! Thank you, man