SA-MP Forums Archive
Dynamic Label System [MYSQL || Problem] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Dynamic Label System [MYSQL || Problem] (/showthread.php?tid=440206)



Dynamic Label System [MYSQL || Problem] - zT KiNgKoNg - 28.05.2013

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;
}



Re: Dynamic Label System [MYSQL || Problem] - zT KiNgKoNg - 29.05.2013

Really needed!


Re: Dynamic Label System [MYSQL || Problem] - Konewka - 29.05.2013

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



Re: Dynamic Label System [MYSQL || Problem] - zT KiNgKoNg - 29.05.2013

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


Re: Dynamic Label System [MYSQL || Problem] - GiamPy. - 29.05.2013

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.


Re: Dynamic Label System [MYSQL || Problem] - zT KiNgKoNg - 29.05.2013

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]);



Re: Dynamic Label System [MYSQL || Problem] - GiamPy. - 29.05.2013

Could you please show me a screenshot of the table structure?
Also, can you please making a debug print of the variables: .. into the while iteration?


Re: Dynamic Label System [MYSQL || Problem] - zT KiNgKoNg - 29.05.2013

Structure.


And its not printing "Loading" in the while statement.


Re: Dynamic Label System [MYSQL || Problem] - GiamPy. - 29.05.2013

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


Re: Dynamic Label System [MYSQL || Problem] - zT KiNgKoNg - 29.05.2013

I am by the looks of it.