new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
format(query, sizeof(query), "UPDATE `playerinfo` SET PosX = '%f', PosY = '%f', PosZ = '%f' ,PosA = '%f' WHERE `Name` = '%s'", x, y, z, z, GetName(playerid));
mysql_function_query(MYSQLConnection, query, false, "noReturnQuery", "d", playerid);
cache_get_field_content(0, "PosX", valor, MYSQLConnection);
playerinfo[playerid][pPosX] = strval(valor);
cache_get_field_content(0, "PosY", valor, MYSQLConnection);
playerinfo[playerid][pPosY] = strval(valor);
cache_get_field_content(0, "PosZ", valor, MYSQLConnection);
playerinfo[playerid][pPosZ] = strval(valor);
SetPlayerPos(playerid, playerinfo[playerid][pPosX], playerinfo[playerid][pPosY], playerinfo[playerid][pPosZ]);
Bom, fiz um script que salve a posiзгo X Y Z do player no servidor e envie para o banco de dados.
Ao deslogar: pawn Код:
|
format(query, sizeof(query), "UPDATE `playerinfo` SET PosX = '%f', PosY = '%f', PosZ = '%f' ,PosA = '%f' WHERE `Name` = '%s'", x, y, z, z, GetName(playerid));
public OnPlayerDisconnect(playerid, reason)
{
new File:file, pasta[40],Float:Pos[4], String[50], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(pasta, 40, Pasta, pName);
format(String, sizeof(String), "•••• %s ••••", pName);
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
GetPlayerFacingAngle(playerid, Pos[3]);
file = fopen(pasta);
fwrite(file, String);
dini_FloatSet(pasta, "PosX", Pos[0]);
dini_FloatSet(pasta, "PosY", Pos[1]);
dini_FloatSet(pasta, "PosZ", Pos[2]);
dini_FloatSet(pasta, "PosA", Pos[3]);
fwrite(file, String);
return 1;
}
public OnPlayerSpawn(playerid)
{
new pasta[40], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(pasta, 40, Pasta, pName);
if(!dini_Exists(pasta)) return dini_Create(pasta);
SetPlayerPos(playerid, dini_Float(pasta, "PosX"), dini_Float(pasta, "PosY"), dini_Float(pasta, "PosZ"));
SetPlayerFacingAngle(playerid, dini_Float(pasta, "PosA"));
return 1;
}