Advertisement
Guest User

Untitled

a guest
Aug 13th, 2010
3,139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.13 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dini>
  3.  
  4. /*
  5. Salvando armas editado caio
  6. */
  7.  
  8. #define PATH "Armas"  //  Aqui é onde vai salvar os negocios
  9.  
  10. new bool:AlreadyGiveWeapons[MAX_PLAYERS];
  11.  
  12. public OnFilterScriptInit()
  13. {
  14.     printf("|------------------------------------------------|");
  15.     printf("|-------- Sistema de armas editado por caio --------|");
  16.     printf("|------------------------------------------------|");
  17.     return 1;
  18. }
  19.  
  20. public OnFilterScriptExit()
  21. {
  22.     printf("|------------------------------------------------|");
  23.     printf("|--------- Sistema de salvar armas editado por caio ---------|");
  24.     printf("|------------------------------------------------|");
  25.     return 1;
  26. }
  27.  
  28. public OnPlayerConnect(playerid)
  29. {
  30.     AlreadyGiveWeapons[playerid] = false;
  31.     return 1;
  32. }
  33.  
  34. public OnPlayerDisconnect(playerid, reason)
  35. {
  36.     SaveWeaponsToFile(playerid);
  37.     return 1;
  38. }
  39.  
  40. SaveWeaponsToFile(playerid)
  41. {
  42.     new i, path[50], string[128], weaponid, ammo;
  43.     path = GetPlayerFormattedName(playerid);
  44.     if (!dini_Exists(path)) dini_Create(path);
  45.     for (i=0; i<13; i++)
  46.     {
  47.         GetPlayerWeaponData(playerid,i,weaponid,ammo);
  48.         format(string,sizeof(string),"Arma - %d",i);
  49.         dini_IntSet(path,string,weaponid);
  50.         format(string,sizeof(string),"Municao - %d",i);
  51.         dini_IntSet(path,string,ammo == 65535 ? 0 : ammo);
  52.     }
  53. }
  54.  
  55. forward LoadArmasToFile(playerid);
  56. public LoadArmasToFile(playerid)
  57. {
  58.     new i, path[50], string[128], weaponid, ammo;
  59.     path = GetPlayerFormattedName(playerid);
  60.     ResetPlayerWeapons(playerid);
  61.     for (i=0; i<13; i++)
  62.     {
  63.         format(string,sizeof(string),"Arma - %d",i);
  64.         weaponid = dini_Int(path,string);
  65.         format(string,sizeof(string),"Municao - %d",i);
  66.         ammo = dini_Int(path,string);
  67.         GivePlayerWeapon(playerid,weaponid,ammo);
  68.     }
  69.     AlreadyGiveWeapons[playerid] = true;
  70. }
  71.  
  72. GetPlayerFormattedName(playerid)
  73. {
  74.     new name[24], full[50];
  75.     GetPlayerName(playerid,name,sizeof(name));
  76.     format(full,sizeof(full),"%s/%s.txt",PATH,name);
  77.     return full;
  78. }
  79.  
  80. public OnPlayerSpawn(playerid)
  81. {
  82.     if (!AlreadyGiveWeapons[playerid]) SetTimerEx("LoadArmasToFile",250,false,"i",playerid);
  83.     return 1;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement