Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.01 KB | None | 0 0
  1. #define FILTERSCRIPT
  2. #include <a_samp>
  3. #include <ZCMD>
  4. #include <DOF2>
  5. #if defined FILTERSCRIPT
  6.  
  7. #define Inventarios "Inventarios/%s.ini"
  8.  
  9.  
  10. enum pInv
  11. {
  12. iSlot[8]
  13. };
  14.  
  15. new PlayerInventario[MAX_PLAYERS][pInv];
  16. new PlayerText:TDEditor_PTD[MAX_PLAYERS][13];
  17. new pName[MAX_PLAYERS][24];
  18. new gstring[20];
  19.  
  20. public OnFilterScriptInit()
  21. {
  22. print("\n--------------------------------------");
  23. print(" Inventario carregado com sucesso! ");
  24. print("--------------------------------------\n");
  25. return 1;
  26. }
  27.  
  28. public OnFilterScriptExit()
  29. {
  30. DOF2_Exit();
  31. return 1;
  32. }
  33.  
  34. public OnPlayerConnect(playerid)
  35. {
  36. GetPlayerName(playerid, pName[playerid], 24);
  37. LoadInventario(playerid);
  38. return 1;
  39. }
  40.  
  41. public OnPlayerDisconnect(playerid, reason)
  42. {
  43. SaveInventario(playerid);
  44. return 1;
  45. }
  46.  
  47. public OnPlayerClickTextDraw(playerid, Text:clickedid){
  48. if(clickedid == Text:INVALID_TEXT_DRAW){
  49.  
  50. if(GetPVarInt(playerid, "Inventario")){
  51.  
  52. InventarioHide(playerid);
  53. }
  54. }
  55. return 1;
  56. }
  57.  
  58. CMD:test(playerid)
  59. {
  60. if(!GetPVarInt(playerid, "Inventario")){
  61. LoadInventario(playerid);
  62. Inventario(playerid);
  63. InventarioShow(playerid);
  64. }
  65. else{
  66.  
  67. SaveInventario(playerid);
  68. InventarioHide(playerid);
  69. }
  70. return 1;
  71. }
  72.  
  73. GetPlayerArquivo(playerid)
  74. {
  75. new ArquivoPlayer[ 30 ];
  76. format( ArquivoPlayer, sizeof( ArquivoPlayer ), Inventarios, pName[playerid]);
  77. return ArquivoPlayer;
  78. }
  79.  
  80. SaveInventario(playerid)
  81. {
  82. for(new I; I < 8; I ++)
  83. {
  84. if(PlayerInventario[playerid][iSlot][I] == 0)
  85. {
  86. PlayerInventario[playerid][iSlot][I] = 1;
  87.  
  88. if(!DOF2_FileExists(GetPlayerArquivo(playerid)))
  89. DOF2_CreateFile(GetPlayerArquivo(playerid));
  90.  
  91. format(gstring, sizeof(gstring), "iSlot%d", I);
  92. DOF2_SetInt(GetPlayerArquivo(playerid), gstring, PlayerInventario[playerid][iSlot][I]);
  93.  
  94. DOF2_SaveFile();
  95. }
  96. }
  97. return 1;
  98. }
  99.  
  100. LoadInventario(playerid)
  101. {
  102. if( DOF2_FileExists( GetPlayerArquivo(playerid) ) )
  103. {
  104. for(new I; I < 8; I ++) {
  105.  
  106. format(gstring, sizeof(gstring), "iSlot%d", I);
  107. PlayerInventario[playerid][iSlot][I] = DOF2_GetInt(GetPlayerArquivo(playerid), gstring);
  108. }
  109. }
  110. return 1;
  111. }
  112.  
  113. InventarioHide(playerid)
  114. {
  115. PlayerTextDrawHide(playerid, TDEditor_PTD[playerid][0]);
  116. PlayerTextDrawHide(playerid, TDEditor_PTD[playerid][1]);
  117. PlayerTextDrawHide(playerid, TDEditor_PTD[playerid][2]);
  118. PlayerTextDrawHide(playerid, TDEditor_PTD[playerid][3]);
  119. PlayerTextDrawHide(playerid, TDEditor_PTD[playerid][4]);
  120. PlayerTextDrawHide(playerid, TDEditor_PTD[playerid][5]);
  121. PlayerTextDrawHide(playerid, TDEditor_PTD[playerid][6]);
  122. PlayerTextDrawHide(playerid, TDEditor_PTD[playerid][7]);
  123. PlayerTextDrawHide(playerid, TDEditor_PTD[playerid][8]);
  124. CancelSelectTextDraw(playerid);
  125.  
  126. SetPVarInt(playerid, "Inventario", 0);
  127. return 1;
  128. }
  129.  
  130. InventarioShow(playerid)
  131. {
  132. PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][0]);
  133. PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][1]);
  134. PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][2]);
  135.  
  136. PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][3]);
  137. PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][4]);
  138. PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][5]);
  139. PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][6]);
  140. PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][7]);
  141. PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][8]);
  142. return 1;
  143. }
  144.  
  145. Inventario(playerid)
  146. {
  147. TDEditor_PTD[playerid][0] = CreatePlayerTextDraw(playerid, 188.125000, 148.583358, "Inventario");
  148.  
  149. TDEditor_PTD[playerid][1] = CreatePlayerTextDraw(playerid, 181.875000, 148.000045, "box");
  150.  
  151.  
  152. TDEditor_PTD[playerid][2] = CreatePlayerTextDraw(playerid, 204.375000, 168.416595, "");
  153.  
  154. PlayerTextDrawSetPreviewModel(playerid, TDEditor_PTD[playerid][2], PlayerInventario[playerid][iSlot][0]);
  155.  
  156.  
  157. TDEditor_PTD[playerid][3] = CreatePlayerTextDraw(playerid, 323.125000, 168.416595, "");
  158.  
  159. PlayerTextDrawSetPreviewModel(playerid, TDEditor_PTD[playerid][3], PlayerInventario[playerid][iSlot][1]);
  160.  
  161.  
  162. TDEditor_PTD[playerid][4] = CreatePlayerTextDraw(playerid, 429.375000, 167.249938, "");
  163. PlayerTextDrawSetPreviewModel(playerid, TDEditor_PTD[playerid][4], PlayerInventario[playerid][iSlot][2]);
  164.  
  165. TDEditor_PTD[playerid][5] = CreatePlayerTextDraw(playerid, 203.125000, 247.749954, "");
  166. PlayerTextDrawSetPreviewModel(playerid, TDEditor_PTD[playerid][5], PlayerInventario[playerid][iSlot][3]);
  167.  
  168. TDEditor_PTD[playerid][6] = CreatePlayerTextDraw(playerid, 321.875000, 248.916656, "");
  169. PlayerTextDrawSetPreviewModel(playerid, TDEditor_PTD[playerid][6], PlayerInventario[playerid][iSlot][4]);
  170.  
  171. TDEditor_PTD[playerid][7] = CreatePlayerTextDraw(playerid, 433.125000, 247.750045, "");
  172. PlayerTextDrawSetPreviewModel(playerid, TDEditor_PTD[playerid][7], PlayerInventario[playerid][iSlot][5]);
  173.  
  174. TDEditor_PTD[playerid][8] = CreatePlayerTextDraw(playerid, 431.250000, 247.750045, "");
  175. PlayerTextDrawSetPreviewModel(playerid, TDEditor_PTD[playerid][8], PlayerInventario[playerid][iSlot][6]);
  176. SetPVarInt(playerid, "Inventario", 1);
  177. return 1;
  178. }
  179.  
  180. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement