Eu uso a include do Gammix's (easydb.inc)
para salvar
PHP код:
stock SaveData(playerid)
{
new key = DB::RetrieveKey(gGlobal[TKT_UserTable], "username", tkPlayerName(playerid));
if(key != DB_INVALID_KEY)
{
if(GetPVarInt(playerid, "TKAdmin_Loggedin") != PLAYER_VARTYPE_NONE)
{
new DATE[18], date[3];
getdate(date[0], date[1], date[2]);
format(DATE, sizeof(DATE), "%i/%i/%i", date[2], date[1], date[0]);
GetPlayerConnectedTime(playerid, tkUSER[playerid][TKU_Hours], tkUSER[playerid][TKU_Minutes], tkUSER[playerid][TKU_Seconds]);
DB::SetStringEntry(gGlobal[TKT_UserTable],key, "laston", DATE);
DB::SetIntEntry(gGlobal[TKT_UserTable], key, "kicked", tkUSER[playerid][TKU_Kicked]);
DB::SetIntEntry(gGlobal[TKT_UserTable], key, "jailed", tkUSER[playerid][TKU_Jailed]);
DB::SetIntEntry(gGlobal[TKT_UserTable], key, "jailtime", tkUSER[playerid][TKU_JailedTime]);
DB::SetIntEntry(gGlobal[TKT_UserTable], key, "muted", tkUSER[playerid][TKU_Muted]);
DB::SetIntEntry(gGlobal[TKT_UserTable], key, "mutetime", tkUSER[playerid][TKU_MutedTime]);
DB::SetIntEntry(gGlobal[TKT_UserTable], key, "cmuted", tkUSER[playerid][TKU_CMuted]);
DB::SetIntEntry(gGlobal[TKT_UserTable], key, "cmutetime", tkUSER[playerid][TKU_CMuteTime]);
DB::SetIntEntry(gGlobal[TKT_UserTable], key, "cash", tkUSER[playerid][TKU_Cash]);
DB::SetIntEntry(gGlobal[TKT_UserTable], key, "level", tkUSER[playerid][TKU_pLevel]);
DB::SetIntEntry(gGlobal[TKT_UserTable], key, "kills", tkUSER[playerid][TKU_Kills]);
DB::SetIntEntry(gGlobal[TKT_UserTable], key, "deaths", tkUSER[playerid][TKU_Deaths]);
DB::SetIntEntry(gGlobal[TKT_UserTable], key, "score", GetPlayerScore(playerid));
DB::SetIntEntry(gGlobal[TKT_UserTable], key, "money", GetPlayerMoney(playerid));
DB::SetIntEntry(gGlobal[TKT_UserTable], key, "hours", tkUSER[playerid][TKU_Hours]);
DB::SetIntEntry(gGlobal[TKT_UserTable], key, "minutes", tkUSER[playerid][TKU_Minutes]);
DB::SetIntEntry(gGlobal[TKT_UserTable], key, "seconds", tkUSER[playerid][TKU_Seconds]);
}
}
return 1;
}
para carregar
PHP код:
new key = DB::RetrieveKey(gGlobal[TKT_UserTable], "username", tkPlayerName(playerid));
new hash[65];
DB::Hash(hash, sizeof(hash), inputtext);
new password[128];
DB::GetStringEntry(gGlobal[TKT_UserTable], key, "password", password);
if(! strcmp(hash, password))
{
tkUSER[playerid][TKU_Kicked] = DB::GetIntEntry(gGlobal[TKT_UserTable], key, "kicked");
tkUSER[playerid][TKU_Admin] = DB::GetIntEntry(gGlobal[TKT_UserTable], key, "admin");
tkUSER[playerid][TKU_VIP] = DB::GetIntEntry(gGlobal[TKT_UserTable], key, "vip");
tkUSER[playerid][TKU_Kills] = DB::GetIntEntry(gGlobal[TKT_UserTable], key, "kills");
tkUSER[playerid][TKU_Deaths] = DB::GetIntEntry(gGlobal[TKT_UserTable], key, "deaths");
tkUSER[playerid][TKU_Score] = DB::GetIntEntry(gGlobal[TKT_UserTable], key, "score");
tkUSER[playerid][TKU_Money] = DB::GetIntEntry(gGlobal[TKT_UserTable], key, "money");
tkUSER[playerid][TKU_Hours] = DB::GetIntEntry(gGlobal[TKT_UserTable], key, "hours");
tkUSER[playerid][TKU_Minutes] = DB::GetIntEntry(gGlobal[TKT_UserTable], key, "minutes");
tkUSER[playerid][TKU_Seconds] = DB::GetIntEntry(gGlobal[TKT_UserTable], key, "seconds");
tkUSER[playerid][TKU_Jailed] = DB::GetIntEntry(gGlobal[TKT_UserTable], key, "jailed");
tkUSER[playerid][TKU_pLevel] = DB::GetIntEntry(gGlobal[TKT_UserTable], key, "level");
tkUSER[playerid][TKU_JailedTime] = DB::GetIntEntry(gGlobal[TKT_UserTable], key, "jailtime");
tkUSER[playerid][TKU_Muted] = DB::GetIntEntry(gGlobal[TKT_UserTable], key, "muted");
tkUSER[playerid][TKU_MutedTime] = DB::GetIntEntry(gGlobal[TKT_UserTable], key, "mutetime");
tkUSER[playerid][TKU_CMuted] = DB::GetIntEntry(gGlobal[TKT_UserTable], key, "cmuted");
tkUSER[playerid][TKU_CMuteTime] = DB::GetIntEntry(gGlobal[TKT_UserTable], key, "cmutetime");
tkUSER[playerid][TKU_Cash] = DB::GetIntEntry(gGlobal[TKT_UserTable], key, "cash");
conversor
PHP код:
stock GetPlayerConnectedTime(playerid, &hours, &minutes, &seconds)
{
new connected_time = NetStats_GetConnectedTime(playerid);
seconds = (connected_time / 1000) % 60;
minutes = (connected_time / (1000 * 60)) % 60;
hours = (connected_time / (1000 * 60 * 60));
return true;
}