Advertisement
Guest User

Salvamento de Armas

a guest
Aug 27th, 2012
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.59 KB | None | 0 0
  1. #include <a_samp>
  2. #include <DOF2>
  3.  
  4. public OnPlayerSpawn(playerid)
  5. {
  6.     LoadWeapons(playerid);
  7.     return 1;
  8. }
  9.  
  10. public OnGameModeExit()
  11. {
  12.     DOF2_Exit();
  13.     return 1;
  14. }
  15.  
  16. public OnPlayerDisconnect(playerid)
  17. {
  18.     SaveWeapons(playerid);
  19.     return 1;
  20. }
  21.  
  22. SaveWeapons(playerid)
  23. {
  24.     new weapons[13][2], wstring[56], armap[24];
  25.     format(wstring, sizeof(wstring), "Armas/%s.ini", GetNick(playerid));
  26.     if(!DOF2_FileExists(wstring))
  27.         DOF2_CreateFile(wstring);
  28.     if(DOF2_FileExists(wstring))
  29.     {
  30.         for (new i = 0; i < 13; i++)
  31.         {
  32.             GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
  33.             format(armap, sizeof(armap), "Weapon%d", i);
  34.             DOF2_SetInt(wstring, armap, weapons[i][0]);
  35.             format(armap, sizeof(armap), "Ammo%d", i);
  36.             DOF2_SetInt(wstring, armap, weapons[i][1]);
  37.         }
  38.         DOF2_SaveFile();
  39.         print("Armas Salvas");
  40.     }
  41.     return 1;
  42. }
  43.  
  44. LoadWeapons(playerid)
  45. {
  46.     new wstring[56], armap[24], weapons[13][2];
  47.     format(wstring, sizeof(wstring), "Armas/%s.ini", GetNick(playerid));
  48.     if(!DOF2_FileExists(wstring))
  49.         return 1;
  50.     if(DOF2_FileExists(wstring))
  51.     {
  52.         for (new i = 0; i < 13; i++)
  53.         {
  54.             format(armap, sizeof(armap), "Weapon%d", i);
  55.             weapons[i][0] = DOF2_GetInt(wstring, armap);
  56.             format(armap, sizeof(armap), "Ammo%d", i);
  57.             weapons[i][1] = DOF2_GetInt(wstring, armap);
  58.             if(weapons[i][0] != 0)
  59.                 GivePlayerWeapon(playerid, weapons[i][0], weapons[i][1]);
  60.         }
  61.         print("Armas Carregadas");
  62.     }
  63.     return 1;
  64. }
  65.  
  66. GetNick(playerid)
  67. {
  68.     new name[MAX_PLAYER_NAME];
  69.     GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  70.     return name;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement