Businesses system [MySQL]
#1

Hello guys, I've a problem with my businesses system which I'm trying to create right now.

Here's a code for uploading data from database to server:
pawn Код:
stock IkeltiVerslus()
{
    mysql_query(1, "SELECT * FROM verslai"); // selects everything from businesses table
    mysql_store_result();
    new rez[256], s[256], i = 0;
    while(mysql_fetch_row_format(rez, "|")) // loops through every row in database and writes the data to the bussines enum
    {
        i++;
        mysql_get_field("ID", rez);                     vInfo[i][ID] = strval(rez);
        mysql_get_field("owner", vInfo[i][Owner]);
        mysql_get_field("name", vInfo[i][Name]);
        mysql_get_field("extx", rez);                   vInfo[i][exterior][0] = floatstr(rez);
        mysql_get_field("exty", rez);                   vInfo[i][exterior][1] = floatstr(rez);
        mysql_get_field("extz", rez);                   vInfo[i][exterior][2] = floatstr(rez);
        mysql_get_field("intx", rez);                   vInfo[i][interior][0] = floatstr(rez);
        mysql_get_field("inty", rez);                   vInfo[i][interior][1] = floatstr(rez);
        mysql_get_field("intz", rez);                   vInfo[i][interior][2] = floatstr(rez);
        mysql_get_field("bought", rez);                 vInfo[i][bought] = strval(rez);
        mysql_get_field("inter", rez);                  vInfo[i][inter] = strval(rez);
        if(vInfo[i][bought] == 1) // if business is bought, in label is written title of business and owner name
        {
            format(s, sizeof(s), "%s\n{15FF0F}Savininkas: {FFFFFF}%s\n{B36666}Spauskite ENTER noredami ieiti", vInfo[i][Name], vInfo[i][Owner]);
            vInfo[i][labelid] = Create3DTextLabel(s, COLOR_CYAN, vInfo[i][exterior][0],vInfo[i][exterior][1],vInfo[i][exterior][2], 40, 0, 1);
        }
        else // else there's written that business has the name "---" and no owner
        {
            format(s, sizeof(s), "---\n{15FF0F}Savininkas: {FFFFFF}Vyriausybe\n{B36666}Spauskite ENTER noredami ieiti");
            vInfo[i][labelid] = Create3DTextLabel(s, COLOR_CYAN, vInfo[i][exterior][0],vInfo[i][exterior][1],vInfo[i][exterior][2], 40, 0, 1);
        }
    }
    mysql_free_result();
}
Now when I put this stock under OnGameModeInit(); :
pawn Код:
public OnGameModeInit()
{
    IkeltiVerslus();
        //................ other stuff
}
It doesn't execute anything under this function (doesn't create any objects, other labels etc.) and doesn't execute itself (don't load any labels and businesses).

+rep for helper
Reply
#2

Well, do you have any businesses created?

As the code shown above only create(s) labels/text draws when a business is created.
Reply
#3

You mean in database?
If yes, then yes.

I created 3 businesses and in each row there are exterior pos, interior pos, everything that i load
Reply
#4

Why don't you use latest version of the MySQL? Also add prints everywhere, to make sure, where the scripts stops, what is being executed and what isn't.

-cut-
Reply
#5

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
Why don't you use latest version of the MySQL? Also add prints everywhere, to make sure, where the scripts stops, what is being executed and what isn't.

-cut-
Ok, looks like when I start GM it doesn't react to that stock, because I haven't recieved any prints.
Reply
#6

Fixed myself.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)