pawn Код:
#include <a_samp>
#include <DOF2>
#define PLAYER_FILE "Spawn/%s.ini" //altere para sua pasta/arquivo de players padrгo
new
bool: g_bool_player_connected [ MAX_PLAYERS ];
public OnFilterScriptExit ( )
{
DOF2_Exit ( );
return 1;
}
public OnPlayerConnect ( playerid )
{
g_bool_player_connected [ playerid ] = true;
return 1;
}
public OnPlayerSpawn ( playerid )
{
if ( g_bool_player_connected [ playerid ] )
{
new
Float: flo_old_player_pos [ 3 ],
Float: flo_old_player_fa,
int_old_player_int,
str_player_name [ MAX_PLAYER_NAME ],
playerFileFormatted[62];
g_bool_player_connected [ playerid ] = false;
GetPlayerName ( playerid, str_player_name, sizeof str_player_name );
format(playerFileFormatted, 62, PLAYER_FILE, str_player_name);
flo_old_player_pos [ 0 ] = DOF2_GetFloat ( playerFileFormatted, "Last Pos X" );
flo_old_player_pos [ 1 ] = DOF2_GetFloat ( playerFileFormatted, "Last Pos Y" );
flo_old_player_pos [ 2 ] = DOF2_GetFloat ( playerFileFormatted, "Last Pos Z" );
flo_old_player_fa = DOF2_GetFloat ( playerFileFormatted, "Last Pos FA" );
int_old_player_int = DOF2_GetInt ( playerFileFormatted, "Last Int" );
SetPlayerPos ( playerid, flo_old_player_pos [ 0 ], flo_old_player_pos [ 1 ], flo_old_player_pos [ 2 ] );
SetPlayerFacingAngle ( playerid, flo_old_player_fa );
SetPlayerInterior ( playerid, int_old_player_int );
SendClientMessage ( playerid, -1, "Spawnado na ъltima posiзгo salva." );
return 1;
}
return 1;
}
public OnPlayerDisconnect ( playerid )
{
new
str_player_name [ MAX_PLAYER_NAME ],
Float: flo_player_pos [ 3 ],
Float: flo_player_fa,
int_player_int = GetPlayerInterior ( playerid ),
playerFileFormatted[62];
GetPlayerPos ( playerid, flo_player_pos [ 0 ], flo_player_pos [ 1 ], flo_player_pos [ 2 ] );
GetPlayerFacingAngle ( playerid, flo_player_fa );
GetPlayerName ( playerid, str_player_name, sizeof str_player_name );
format(playerFileFormatted, 62, PLAYER_FILE, str_player_name);
if ( !DOF2_FileExists ( playerFileFormatted ) )
DOF2_CreateFile ( playerFileFormatted );
DOF2_SetFloat ( playerFileFormatted, "Last Pos X", flo_player_pos [ 0 ] );
DOF2_SetFloat ( playerFileFormatted, "Last Pos Y", flo_player_pos [ 1 ] );
DOF2_SetFloat ( playerFileFormatted, "Last Pos Z", flo_player_pos [ 2 ] );
DOF2_SetFloat ( playerFileFormatted, "Last Pos FA", flo_player_fa );
DOF2_SetInt ( playerFileFormatted, "Last Int", int_player_int );
DOF2_SaveFile ( );
return 1;
}