PVar not saving
#1

I'm trying to save a PVar but it just won't work. Here is my SQL method:
pawn Код:
forward CheckCharExists_handle(playerid);
public CheckCharExists_handle(playerid) {
    new rows, fields;
    cache_get_data(rows, fields);
    printf("r: %d", rows);
    if(rows > 0) {
        SetPVarInt(playerid, "CharFound", 1);
    } else {
        SetPVarInt(playerid, "CharFound", 0);
    }
    printf("cf: %d", GetPVarInt(playerid, "CharFound"));
}

CheckCharExists(playerid, char_name[])
{
    new string[128];
    CheckMySQL();
    format(string, sizeof(string), "SELECT * FROM characters WHERE Name='%s'", char_name);
    mysql_function_query(dbHandle, string, true, "CheckCharExists_handle", "i", playerid);
}
As you can see, it sets the PVar depending on if there are any rows. "cf" and "r" are both printed in the console, and both say "1". I call the CheckCharExists method, and then after that I call the RegisterPlayer method, but I have this in RegisterPlayer:
pawn Код:
if(GetPVarInt(playerid, "CharFound") == 1) {
        return SendClientMessage(playerid, COLOR_GREY, "That character name is already registered."),
               ShowPlayerDialog(playerid, REGISTER_CHARACTER_DIALOG, DIALOG_STYLE_INPUT, "Character Name", "Please enter your desired character name below.", "Register", ""),
               1;
    }
And that message is not printed! I'd appreciate any help
Reply
#2

Alright, i'll add a lot of debugging lines I used a normal variable and got the same problem, though.
Reply
#3

Alright, i'll add a lot of debugging lines I used a normal variable and got the same problem, though.
Reply
#4

The pvar was saving, but the query was not completing until after the check and so it would equal 0 when checked and would only be set afterwards :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)