Доброго времени суток ув. пользователи, сегодня я вам расскажу как сделать сохранение позиции после выхода.
И так, в Enum pInfo добавим следующий код.
Code
Float:pPos_x,
Float:pPos_y,
Float:pPos_z,
Затем, в public OnPlayerConnect
Code
PlayerInfo[playerid][pPos_x] = 2246.6;//Положение пероначального спавна X
PlayerInfo[playerid][pPos_y] = -1161.9;//Положение пероначального спавна Y
PlayerInfo[playerid][pPos_z] = 1029.7;//Положение пероначального спавна Z
Далее, public OnPlayerDisconnect
Code
PlayerInfo[playerid][pPos_x] = x;//Как бе идёт, сохранение позиции.
PlayerInfo[playerid][pPos_y] = y;
PlayerInfo[playerid][pPos_z] = z;
public OnPlayerRegister
Code
format(var, 64, "Pos_x=%.1f\n",PlayerInfo[playerid][pPos_x]);fwrite(hFile, var);
format(var, 64, "Pos_y=%.1f\n",PlayerInfo[playerid][pPos_y]);fwrite(hFile, var);
format(var, 64, "Pos_z=%.1f\n",PlayerInfo[playerid][pPos_z]);fwrite(hFile, var);
public OnPlayerUpdate
Code
if ((PlayerInfo[playerid][pPos_x]==0.0 && PlayerInfo[playerid][pPos_y]==0.0 && PlayerInfo[playerid][pPos_z]==0.0))
{
PlayerInfo[playerid][pPos_x] = 1684.9;//как помним первоначальные координаты
PlayerInfo[playerid][pPos_y] = -2244.5;
PlayerInfo[playerid][pPos_z] = 13.5;
}
format(var, 64, "Pos_x=%.1f\n",PlayerInfo[playerid][pPos_x]);fwrite(hFile, var);
format(var, 64, "Pos_y=%.1f\n",PlayerInfo[playerid][pPos_y]);fwrite(hFile, var);
format(var, 64, "Pos_z=%.1f\n",PlayerInfo[playerid][pPos_z]);fwrite(hFile, var);
В public OnPlayerLogin
Code
if( strcmp( key , "Pos_x" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pPos_x] = floatstr( val ); }
if( strcmp( key , "Pos_y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pPos_y] = floatstr( val ); }
if( strcmp( key , "Pos_z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pPos_z] = floatstr( val ); }
И ниже видим подобные строчки и добавляем
Code
PlayerInfo[playerid][pPos_x] = 2246.6;
PlayerInfo[playerid][pPos_y] = -1161.9;
PlayerInfo[playerid][pPos_z] = 1029.7;
Ну и где, сам спавн игроков, делаем так
Code
PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z]
.