_iLustcheR_

SAMP-IL SavingDataCrash v1.1 by LustcheR

May 5th, 2014
859
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.20 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_SetInt(CrashFile(playerid), "Monay", GetPlayerMonay(playerid));
  18.         DOF2_SetFloat(CrashFile(playerid), "PosX", Pos[0]);
  19.         DOF2_SetFloat(CrashFile(playerid), "PosY", Pos[1]);
  20.         DOF2_SetFloat(CrashFile(playerid), "PosZ", Pos[2]);
  21.     }
  22.     return 1;
  23. }
  24.  
  25. public OnPlayerSpawn(playerid)
  26. {
  27.     if(DOF2_FileExists(CrashFile(playerid)))
  28.     {
  29.     GivePlayerMoney(playerid, DOF2_GetInt(CrashFile(playerid), "Monay"));
  30.         SetPlayerPos(playerid, DOF2_GetFloat(CrashFile(playerid), "PosX"), DOF2_GetFloat(CrashFile(playerid), "PosY"),         DOF2_GetFloat(CrashFile(playerid), "PosZ"));
  31.         DOF2_RemoveFile(CrashFile(playerid));
  32.     }
  33.     else return 0;
  34.     return 1;
  35. }
  36.  
  37. stock CrashFile(playerid)
  38. {
  39.     new CF[64];
  40.     format(CF, sizeof(CF), "Crash/%s.ini", Name[playerid]);
  41.     return CF;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment