[WARNING] mysql_connect: no password specified [ERROR] cache_get_value_name_int: no active cache
forward Query_LoadCharacter(playerid); public Query_LoadCharacter(playerid) { new rows = cache_num_rows(); if(!rows) { printf("[SERVER]: No clans were loaded from the MYSQL Database."); return 0; } for (new i = 0; i < rows; i ++) { cache_get_value_name_int(i, "char_ID", CharacterInfo[i][cID]); cache_get_value_name_int(i, "char_Admin", CharacterInfo[i][cAdmin]); cache_get_value_name_int(i, "char_Skin", CharacterInfo[i][cSkin]); cache_get_value_float(i, "char_PosX", CharacterInfo[i][cPos][0]); cache_get_value_float(i, "char_PosY", CharacterInfo[i][cPos][1]); cache_get_value_float(i, "char_PosZ", CharacterInfo[i][cPos][2]); cache_get_value_float(i, "char_PosA", CharacterInfo[i][cPos][3]); cache_get_value_name_int(i, "char_Interior", CharacterInfo[i][cInterior]); cache_get_value_name_int(i, "char_VW", CharacterInfo[i][cVW]); cache_get_value_name_int(i, "char_Age", CharacterInfo[i][cAge]); cache_get_value_float(i, "char_Health", CharacterInfo[i][cHealth]); cache_get_value_float(i, "char_Armour", CharacterInfo[i][cArmour]); cache_get_value_name_int(i, "char_Money", CharacterInfo[i][cMoney]); } TogglePlayerSpectating(playerid, false); LoadCharacter(playerid); return 1; }
stock SaveCharacter(playerid)
{
send_msg(playerid, -1, "Save Pos");
GetPlayerPos(playerid, CharacterInfo[playerid][cPos][0], CharacterInfo[playerid][cPos][1], CharacterInfo[playerid][cPos][2]);
GetPlayerFacingAngle(playerid, CharacterInfo[playerid][cPos][3]);
GetPlayerHealth(playerid, CharacterInfo[playerid][cHealth]);
GetPlayerArmour(playerid, CharacterInfo[playerid][cArmour]);
CharacterInfo[playerid][cVW] = GetPlayerVirtualWorld(playerid);
CharacterInfo[playerid][cInterior] = GetPlayerInterior(playerid);
send_format(playerid, -1, "X: %.4f | Y: %.4f | Z: %.4f | A: %.4f", CharacterInfo[playerid][cPos][0], CharacterInfo[playerid][cPos][1], CharacterInfo[playerid][cPos][2], CharacterInfo[playerid][cPos][3]);
new query[2024];
format(query, sizeof(query), "UPDATE `rp_characters` SET char_Admin = %d, char_Skin = %d, char_PosX = %.4f, char_PosY = %.4f, char_PosZ = %.4f, char_PosA = %.4f, char_Interior = %d, char_VW = %d",
CharacterInfo[playerid][cAdmin],
CharacterInfo[playerid][cSkin],
CharacterInfo[playerid][cPos][0],
CharacterInfo[playerid][cPos][1],
CharacterInfo[playerid][cPos][2],
CharacterInfo[playerid][cPos][3],
CharacterInfo[playerid][cVW],
CharacterInfo[playerid][cInterior]);
format(query, sizeof(query), "%s, char_Health = %.4f = %d, char_Armour = %.4f, char_Money = %d WHERE char_ID = '%d'",
query,
CharacterInfo[playerid][cHealth],
CharacterInfo[playerid][cArmour],
CharacterInfo[playerid][cMoney],
CharacterInfo[playerid][cID]);
mysql_tquery(g_SQL, query);
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch (dialogid)
{
case DIALOG_SELECT_CHARACTER_RP:
{
if(!response) return 1;
playerMakingCharacter[playerid] = true;
playerCharacterStep[playerid] = 1;
return 1;
}
else
{
new string[128], thread[128];
TogglePlayerSpectating(playerid, true);
playerMakingCharacter[playerid] = false;
playerCharacterStep[playerid] = 0;
SetPlayerName(playerid, CharacterLister[playerid][listitem]);
mysql_format(g_SQL, thread, sizeof(thread), "SELECT * FROM rp_characters WHERE char_Name = '%e' LIMIT 1", CharacterLister[playerid][listitem]);
mysql_tquery(g_SQL, thread, "Query_SelectCharacter", "i", playerid);
}
}
return 1;
}
forward Query_SelectCharacter(playerid);
public Query_SelectCharacter(playerid)
{
if (!cache_num_rows())
{
new
liststring[128]
;
for (new i = 0; i < 3; i ++) {
format(liststring, sizeof(liststring), "%s%s\n", liststring, CharacterLister[playerid][i]); }
return ShowPlayerDialog(playerid, DIALOG_SELECT_CHARACTER_RP, DIALOG_STYLE_LIST, "Nhan vat:", liststring, "Chon", "Tro lai");
}
new rows, fields, thread[128];
cache_get_row_count(rows);
cache_get_field_count(fields);
if(rows)
{
mysql_format(g_SQL, thread, sizeof(thread), "SELECT * FROM rp_characters WHERE char_Name = '%e'", GetPlayerNameEx(playerid));
mysql_tquery(g_SQL, thread, "Query_LoadCharacter", "i", playerid);
}
return 1;
}
forward Query_LoadCharacter(playerid); public Query_LoadCharacter(playerid) { new rows = cache_num_rows(); if(!rows) { printf("[SERVER]: No clans were loaded from the MYSQL Database."); //clans? return 0; } //We dont have to loop,because you are only loading 1 characters data. cache_get_value_name_int(0, "char_ID", CharacterInfo[playerid][cID]); cache_get_value_name_int(0, "char_Admin", CharacterInfo[playerid][cAdmin]); cache_get_value_name_int(0, "char_Skin", CharacterInfo[playerid][cSkin]); cache_get_value_float(0, "char_PosX", CharacterInfo[playerid][cPos][0]); cache_get_value_float(0, "char_PosY", CharacterInfo[playerid][cPos][1]); cache_get_value_float(0, "char_PosZ", CharacterInfo[playerid][cPos][2]); cache_get_value_float(0, "char_PosA", CharacterInfo[playerid][cPos][3]); cache_get_value_name_int(0, "char_Interior", CharacterInfo[playerid][cInterior]); cache_get_value_name_int(0, "char_VW", CharacterInfo[playerid][cVW]); cache_get_value_name_int(0, "char_Age", CharacterInfo[playerid][cAge]); cache_get_value_float(0, "char_Health", CharacterInfo[playerid][cHealth]); cache_get_value_float(0, "char_Armour", CharacterInfo[playerid][cArmour]); cache_get_value_name_int(0, "char_Money", CharacterInfo[playerid][cMoney]); TogglePlayerSpectating(playerid, false); LoadCharacter(playerid); return 1; }
Код:
forward Query_LoadCharacter(playerid); public Query_LoadCharacter(playerid) { new rows = cache_num_rows(); if(!rows) { printf("[SERVER]: No clans were loaded from the MYSQL Database."); //clans? return 0; } //We dont have to loop,because you are only loading 1 characters data. cache_get_value_name_int(0, "char_ID", CharacterInfo[playerid][cID]); cache_get_value_name_int(0, "char_Admin", CharacterInfo[playerid][cAdmin]); cache_get_value_name_int(0, "char_Skin", CharacterInfo[playerid][cSkin]); cache_get_value_float(0, "char_PosX", CharacterInfo[playerid][cPos][0]); cache_get_value_float(0, "char_PosY", CharacterInfo[playerid][cPos][1]); cache_get_value_float(0, "char_PosZ", CharacterInfo[playerid][cPos][2]); cache_get_value_float(0, "char_PosA", CharacterInfo[playerid][cPos][3]); cache_get_value_name_int(0, "char_Interior", CharacterInfo[playerid][cInterior]); cache_get_value_name_int(0, "char_VW", CharacterInfo[playerid][cVW]); cache_get_value_name_int(0, "char_Age", CharacterInfo[playerid][cAge]); cache_get_value_float(0, "char_Health", CharacterInfo[playerid][cHealth]); cache_get_value_float(0, "char_Armour", CharacterInfo[playerid][cArmour]); cache_get_value_name_int(0, "char_Money", CharacterInfo[playerid][cMoney]); TogglePlayerSpectating(playerid, false); LoadCharacter(playerid); return 1; } |