Need help with mysql based gamemode.
#1

Hello,

I am having issues with a gamemode (not going to tell it's name) and it has a character system.
When a player connects to the server, a registration or login dialog appears. When the player registrate an account, they are able to create a character. That works fine, everything is stored in the database, but when the player logs off and connects to the server, they get the login dialog and then the server crashes. I debugged everything using printf, and I found out that when the character selection function is called, that the server crashes.

This is the function what's bugging:

pawn Код:
public OnLoadCharacters(playerid) {
    printf("[ACCOUNT.PWN] OnLoadCharacters called.");
    new rows,fields;
    cache_get_data(rows,fields);
    printf("[ACCOUNT.PWN] OLC: Stage 1. (NumCharacters)");
    //GetPVarInt(playerid, "NumCharacters", rows);
    SetPVarInt(playerid, "NumCharacters", rows);
    new pvarname[32];
    new fielddata[64];
    new charid;
    for(new i=0;i<rows;i++) {
        cache_get_row(i,0,fielddata);
        format(pvarname,sizeof(pvarname),"CharUsername%d",i);
        SetPVarString(playerid,pvarname,fielddata);
        format(pvarname,sizeof(pvarname),"CharID%d",i);
        cache_get_row(i,1,fielddata);
        charid = strval(fielddata);
        SetPVarInt(playerid,pvarname,charid);
    }
    printf("[ACCOUNT.PWN] OLC: Stage 2. (ShowCharacterDialog)");
    ShowCharacterDialog(playerid);
    printf("[ACCOUNT.PWN] OLC: Stages ended.");
    printf("[ACCOUNT.PWN] OnLoadChoaracters loaded.");
    return 1;
}
This is the server log with the debugging:
Код:
[13:43:20] Incoming connection: [IP HERE]
[13:43:21] [join] Sidney_Hoekstra has joined the server (0:[IP HERE])
[13:43:21] [CRP.PWN] OnPlayerConnect function loaded succesfully.
[13:43:21] [ACCOUNT.PWN] ShowLoginDialog function called.
[13:43:21] [ACCOUNT.PWN] SLD: Stage 1.
[13:43:21] [ACCOUNT.PWN] ShowLoginDialog function loaded.
[13:43:30] [ACCOUNT.PWN] OnLoginAttempt called.
[13:43:30] [ACCOUNT.PWN] OLA: Stage 1. (LoginAttempts called)
[13:43:30] [ACCOUNT.PWN] OLA: Stage 4. (Succesful login)
[13:43:30] [ACCOUNT.PWN] OLA: Stage 5. (NewbieRank)
[13:43:30] [ACCOUNT.PWN] OLA: Stage 6. (ConnectTime)
[13:43:30] [ACCOUNT.PWN] OLA: Stage 7. (AdminTitle)
[13:43:30] [ACCOUNT.PWN] OLA: Stage 8. (AdminFlags)
[13:43:30] [ACCOUNT.PWN] OLA: Stage 9. (NewbieRank)
[13:43:30] [ACCOUNT.PWN] OLA: Stage 10. (AdminFlags, NewbieRank)
[13:43:30] [ACCOUNT.PWN] OLA: Stage 11. (DonatePoints)
[13:43:30] [ACCOUNT.PWN] OLA: Stage 12. (DonateRank)
[13:43:30] [ACCOUNT.PWN] OLA: Stage 13. (Cookies)
[13:43:30] [ACCOUNT.PWN] OLA: Stage 15. (NMuteTime)
[13:43:30] [ACCOUNT.PWN] OLA: Stage 16. (NMuteTime)
[13:43:30] [ACCOUNT.PWN] OLA: Stage 16. (ReportBanned)
[13:43:30] [ACCOUNT.PWN] OLA: Stage 17. (AccountFlags)
[13:43:30] [ACCOUNT.PWN] OLA: Stage 18. (OnPlayerLogin called)
[13:43:30] [ACCOUNT.PWN] OnPlayerLogin called.
[13:43:30] [ACCOUNT.PWN] OnPlayerLogin: Weapon skills loaded.
[13:43:30] [ACCOUNT.PWN] OnPlayerLogin: LoadCharacters being called.
[13:43:30] [ACCOUNT.PWN] LoadCharacters called.
[13:43:30] [ACCOUNT.PWN] LC: Stage 1.
[13:43:30] [ACCOUNT.PWN] LC: Stage 3.
[13:43:30] [ACCOUNT.PWN] LC: Stage 4.
[13:43:30] [ACCOUNT.PWN] LC: Stage 5.
[13:43:30] [ACCOUNT.PWN] LoadCharacters loaded.
[13:43:30] [ACCOUNT.PWN] OnPlayerLogin loaded.
[13:43:30] [ACCOUNT.PWN] OLA: Stages ended.
[13:43:30] [ACCOUNT.PWN] OnLoginAttempt loaded.
Then the function "OnLoadCharacters(playerid)" must be called, and it doesn't.

//EDIT: This is the function calling "OnLoadCharacters(playerid)", it's the only one:
pawn Код:
LoadCharacters(playerid, bool:showdialog) {
    printf("[ACCOUNT.PWN] LoadCharacters called.");
    //#pragma unused showdialog
    query[128] = 0;//[128];
    printf("[ACCOUNT.PWN] LC: Stage 1.");
    new accountid = GetPVarInt(playerid,"AccountID");
    if(accountid == 0) {
        printf("[ACCOUNT.PWN] LC: Stage 2.");
        return 0;
    }
    printf("[ACCOUNT.PWN] LC: Stage 3.");
    format(query, sizeof(query),"SELECT `username`,`id` FROM `characters` WHERE `accountid` = %d",accountid);
    printf("[ACCOUNT.PWN] LC: Stage 4.");
    mysql_function_query(g_mysql_handle, query, true, "OnLoadCharacters", "d", playerid);
    printf("[ACCOUNT.PWN] LC: Stage 5.");
    printf("[ACCOUNT.PWN] LoadCharacters loaded.");
    return 1;
}
Thanks in advance.
Reply
#2

Well, the fact that "[ACCOUNT.PWN] OnLoadCharacters called." never shows up would incline me to believe we need to see the function actually calling this.

Could we please see that?
Reply
#3

Sure, here you go:

pawn Код:
LoadCharacters(playerid, bool:showdialog) {
    printf("[ACCOUNT.PWN] LoadCharacters called.");
    //#pragma unused showdialog
    query[128] = 0;//[128];
    printf("[ACCOUNT.PWN] LC: Stage 1.");
    new accountid = GetPVarInt(playerid,"AccountID");
    if(accountid == 0) {
        printf("[ACCOUNT.PWN] LC: Stage 2.");
        return 0;
    }
    printf("[ACCOUNT.PWN] LC: Stage 3.");
    format(query, sizeof(query),"SELECT `username`,`id` FROM `characters` WHERE `accountid` = %d",accountid);
    printf("[ACCOUNT.PWN] LC: Stage 4.");
    mysql_function_query(g_mysql_handle, query, true, "OnLoadCharacters", "d", playerid);
    printf("[ACCOUNT.PWN] LC: Stage 5.");
    printf("[ACCOUNT.PWN] LoadCharacters loaded.");
    return 1;
}
Reply
#4

No one who can help me? I appreciate any help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)