Services not saving
#1

Alright, well they are loading perfectly fine but they don't seem to be saving to the variables within the enum.
pawn Код:
enum sInfo
{
    sType,
    sFunds,
    sName[128],
}
new ServiceInfo[MAX_SERVICES][sInfo];
I have got the funds to save to the variable so they display perfectly well.

Although the type & name don't want to save, here are my codes.
pawn Код:
forward LoadServices();
public LoadServices()
{
    new
        line[512],
        placeholder
    ;
    mysql_query("SELECT * FROM services LIMIT " #MAX_SERVICES "");
    mysql_store_result();
    while(mysql_fetch_row_format(line))
    {
        new data[3];
        sscanf(line, "p<|>ddds[128]", placeholder, data[0], data[1], data[2]);
        print(line);
        ServiceInfo[services][sFunds] = data[0];
        ServiceInfo[services][sType] = data[1];
        ServiceInfo[services][sName] = data[2];
        services++;
        printf("DEBUG: %i Services Loaded.", services);
    }
    mysql_free_result();
}
I have been trying to get this working most of this morning and last night but still haven't got it to work correctly. Here are the logs.

Код:
[11:08:24] 1|150001|TESTING
[11:08:24] DEBUG: 1 Services Loaded.
As you can see they are loading correctly.

But when I do a debug command.
Код:
[11:08:35] SERVICES: , 0, $150001.
Which is very confusing.
Reply
#2

What's your debug command, can you show it?
Reply
#3

Yes.
pawn Код:
CMD:si(playerid, params[])
{
    for(new i=0; i<services; i++)
    {
        new str[256];
        format(str, sizeof(str), "SERVICES: %s, %d, $%d.", ServiceInfo[i][sName], ServiceInfo[i][sType], ServiceInfo[i][sFunds]);
        SendClientMessage(playerid, COLOR_RED, str);
        print(str);
    }
    return 1;
}
Reply
#4

The variable sName is a array, and you're setting the data as if it was a integer.

pawn Код:
stock LoadServices()
{
    new
        line[512],
        placeholder
    ;
    mysql_query("SELECT * FROM services LIMIT " #MAX_SERVICES "");
    mysql_store_result();
    while(mysql_fetch_row_format(line))
    {
        new data[3], sdata[ 128 ];
        sscanf(line, "p<|>ddds[128]", placeholder, data[0], data[1], sdata);
        print(line);
        ServiceInfo[services][sFunds] = data[0];
        ServiceInfo[services][sType] = data[1];
        strcat( ServiceInfo[services][sName], sdata );
        services++;
        printf("DEBUG: %i Services Loaded.", services);
    }
    mysql_free_result();
}
Reply
#5

That still isn't doing anything.
Reply
#6

I also noticed that your debugging code that printed the variable line is only loading three parameters, but you have four specifiers in sscanf.
Reply
#7

The first parameter is a placeholder.
Reply
#8

Quote:
Originally Posted by -Luis
Посмотреть сообщение
The first parameter is a placeholder.
The placeholder would also print if the SQL field actually existed. That's the reason why it isn't properly loading. Try this:

pawn Код:
sscanf(line, "p<|>dds[128]", data[0], data[1], sdata);
Reply
#9

Right now its just the name that isn't working, which is weird.
Reply
#10

Ah, fixed. you forgot to add "sizeof(sdata)". Thanks.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)