Stuck at Query
#1

The server wont move onto OnAccountCreate, stops right there.


pawn Код:
public OnCheckEmail(playerid, username[],email[],password[]) {
    new rows, fields, msg[256];
    query[0] = 0;//[256];
    cache_get_data(rows, fields);
    if(rows < 1) {
        format(query,sizeof(query),"INSERT INTO `accounts` (`username`,`email`,`password`) VALUES(\"%s\",\"%s\",md5(\"%s\"));",username,email,password);
        mysql_function_query(g_mysql_handle, query, true, "onAccountCreate", "dd", playerid, mysql_insert_id());
        format(msg,sizeof(msg),"Registered2: %d | %s | %s | %s",playerid,username, email, password);
        printf(msg);
    } else {
        ShowPlayerDialog(playerid, _:EAccountDialog_EnterEmail, DIALOG_STYLE_INPUT, "Enter your email address", "Enter your email address.\n{FF0000}Notice{FFFFFF}: Make sure this is valid, or else you might not be able to reset your email!\n{FF0000}This email is in use! Enter another email!","Ok","Cancel");
    }
}
pawn Код:
public onAccountCreate(playerid, last_insert_id) {
   
    new msg[256], id = mysql_insert_id();
    if(id == 0 || id == last_insert_id) {
        SendClientMessage(playerid, X11_RED, "There was an error creating your account.");
        //TODO: LOG ERRORS
        Kick(playerid);
        return 0;
    }
    SetPVarInt(playerid,"AccountID",id);
    format(msg,sizeof(msg),"Registered2: %d | %d",playerid, id);
    printf(msg);
    #if debug
    new dbgmsg[128];
    format(dbgmsg,sizeof(dbgmsg),"[DBG]: Account ID: %d",id);
    SendClientMessage(playerid, X11_RED,dbgmsg);
    #endif
    ShowCharacterDialog(playerid);
    return 1;
}
Reply
#2

Are there any errors? You can use this to see errors

pawn Код:
public OnQueryError(errorid, error[], callback[], query[], connectionHandle)
{
    printf("======== MySQL ERROR =============");
    printf("%s",query);
    printf("%s",error);
    return 1;
}
Reply
#3

Try this:

pawn Код:
new lastInsertID; // at the top of your game mode

public OnCheckEmail(playerid, username[],email[],password[]) {
    new rows, fields;
    query[0] = 0;
    cache_get_data(rows, fields);
    if(rows < 1) {
        format(query,sizeof(query),"INSERT INTO `accounts` (`username`,`email`,`password`) VALUES(\"%s\",\"%s\",md5(\"%s\"));",username,email,password);
        mysql_function_query(g_mysql_handle, query, true, "onAccountCreate", "dd", playerid, lastInsertID);
        printf("Registered2: %d | %s | %s | %s", playerid, username, email, password);
    } else {
        ShowPlayerDialog(playerid, _:EAccountDialog_EnterEmail, DIALOG_STYLE_INPUT, "Enter your email address", "Enter your email address.\n{FF0000}Notice{FFFFFF}: Make sure this is valid, or else you might not be able to reset your email!\n{FF0000}This email is in use! Enter another email!","Ok","Cancel");
    }
}

public onAccountCreate(playerid, lastID) {
    new id = cache_insert_id();
    if(id == 0 || id == lastID) {
        SendClientMessage(playerid, X11_RED, "There was an error creating your account.");
        //TODO: LOG ERRORS
        Kick(playerid);
        return 0;
    }
    lastInsertID = id;
    SetPVarInt(playerid,"AccountID",id);
    printf("Registered2: %d | %d",playerid, id);
    #if debug
    new dbgmsg[128];
    format(dbgmsg,sizeof(dbgmsg),"[DBG]: Account ID: %d",id);
    SendClientMessage(playerid, X11_RED,dbgmsg);
    #endif
    ShowCharacterDialog(playerid);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)