Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include a_samp
- #include dof2
- #include pawn.cmd
- #define function%0(%1) \
- forward%0(%1); public%0(%1)
- static gPlayerLastTimer[MAX_PLAYERS] = {-1, ...};
- static Float:gPlayerLastPos[MAX_PLAYERS][4];
- static bool:gPlayerLastWarning[MAX_PLAYERS];
- main(){}
- public OnGameModeInit()
- {
- DOF2::Exit();
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- new file[16 + MAX_PLAYER_NAME];
- format(file, sizeof(file), "Posições/%s.ini", GetPlayerNamef(playerid));
- if(DOF2::FileExists(file) && !gPlayerLastWarning[playerid] && gPlayerLastTimer[playerid] == -1)
- {
- SendClientMessage(playerid, -1, "* Para continuar em sua última posição use (/continuar).");
- gPlayerLastTimer[playerid] = SetTimerEx("OnPlayerLastPosition", 30000, false, "i", playerid);
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- SavePlayerLastPosition(playerid);
- return 1;
- }
- function OnPlayerLastPosition(playerid)
- {
- ResetPlayerLastPosition(playerid);
- SendClientMessage(playerid, -1, "* Se passaram 30 segundos e você não quis continuar em sua última posição.");
- return 1;
- }
- SavePlayerLastPosition(playerid)
- {
- new file[16 + MAX_PLAYER_NAME];
- format(file, sizeof(file), "Posições/%s.ini", GetPlayerNamef(playerid));
- if(!DOF2::FileExists(file))
- DOF2::CreateFile(file);
- GetPlayerPos(playerid, gPlayerLastPos[playerid][0], gPlayerLastPos[playerid][1], gPlayerLastPos[playerid][2]);
- GetPlayerFacingAngle(playerid, gPlayerLastPos[playerid][3]);
- DOF2::SetFloat(file, "X", gPlayerLastPos[playerid][0]);
- DOF2::SetFloat(file, "Y", gPlayerLastPos[playerid][1]);
- DOF2::SetFloat(file, "Z", gPlayerLastPos[playerid][2]);
- DOF2::SetFloat(file, "A", gPlayerLastPos[playerid][3]);
- DOF2::SaveFile();
- }
- ResetPlayerLastPosition(playerid)
- {
- KillTimer(gPlayerLastTimer[playerid]);
- gPlayerLastTimer[playerid] = -1;
- gPlayerLastWarning[playerid] = true;
- }
- GetPlayerNamef(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, MAX_PLAYER_NAME);
- return name;
- }
- CMD:continuar(playerid)
- {
- if(gPlayerLastWarning[playerid])
- return SendClientMessage(playerid, -1, "* Você não pode usar este comando agora.");
- new file[16 + MAX_PLAYER_NAME];
- format(file, sizeof(file), "Posições/%s.ini", GetPlayerNamef(playerid));
- if(DOF2::FileExists(file))
- {
- gPlayerLastPos[playerid][0] = DOF2::GetFloat(file, "X");
- gPlayerLastPos[playerid][1] = DOF2::GetFloat(file, "Y");
- gPlayerLastPos[playerid][2] = DOF2::GetFloat(file, "Z");
- gPlayerLastPos[playerid][3] = DOF2::GetFloat(file, "A");
- SetPlayerPos(playerid, gPlayerLastPos[playerid][0], gPlayerLastPos[playerid][1], gPlayerLastPos[playerid][2]);
- SetPlayerFacingAngle(playerid, gPlayerLastPos[playerid][3]);
- SetCameraBehindPlayer(playerid);
- ResetPlayerLastPosition(playerid);
- }
- return 1;
- }
Add Comment
Please, Sign In to add comment