Dynamic Label System [MYSQL || Problem]
#1

Hey guys for some reason the dynamic lables are not showing up when the server loads, Its says and defined that there aren't any in the database when there's three, I don't know if this is a sscanf error or its just not loading correctly


pawn Код:
enum DynamicLables {

    DynamicLableID,
    Float: DL_X,
    Float: DL_Y,
    Float: DL_Z,
    DL_String[500]
};


new DL_Data[MAX_DYNAMIC_LABLES][DynamicLables];
new Text3D:DL_Set[MAX_DYNAMIC_LABLES];
new LableCount;
Loading
pawn Код:
public CreateDynamicLables()
{
    new LableID,FetchRow[300];
   
    format(Query, sizeof(Query), "SELECT * FROM `dynamiclabels`");
    mysql_query(Query);
    mysql_store_result();
    LableID = mysql_num_rows();
    //DL_Data[LableID][]
   
    if(LableID > 0)
    {
        while(mysql_fetch_row(FetchRow))
        {
            //DynamicLableID
            sscanf(FetchRow, "p<|>dfffs[300]>", DL_Data[LableID]);
            DL_Set[LableID] = CreateDynamic3DTextLabel(DL_Data[LableID][DL_String], 0xFFFFFF, DL_Data[LableID][DL_X], DL_Data[LableID][DL_Y], DL_Data[LableID][DL_Z], 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100);
            LableID++;
            LableCount ++;
        }
        mysql_free_result();
       
    } else {
   
        print("No Dynamic Lables were created, Make some ingame");
   
    }

    return 1;
}
Reply
#2

Really needed!
Reply
#3

pawn Код:
format(Query, sizeof(Query), "SELECT * FROM `dynamiclabels`");
    mysql_query(Query);
pawn Код:
format(FetchRow, sizeof(FetchRow), "SELECT * FROM `dynamiclabels`");
    mysql_query(FetchRow);
Reply
#4

Didn't work because i changed it to Query already!
Reply
#5

First of all, I suggest you to switch over threaded callbacks and cached functions provided by BlueG MySQL plugin. The way you're making the script extremely inefficient.

Anyway, you're not loading the data at all.

pawn Код:
sscanf(FetchRow, "p<|>dfffs[300]>", DL_Data[LableID]);
You are only loading the first "d" (integer) value in DL_Data[LableID] - also not properly.
The four remaining values are parsed properly but they are not loaded in each variable.

This way should make it work:

pawn Код:
sscanf(FetchRow, "p<|>dfffs[300]>", DL_Data[LableID][DynamicLableID], DL_Data[LableID][DL_X], DL_Data[LableID][DL_Y], DL_Data[LableID][DL_String]);
Also, you've chosen to parse the string with an array of 300 instead of 500, as you defined in your enum. That doesn't make any sense. It's just better if you change both arrays to 128 which is the maximum length of a string.
Reply
#6

Well thats funny, Because its still not loading the three dynamic lables in the database, And there is three in the database. So far nothing is working.

Updated Code (Pretty much the same way i load all the player data with e<>)
pawn Код:
public CreateDynamicLables()
{
    new LableID;
   
    format(Query, sizeof(Query), "SELECT * FROM  `dynamiclabels`");
    mysql_query(Query);
    mysql_store_result();
    LableID = mysql_num_rows();
    //DL_Data[LableID][]
   
    if(LableID > 0)
    {
        while(mysql_fetch_row_format(Query,"|"))
        {
            //DynamicLableID
            sscanf(Query, "e<p<|>dfffs[300]>", DL_Data[LableID]);
            DL_Set[LableID] = CreateDynamic3DTextLabel(DL_Data[LableID][DL_String], 0xFFFFFF, DL_Data[LableID][DL_X], DL_Data[LableID][DL_Y], DL_Data[LableID][DL_Z], 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100);
            LableID++;
            LableCount ++;
        }
        mysql_free_result();
        printf("%i Dynamic Lables Created", LableCount);
       
    } else {
        printf("%i Dynamic Lables Created",0);
    }
    return 1;
}
Player Data
pawn Код:
sscanf(Query, "e<p<|>is[100]s[100]s[100]s[100]fffdids[100]ididi>", pData[playerid]);
Reply
#7

Could you please show me a screenshot of the table structure?
Also, can you please making a debug print of the variables:
  • DL_Data[LableID][DynamicLableID]
  • DL_Data[LableID][DL_X]
  • DL_Data[LableID][DL_Y]
  • DL_Data[LableID][DL_String]
.. into the while iteration?
Reply
#8

Structure.


And its not printing "Loading" in the while statement.
Reply
#9

You're saying that the while iteration is never executed?
Reply
#10

I am by the looks of it.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)