Advertisement
_iLustcheR_

SAMP-IL SavingDataCrash v1.0 by LustcheR

May 5th, 2014
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.06 KB | None | 0 0
  1. #include <a_samp>
  2. #include <DOF2>
  3.  
  4. #pragma unused DOF2_Exit
  5.  
  6. new Name[MAX_PLAYER_NAME];
  7.  
  8. public OnPlayerConnect(playerid) return GetPlayerName(playerid, Name, sizeof(Name));
  9.  
  10. public OnPlayerDisconnect(playerid, reason)
  11. {
  12.     if(reason == 0)
  13.     {
  14.         new Float:Pos[3];
  15.         GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  16.         DOF2_CreateFile(CrashFile(playerid));
  17.         DOF2_SetFloat(CrashFile(playerid), "PosX", Pos[0]);
  18.         DOF2_SetFloat(CrashFile(playerid), "PosY", Pos[1]);
  19.         DOF2_SetFloat(CrashFile(playerid), "PosZ", Pos[2]);
  20.     }
  21.     return 1;
  22. }
  23.  
  24. public OnPlayerSpawn(playerid)
  25. {
  26.     if(DOF2_FileExists(CrashFile(playerid)))
  27.     {
  28.         SetPlayerPos(playerid, DOF2_GetFloat(CrashFile(playerid), "PosX"), DOF2_GetFloat(CrashFile(playerid), "PosY"),         DOF2_GetFloat(CrashFile(playerid), "PosZ"));
  29.         DOF2_RemoveFile(CrashFile(playerid));
  30.     }
  31.     else return 0;
  32.     return 1;
  33. }
  34.  
  35. stock CrashFile(playerid)
  36. {
  37.     new CF[64];
  38.     format(CF, sizeof(CF), "Crash/%s.ini", Name[playerid]);
  39.     return CF;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement