If you have a table of 'users' with the next columns: x, y, z, a then it's simple.
Add this when player disconnects:
I'm pretty sure it should work
pawn Код:
new Float:x, Float:y, Float:z, Float:a;
GetPlayerFacingAngle(playerid, a);
GetPlayerPos(playerid, x, y, z);
format(query, sizeof(query), "UPDATE `users` SET `x` = %f, `y` = %f, `z` = %f, `a` = %f WHERE `name` = '%s'", x, y, z, a, GetName(playerid));
mysql_function_query(dbHandle, query, false, "", "");
//When player connects:
LoadPosition(playerid);
//Add those functions
stock LoadPosition(playerid)
{
//You can use escapse string.
format(query, sizeof(query), "SELECT * FROM `users` WHERE `name` = '%s' LIMIT 1", GetName(playerid));
mysql_function_query(dbHandle, query, true, "InsertPosition", "i", playerid);
}
forward InsertPosition(playerid);
public InsertPosition(playerid)
{
new rows, fields;
cache_get_data(rows, fields);
if(rows)
{
PlayerInfo[playerid][pPosX] = cache_get_row_int(total, X_COLUMN_NUMBER);
PlayerInfo[playerid][pPosY] = cache_get_row_int(total, Y_COLUMN_NUMBER);
PlayerInfo[playerid][pPosZ] = cache_get_row_int(total, Z_COLUMN_NUMBER);
PlayerInfo[playerid][pPosA] = cache_get_row_int(total, A_COLUMN_NUMBER);
}
return 1;
}