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;
}
// An example:
playerVariables[playerid][pInternalID] = cache_get_row_int(0, 0);
// Instead of:
cache_get_row(0, 0, szQueryOutput); // pInternalID
playerVariables[playerid][pInternalID] = strval(szQueryOutput);
Lines don't matter! What would you prefer, something that is done faster but has few more lines or the opposite?!
By the way, you can reduce the lines by using cache_get_row_(int/float). pawn Код:
|
Those functions aren't in R7. You can however refer to this to get cache_get_row_int:
http://forum.sa-mp.com/showpost.php?...&postcount=935 |
* Added cache_get_row_int and cache_get_row_float. * More security added to internal string handling to prevent buffer overflows. * Fixed crash issue on gamemode restart (gmx). * A few more internal issues cleared up. |