20.09.2012, 20:52
I'm trying to save a PVar but it just won't work. Here is my SQL method:
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:
And that message is not printed! I'd appreciate any help
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);
}
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;
}
