Sscanfiy this - Code Help
#1

Hi

I don't see lots of lines like this in others code. Is there an easier way of setting the DB data into the playerVariables enum maybe using sscanf.

Help please!

pawn Код:
public LoadPlayerData(playerid, account[])
{
    new rows, fields;
    cache_get_data(rows, fields);

    if(rows) {

        cache_get_row(0, 0, szQueryOutput); // pInternalID
        playerVariables[playerid][pInternalID] = strval(szQueryOutput);
       
        playerVariables[playerid][pLogged] = 1;
       
        cache_get_row(0, 3, szQueryOutput);
        playerVariables[playerid][pSkin] =  strval(szQueryOutput);
       
        cache_get_row(0, 4, szQueryOutput);
        playerVariables[playerid][pMoney] = strval(szQueryOutput);
       
        cache_get_row(0, 5, szQueryOutput);
        playerVariables[playerid][pBank] = strval(szQueryOutput);
       
        cache_get_row(0, 6, szQueryOutput);
        playerVariables[playerid][pSpawnX] = floatstr(szQueryOutput);
       
        cache_get_row(0, 7, szQueryOutput);
        playerVariables[playerid][pSpawnY] = floatstr(szQueryOutput);
       
        cache_get_row(0, 8, szQueryOutput);
        playerVariables[playerid][pSpawnZ] = floatstr(szQueryOutput);
       
        cache_get_row(0, 9, szQueryOutput);
        playerVariables[playerid][pSpawnA] = floatstr(szQueryOutput);
       
        cache_get_row(0, 10, szQueryOutput);
        playerVariables[playerid][pWs1] = strval(szQueryOutput);
       
        cache_get_row(0, 11, szQueryOutput);
        playerVariables[playerid][pWa1] = strval(szQueryOutput);
       
        cache_get_row(0, 12, szQueryOutput);
        playerVariables[playerid][pWs2] = strval(szQueryOutput);
       
        cache_get_row(0, 13, szQueryOutput);
        playerVariables[playerid][pWa2] = strval(szQueryOutput);
       
        cache_get_row(0, 14, szQueryOutput);
        playerVariables[playerid][pWs3] = strval(szQueryOutput);
       
        cache_get_row(0, 15, szQueryOutput);
        playerVariables[playerid][pWa3] = strval(szQueryOutput);
       
        cache_get_row(0, 16, szQueryOutput);
        playerVariables[playerid][pHasDrivingLicence] = strval(szQueryOutput);
       
        cache_get_row(0, 17, szQueryOutput);
        playerVariables[playerid][pHasBoatLicence] = strval(szQueryOutput);
       
        cache_get_row(0, 18, szQueryOutput);
        playerVariables[playerid][pHasPilotLicence] = strval(szQueryOutput);
       
        cache_get_row(0, 19, szQueryOutput);
        playerVariables[playerid][pHasFishingLicence] = strval(szQueryOutput);
       
       
        SetSpawnInfo(playerid,0,playerVariables[playerid][pSkin],playerVariables[playerid][pSpawnX],playerVariables[playerid][pSpawnY],playerVariables[playerid][pSpawnZ],playerVariables[playerid][pSpawnA],-1,-1,-1,-1,-1,-1);
        SpawnPlayer(playerid);
        GivePlayerMoney(playerid,playerVariables[playerid][pMoney]);

        format(szString, sizeof(szString), "[SERVER]: Welcome back to Bayside RP, %s! Please follow the rules.", account);
        SendClientMessage(playerid, COLOR_GREEN, szString);
       
        TogglePlayerSpectating(playerid, false);
    }
    else
    {
        format(szString, sizeof(szString), "{FF0000}Sorry, %s!", account);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, szString, "{FF0000}The password is WRONG!\n{FFFFFF}Enter your password below:", "Login", "Cancel");
    }

    return 1;
}
Reply


Messages In This Thread
Sscanfiy this - Code Help - by liam1412 - 02.04.2013, 13:00
Re: Sscanfiy this - Code Help - by Konstantinos - 02.04.2013, 13:04
Re: Sscanfiy this - Code Help - by SuperViper - 02.04.2013, 14:09
Re: Sscanfiy this - Code Help - by Konstantinos - 02.04.2013, 14:13
Re: Sscanfiy this - Code Help - by SuperViper - 02.04.2013, 14:17
Re: Sscanfiy this - Code Help - by Konstantinos - 02.04.2013, 14:22
Re: Sscanfiy this - Code Help - by liam1412 - 02.04.2013, 17:33
Re: Sscanfiy this - Code Help - by MP2 - 02.04.2013, 19:13
Re: Sscanfiy this - Code Help - by Vince - 02.04.2013, 19:28

Forum Jump:


Users browsing this thread: 4 Guest(s)