Advertisement
Eduardo_AC

Sistema de inventário

Dec 27th, 2022 (edited)
588
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 64.28 KB | None | 0 0
  1. /*
  2.  
  3. ***********************
  4. **   By Eduardo AC   **
  5. ***********************
  6.  
  7. Callbacks:
  8.  
  9. * Chamada ao criar um inventario
  10. OnCreateInventory(Inventory:id)
  11.  
  12. * Chamada ao criar um inventário estático (posicionado no mapa)
  13. OnCreateStaticInventory(Inventory:id, Float:x, Float:y, Float:z, virtual_world, interior, destroy_delay, Inventory:copy_id)
  14.  
  15. * Chamada quando um inventário é destruído
  16. OnDestroyInventory(Inventory:id, bool:static_inventory)
  17.  
  18. * Chamada quando o joagdor abre um inventário
  19. OnPlayerOpenInventory(playerid, Inventory:id)
  20.  
  21. * Chamada quando o jogador fecha o inventário
  22. OnPlayerCloseInventory(playerid, Inventory:id)
  23.  
  24. * Chamada quando um inventário é destruído, porém um jogador está com ele aberto
  25. OnDestroyOpenedInventory(playerid, Inventory:id)
  26.  
  27. * Chamada quando o jogador clica em um item
  28. OnPlayerSelectItem(playerid, Inventory:id, item, type_index, index)
  29.  
  30. * Chamada quando o jogador usa um item
  31. OnPlayerUseItem(playerid, Inventory:id, item, type_index, index)
  32.  
  33. * Chamada quando o jogador solta um item
  34. OnPlayerDropItem(playerid, Inventory:id, item, type_index, index)
  35.  
  36. * Chamada quando um item é removido do inventário (através da função RemoveInventoryItem apenas)
  37. OnRemoveInventoryItem(Inventory:id, item, type_index, amount)
  38.  
  39. * Chamada quando o jogador pega um item do chão
  40. OnPlayerGetDropedItem(playerid, dropped_index, item, type_index, amount)
  41.  
  42. ----------------------------------------------------------------------
  43.  
  44. Funções:
  45.  
  46. * Cria e inicializa o inventário do jogador (sempre usar esta função antes de qualquer outra para o jogador)
  47. Inventory:CreatePlayerInventory(playerid)
  48.  
  49. * Cria um inventário estático
  50. Inventory:CreateStaticInventory(Float:x, Float:y, Float:z, max_items = MAX_INVENTORY_ITEMS, vw = -1, interior = -1, modelid = -1, Float:rx = 0.0, Float:ry = 0.0, Float:rz = 0.0, const label_text[] = "", destroy_delay = 0, Inventory:id = INVALID_INVENTORY_ID)
  51.  
  52. * Cria um inventário
  53. Inventory:CreateInventory(Inventory:id = INVALID_INVENTORY_ID, max_items = MAX_INVENTORY_ITEMS)
  54.  
  55. * Pega o inventário que o jogador está visualizando
  56. Inventory:GetPlayerOpenedInventory(playerid)
  57.  
  58. * Adiciona um novo item ao conjunto de itens existentes de inventário
  59. AddNewInventoryItem(item, type_index, const title[], const description[])
  60.  
  61. * Adiciona um novo item ao inventário
  62. AddItemInventory(Inventory:id, item, type_index, amount, index = -1)
  63.  
  64. * Retorna por referência o id, tipo e quantidade do item através do index no inventário
  65. InfoInventoryItem(Inventory:id, index, &item, &type_index, &amount)
  66.  
  67. * Retorna o inventário estático mais próximo do jogador com base em determinada área
  68. Inventory:GetStaticInventoryNearPlayer(playerid, Float:range)
  69.  
  70. * Retorna a quantidade do item através do index no inventário
  71. GetInventoryIndexAmount(Inventory:id, index)
  72.  
  73. * Retorna a quantidade do item através do id do item e tipo no inventário
  74. GetInventoryItemAmount(Inventory:id, item, type_index)
  75.  
  76. * Retorna por referência o título e descrição de determinado item através do id e tipo
  77. ItemInfo(item, type_index, title[], description[])
  78.  
  79. * Remove um item do inventário através do item, tipo e determinada quantidade (-1 remove tudo)
  80. RemoveInventoryItem(Inventory:id, item, type_index, amount = -1)
  81.  
  82. * Remove um item do inventário com base no index no inventário
  83. RemoveInventoryItemIndex(Inventory:id, index)
  84.  
  85. * Retorna se o jogador possui determinado item
  86. HaveInventoryItem(Inventory:id, item, type_index)
  87.  
  88. * Reseta os itens do inventário
  89. ClearInventory(Inventory:id)
  90.  
  91. * Retorna se o inventário é válido
  92. IsValidInventory(Inventory:id)
  93.  
  94. * Retorna se o inventário é estático
  95. IsStaticInventory(Inventory:id)
  96.  
  97. * Retorna se o inventário é temporário (auto-destrói)
  98. IsTemporaryInventory(Inventory:id)
  99.  
  100. * Retorna a quantidade de itens do inventário
  101. CountInventoryItems(Inventory:id)
  102.  
  103. * Define a quantidade máxima de itens do inventário
  104. SetInventoryMaxItems(Inventory:id, max_items)
  105.  
  106. * Retorna a quantidade máxima de itens do inventário
  107. GetInventoryMaxItems(Inventory:id)
  108.  
  109. * Retorna o index do último item válido do inventário
  110. GetLastInventoryItemIndex(Inventory:id)
  111.  
  112. * Retorna se o item é válido (caso ele não exista mais no servidor e o jogador ainda o possua)
  113. IsValidInventoryItem(item, type_index)
  114.  
  115. * Retorna o index do item com base no id e tipo
  116. GetInventoryItemIndex(Inventory:id, item, type_index)
  117.  
  118. * Cria um item no chão
  119. CreateDropItem(item, type_index, amount, Float:x, Float:y, Float:z, Float:rx = 0.0, Float:ry = 0.0, Float:rz = 0.0, vw = -1, interior = -1)
  120.  
  121. * Remove um item do chão
  122. RemoveDroppedItem(dropped_index)
  123.  
  124. * Retorna o número de itens no chão com base no id e tipo
  125. CountDroppedItem(item, type_index = 0)
  126.  
  127. * Retorna o número de itens no chão
  128. CountDroppedItems()
  129.  
  130. * Mostra o inventário para o jogador
  131. ShowInventory(Inventory:id, playerid, page = 1, bool:button_use = true, bool:button_drop = true)
  132.  
  133. * Mostra a aba de informações do item (título, descrição, icone e botões)
  134. ShowInventoryItemInfo(playerid)
  135.  
  136. * Oculta a aba de informações do item (título, descrição, icone e botões)
  137. HideInventoryItemInfo(playerid)
  138.  
  139. * Oculta o inventário para o jogador (automaticamente oculta a aba de informações do item)
  140. HideInventory(playerid)
  141.  
  142. * Destrói o inventário
  143. DestroyInventory(Inventory:id)
  144. */
  145.  
  146. #define INVENTORY_LABEL_STREAM                  10.0
  147. #define OPEN_INVENTORY_KEY                      KEY_YES
  148. #define GET_INVENTORY_ITEM_KEY                  KEY_YES
  149.  
  150. #define MAX_SERVER_INVENTORY                    MAX_PLAYERS * 5 + 200
  151. #define MAX_INTERNAL_INVENTORY_ITEMS            120 // Número máximo de itens de inventário
  152. #define MAX_SERVER_DROPPED_ITEMS                10000 // Número máximo de objetos soltos no mapa
  153. #define MAX_INVENTORY_ITEMS                     12 * 2 // Cada página contém 12 itens
  154. #define MAX_INVENTORY_SUBITEMS                  5 // Número máximo de subitens por item
  155. #define MAX_INVENTORY_TITLE                     30 // Número máximo de caracteres do título
  156. #define MAX_INVENTORY_DESCRIPTION               50 // Número máximo de caracteres da descrição
  157. #define INVALID_INVENTORY_ID                    Inventory:-1
  158. #define INVALID_INVENTORY_ITEM                  -1 // ID do objeto que vai definir os itens inválidos
  159.  
  160. enum E_INVENTARIO_ITENS_DATA
  161. {
  162.     ObjectModel,
  163.     TypeIndex,
  164.     ItemTitle[MAX_INVENTORY_TITLE],
  165.     ItemDescription[MAX_INVENTORY_DESCRIPTION]
  166. }
  167. static __tempInventoryItems[MAX_INTERNAL_INVENTORY_ITEMS][E_INVENTARIO_ITENS_DATA];
  168.  
  169. //static PlayerText:InvTD[MAX_PLAYERS][35];
  170. new Text:__globalInvTD[7];
  171. new PlayerText:__playerInvTD[MAX_PLAYERS][28];
  172.  
  173. static bool:__tempInvAtivo[MAX_PLAYERS];
  174. static bool:__tempBotaoUsar[MAX_PLAYERS];
  175. static bool:__tempBotaoSoltar[MAX_PLAYERS];
  176. static __tempNoInventario[MAX_PLAYERS] = { _:INVALID_INVENTORY_ID, ... };
  177. static __tempPaginaInicial[MAX_PLAYERS] = { -1, ... };
  178. static __tempPaginaSelecionada[MAX_PLAYERS];
  179. static __tempItemSelecionado[MAX_PLAYERS] = { -1, ... };
  180. static __tempTextdrawSelecionada[MAX_PLAYERS] = { INVALID_TEXT_DRAW, ... };
  181.  
  182. enum E_INVENTARIO_DATA
  183. {
  184.     ObjectModel,
  185.     TypeIndex,
  186.     Amount,
  187.     ItemTitle[20],
  188.     ItemDescription[MAX_INVENTORY_DESCRIPTION],
  189. }
  190. static InventoryData[MAX_SERVER_INVENTORY][MAX_INVENTORY_ITEMS][E_INVENTARIO_DATA];
  191.  
  192. enum E_INVENTARIO_SERVER_DATA
  193. {
  194.     ID,
  195.     bool:Static,
  196.     ObjectID,
  197.     MaxItems,
  198.     Text3D:Label,
  199.     ObjectModel,
  200.     Float:PosX,
  201.     Float:PosY,
  202.     Float:PosZ,
  203.     VirtualWorld,
  204.     Interior,
  205.     TimerDestroy
  206. }
  207. static Inv[MAX_SERVER_INVENTORY][E_INVENTARIO_SERVER_DATA];
  208.  
  209. // Itens no chão
  210. static DroppedServerItemData[MAX_SERVER_DROPPED_ITEMS][E_INVENTARIO_DATA];
  211. static Float:DroppedServerItemDataPos[MAX_SERVER_DROPPED_ITEMS][3];
  212.  
  213. static __tempServerObjectItem[MAX_SERVER_DROPPED_ITEMS] = {INVALID_OBJECT_ID, ...};
  214. static Text3D:__tempServerObjectLabel[MAX_SERVER_DROPPED_ITEMS];
  215.  
  216. forward OnCreateInventory(Inventory:id);
  217. forward OnCreateStaticInventory(Inventory:id, Float:x, Float:y, Float:z, virtual_world, interior, destroy_delay, Inventory:copy_id);
  218. forward OnDestroyInventory(Inventory:id, bool:static_inventory);
  219. forward OnPlayerOpenInventory(playerid, Inventory:id);
  220. forward OnPlayerCloseInventory(playerid, Inventory:id);
  221. forward OnDestroyOpenedInventory(playerid, Inventory:id);
  222. forward OnPlayerSelectItem(playerid, Inventory:id, item, type_index, index);
  223. forward OnPlayerUseItem(playerid, Inventory:id, item, type_index, index);
  224. forward OnPlayerDropItem(playerid, Inventory:id, item, type_index, index);
  225. forward OnRemoveInventoryItem(Inventory:id, item, type_index, amount);
  226. forward OnPlayerGetDropedItem(playerid, dropped_index, item, type_index, amount);
  227.  
  228. public OnGameModeInit()
  229. {
  230.     for(new i = 0; i < MAX_INTERNAL_INVENTORY_ITEMS; i ++)
  231.         __tempInventoryItems[i][ObjectModel] = INVALID_INVENTORY_ITEM;
  232.    
  233.     for(new i = 0; i < MAX_SERVER_DROPPED_ITEMS; i ++)
  234.         DroppedServerItemData[i][ObjectModel] = INVALID_INVENTORY_ITEM;
  235.    
  236.     CreateInventoryTD();
  237.    
  238.     #if defined td_invent_OnGameModeInit
  239.         td_invent_OnGameModeInit();
  240.     #endif
  241.     return true;
  242. }
  243.  
  244. public OnPlayerDisconnect(playerid, reason)
  245. {
  246.     SetTimerEx("Timer_DesconectarInventarioTD", 0, false, "i", playerid);
  247.    
  248.     #if defined td_invent_OnPlayerDisconnect
  249.         td_invent_OnPlayerDisconnect(playerid, reason);
  250.     #endif
  251.     return true;
  252. }
  253.  
  254. forward Timer_DesconectarInventarioTD(playerid);
  255. public Timer_DesconectarInventarioTD(playerid)
  256. {
  257.     DestroyInventoryTD(playerid);
  258.     __tempInvAtivo[playerid] = false;
  259.     __tempNoInventario[playerid] = _:INVALID_INVENTORY_ID;
  260.     __tempItemSelecionado[playerid] = -1;
  261.     __tempPaginaInicial[playerid] = -1;
  262.     __tempPaginaSelecionada[playerid] = 0;
  263.     __tempTextdrawSelecionada[playerid] = INVALID_TEXT_DRAW;
  264.     return true;
  265. }
  266.  
  267. public OnPlayerClickTextDraw(playerid, Text:clickedid)
  268. {
  269.     if(clickedid == Text:INVALID_TEXT_DRAW && __tempInvAtivo[playerid])
  270.     {
  271.         HideInventory(playerid);
  272.     }
  273.    
  274.     if(__tempNoInventario[playerid] != _:INVALID_INVENTORY_ID)
  275.     {
  276.         new idx = __tempNoInventario[playerid];
  277.         if(IsValidInventory(Inventory:idx))
  278.         {
  279.             if(clickedid == __globalInvTD[6]) // Soltar
  280.             {
  281.                 new bool:validItem = false;
  282.                 if(__tempItemSelecionado[playerid] > -1)
  283.                 {
  284.                     new pag = __tempPaginaInicial[playerid];
  285.                     new item = __tempItemSelecionado[playerid];
  286.                    
  287.                     if(InventoryData[_:idx][pag + item][ObjectModel] != INVALID_INVENTORY_ITEM)
  288.                     {
  289.                         validItem = true;
  290.                         CallLocalFunction("OnPlayerDropItem", "iiiii", playerid, idx, InventoryData[idx][pag + item][ObjectModel], InventoryData[idx][pag + item][TypeIndex], pag + item);
  291.                     }
  292.                 }
  293.                
  294.                 if(!validItem)
  295.                     CallLocalFunction("OnPlayerDropItem", "iiiii", playerid, idx, INVALID_INVENTORY_ITEM, -1, -1);
  296.             }
  297.             else if(clickedid == __globalInvTD[5]) // Usar
  298.             {
  299.                 new bool:validItem = false;
  300.                 if(__tempItemSelecionado[playerid] > -1)
  301.                 {
  302.                     new pag = __tempPaginaInicial[playerid];
  303.                     new item = __tempItemSelecionado[playerid];
  304.                    
  305.                     if(InventoryData[idx][pag + item][ObjectModel] != INVALID_INVENTORY_ITEM)
  306.                     {
  307.                         validItem = true;
  308.                         CallLocalFunction("OnPlayerUseItem", "iiiii", playerid, idx, InventoryData[idx][pag + item][ObjectModel], InventoryData[idx][pag + item][TypeIndex], pag + item);
  309.                        
  310.                         new tdid = __tempTextdrawSelecionada[playerid];
  311.                         if(tdid != INVALID_TEXT_DRAW)
  312.                         {
  313.                             new amount[15];
  314.                             valstr(amount, InventoryData[idx][pag + item][Amount]);
  315.                             PlayerTextDrawSetString(playerid, PlayerText:(tdid + 12), amount);
  316.                             PlayerTextDrawShow(playerid, PlayerText:(tdid + 12));
  317.                             PlayerTextDrawSetPreviewModel(playerid, PlayerText:tdid, InventoryData[idx][pag + item][ObjectModel]);
  318.                             PlayerTextDrawShow(playerid, PlayerText:tdid);
  319.                         }
  320.                     }
  321.                 }
  322.                
  323.                 if(!validItem)
  324.                     CallLocalFunction("OnPlayerUseItem", "iiiii", playerid, idx, INVALID_INVENTORY_ITEM, -1, -1);
  325.             }
  326.             else if(clickedid == __globalInvTD[1]) // Fechar
  327.             {
  328.                 HideInventory(playerid);
  329.             }
  330.             else if(clickedid == __globalInvTD[2]) // Voltar
  331.             {
  332.                 if(__tempPaginaSelecionada[playerid] > 1)
  333.                 {
  334.                     __tempPaginaSelecionada[playerid] --;
  335.                     ShowInventory(Inventory:idx, playerid, __tempPaginaSelecionada[playerid]);
  336.                 }
  337.             }
  338.             else if(clickedid == __globalInvTD[3]) // Avançar
  339.             {
  340.                 new ultimo_item = GetLastInventoryItemIndex(Inventory:idx);
  341.                 new max_paginas = floatround(float(ultimo_item) / 12, floatround_ceil);
  342.                
  343.                 if(__tempPaginaSelecionada[playerid] < max_paginas)
  344.                 {
  345.                     __tempPaginaSelecionada[playerid] ++;
  346.                     ShowInventory(Inventory:idx, playerid, __tempPaginaSelecionada[playerid]);
  347.                 }
  348.             }
  349.         }
  350.     }
  351.    
  352.     #if defined inv_OnPlayerClickTextDraw
  353.         inv_OnPlayerClickTextDraw(playerid, Text:clickedid);
  354.     #endif
  355.     return true;
  356. }
  357.  
  358. public OnPlayerClickDynamicTextdraw(playerid, PlayerText:playertextid)
  359. {
  360.     if(playertextid == PlayerText:INVALID_TEXT_DRAW && __tempInvAtivo[playerid])
  361.     {
  362.         HideInventory(playerid);
  363.     }
  364.    
  365.     if(__tempNoInventario[playerid] != _:INVALID_INVENTORY_ID)
  366.     {
  367.         new bool:validItem = false;
  368.         new idx = __tempNoInventario[playerid];
  369.         if(IsValidInventory(Inventory:idx))
  370.         {
  371.             for(new i = 4, j = 0; i <= 15; i ++, j++)
  372.             {
  373.                 PlayerTextDrawColor(playerid, __playerInvTD[playerid][i], -1);
  374.                 PlayerTextDrawShow(playerid, __playerInvTD[playerid][i]);
  375.                
  376.                 if(playertextid == __playerInvTD[playerid][i])
  377.                 {
  378.                     new pag = __tempPaginaInicial[playerid];
  379.                     __tempItemSelecionado[playerid] = j;
  380.                     __tempTextdrawSelecionada[playerid] = _:__playerInvTD[playerid][i];
  381.                    
  382.                     PlayerTextDrawColor(playerid, __playerInvTD[playerid][i], 1687547391);
  383.                    
  384.                     if(InventoryData[idx][pag + j][ObjectModel] != INVALID_INVENTORY_ITEM)
  385.                     {
  386.                         validItem = true;
  387.                         new titulo[MAX_INVENTORY_TITLE], descricao[MAX_INVENTORY_DESCRIPTION];
  388.                         ItemInfo(InventoryData[idx][pag + j][ObjectModel], InventoryData[idx][pag + j][TypeIndex], titulo, descricao);
  389.                        
  390.                         ShowInventoryItemInfo(playerid);
  391.                         PlayerTextDrawShow(playerid, __playerInvTD[playerid][i]);
  392.                         PlayerTextDrawSetPreviewModel(playerid, __playerInvTD[playerid][2], InventoryData[idx][pag + j][ObjectModel]);
  393.                         PlayerTextDrawShow(playerid, __playerInvTD[playerid][2]);
  394.                         PlayerTextDrawSetString(playerid, __playerInvTD[playerid][1], FixText(titulo));
  395.                         PlayerTextDrawShow(playerid, __playerInvTD[playerid][1]);
  396.                         PlayerTextDrawSetString(playerid, __playerInvTD[playerid][3], FixText(descricao));
  397.                         PlayerTextDrawShow(playerid, __playerInvTD[playerid][3]);
  398.                        
  399.                         CallLocalFunction("OnPlayerSelectItem", "iiiii", playerid, idx, InventoryData[idx][pag + j][ObjectModel], InventoryData[idx][pag + j][TypeIndex], pag + j);
  400.                     }
  401.                 }
  402.             }
  403.         }
  404.        
  405.         if(!validItem)
  406.         {
  407.             HideInventoryItemInfo(playerid);
  408.             CallLocalFunction("OnPlayerSelectItem", "iiiii", playerid, idx, INVALID_INVENTORY_ITEM, -1, -1);
  409.         }
  410.     }
  411.    
  412.     #if defined invOnPlayerClickDynamicTextdraw
  413.         invOnPlayerClickDynamicTextdraw(playerid, PlayerText:playertextid);
  414.     #endif
  415.     return true;
  416. }
  417.  
  418. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  419. {
  420.     if((newkeys & OPEN_INVENTORY_KEY == OPEN_INVENTORY_KEY) && (oldkeys & OPEN_INVENTORY_KEY != OPEN_INVENTORY_KEY))
  421.     {
  422.         for(new i = 0; i < MAX_SERVER_INVENTORY; i ++)
  423.         {
  424.             if(!IsValidInventory(Inventory:i))
  425.                 continue;
  426.            
  427.             if(IsPlayerInRangeOfPoint(playerid, 1.0, Inv[i][PosX], Inv[i][PosY], Inv[i][PosZ]))
  428.             {
  429.                 if(Inv[i][Interior] != -1 && GetPlayerInterior(playerid) != Inv[i][Interior])
  430.                     return true;
  431.                
  432.                 if(Inv[i][VirtualWorld] != -1 && GetPlayerVirtualWorld(playerid) != Inv[i][VirtualWorld])
  433.                     return true;
  434.                
  435.                 ShowInventory(Inventory:i, playerid);
  436.                 return true;
  437.             }
  438.         }
  439.     }
  440.     if((newkeys & GET_INVENTORY_ITEM_KEY == GET_INVENTORY_ITEM_KEY) && (oldkeys & GET_INVENTORY_ITEM_KEY != GET_INVENTORY_ITEM_KEY))
  441.     {
  442.         for(new i = 0; i < MAX_SERVER_DROPPED_ITEMS; i ++)
  443.         {
  444.             if(__tempServerObjectItem[i] == INVALID_OBJECT_ID)
  445.                 continue;
  446.            
  447.             if(IsPlayerInRangeOfPoint(playerid, 1.5, DroppedServerItemDataPos[i][0], DroppedServerItemDataPos[i][1], DroppedServerItemDataPos[i][2]))
  448.             {
  449.                 CallLocalFunction("OnPlayerGetDropedItem", "iiiii", playerid, i, DroppedServerItemData[i][ObjectModel], DroppedServerItemData[i][TypeIndex], DroppedServerItemData[i][Amount]);
  450.                 return true;
  451.             }
  452.         }
  453.     }
  454.    
  455.     #if defined invent_OnPlayerKeyStateChange
  456.         invent_OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
  457.     #endif
  458.     return true;
  459. }
  460.  
  461. stock Inventory:CreateStaticInventory(Float:x, Float:y, Float:z, max_items = MAX_INVENTORY_ITEMS, vw = -1, interior = -1, modelid = -1, Float:rx = 0.0, Float:ry = 0.0, Float:rz = 0.0, const label_text[] = "", destroy_delay = 0, Inventory:id = INVALID_INVENTORY_ID)
  462. {
  463.     new Inventory:idx = Inventory:GetAvaliableInventoryIndex();
  464.     if(idx == INVALID_INVENTORY_ID)
  465.         return INVALID_INVENTORY_ID;
  466.    
  467.     Inv[_:idx][ID] = 1;
  468.     Inv[_:idx][Static] = true;
  469.     Inv[_:idx][ObjectModel] = modelid;
  470.     Inv[_:idx][MaxItems] = max_items;
  471.     Inv[_:idx][PosX] = x;
  472.     Inv[_:idx][PosY] = y;
  473.     Inv[_:idx][PosZ] = z;
  474.     Inv[_:idx][VirtualWorld] = vw;
  475.     Inv[_:idx][Interior] = interior;
  476.     if(destroy_delay > 0)
  477.         Inv[_:idx][TimerDestroy] = SetTimerEx("Timer_DestroyInventory", destroy_delay, false, "ib", _:idx, true);
  478.     ClearInventory(idx);
  479.    
  480.     if(modelid != -1)
  481.         Inv[_:idx][ObjectID] = CreateDynamicObject(modelid, x, y, z, rx, ry, rz, vw, interior);
  482.    
  483.     if(label_text[0] != '\0')
  484.         Inv[_:idx][Label] = CreateDynamic3DTextLabel(label_text, -1, x, y, z, INVENTORY_LABEL_STREAM, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, vw, interior);
  485.    
  486.     if(id != INVALID_INVENTORY_ID)
  487.     {
  488.         for(new i = 0; i < MAX_INVENTORY_ITEMS; i ++)
  489.         {
  490.             InventoryData[_:idx][_:i][ObjectModel] = InventoryData[_:id][i][ObjectModel];
  491.             InventoryData[_:idx][_:i][TypeIndex] = InventoryData[_:id][i][TypeIndex];
  492.             InventoryData[_:idx][_:i][Amount] = InventoryData[_:id][i][Amount];
  493.             InventoryData[_:idx][_:i][ItemTitle] = InventoryData[_:id][i][ItemTitle];
  494.             InventoryData[_:idx][_:i][ItemDescription] = InventoryData[_:id][i][ItemDescription];
  495.         }
  496.     }
  497.    
  498.     CallLocalFunction("OnCreateStaticInventory", "ifffiiii", _:idx, x, y, z, vw, interior, destroy_delay, _:id);
  499.     return Inventory:idx;
  500. }
  501.  
  502. stock Inventory:CreateInventory(Inventory:id = INVALID_INVENTORY_ID, max_items = MAX_INVENTORY_ITEMS)
  503. {
  504.     new Inventory:idx = Inventory:GetAvaliableInventoryIndex();
  505.     if(idx == INVALID_INVENTORY_ID)
  506.         return INVALID_INVENTORY_ID;
  507.    
  508.     Inv[_:idx][ID] = 1;
  509.     Inv[_:idx][MaxItems] = max_items;
  510.     ClearInventory(idx);
  511.    
  512.     if(id != INVALID_INVENTORY_ID)
  513.     {
  514.         for(new i = 0; i < MAX_INVENTORY_ITEMS; i ++)
  515.         {
  516.             InventoryData[_:idx][_:i][ObjectModel] = InventoryData[_:id][i][ObjectModel];
  517.             InventoryData[_:idx][_:i][TypeIndex] = InventoryData[_:id][i][TypeIndex];
  518.             InventoryData[_:idx][_:i][Amount] = InventoryData[_:id][i][Amount];
  519.             InventoryData[_:idx][_:i][ItemTitle] = InventoryData[_:id][i][ItemTitle];
  520.             InventoryData[_:idx][_:i][ItemDescription] = InventoryData[_:id][i][ItemDescription];
  521.         }
  522.     }
  523.    
  524.     CallLocalFunction("OnCreateInventory", "ii", _:idx, _:id);
  525.     return Inventory:idx;
  526. }
  527.  
  528. forward Inventory:CreatePlayerInventory(playerid);
  529. stock Inventory:CreatePlayerInventory(playerid)
  530. {
  531.     CreatePlayerInventoryTD(playerid);
  532.     new Inventory:idx = CreateInventory();
  533.     return idx;
  534. }
  535.  
  536. stock Inventory:GetPlayerOpenedInventory(playerid)
  537. {
  538.     return Inventory:__tempNoInventario[playerid];
  539. }
  540.  
  541. forward Timer_DestroyInventory(Inventory:id);
  542. public Timer_DestroyInventory(Inventory:id)
  543. {
  544.     DestroyInventory(id);
  545.     return true;
  546. }
  547.  
  548. stock AddNewInventoryItem(item, type_index, const title[], const description[])
  549. {
  550.     new idx = GetFreeInventoryItemSlot();
  551.     if(idx == INVALID_INVENTORY_ITEM)
  552.         return false;
  553.    
  554.     __tempInventoryItems[idx][ObjectModel] = item;
  555.     __tempInventoryItems[idx][TypeIndex] = type_index;
  556.     strcat((__tempInventoryItems[idx][ItemTitle][0] = '\0', __tempInventoryItems[idx][ItemTitle]), title, MAX_INVENTORY_TITLE);
  557.     strcat((__tempInventoryItems[idx][ItemDescription][0] = '\0', __tempInventoryItems[idx][ItemDescription]), description, MAX_INVENTORY_DESCRIPTION);
  558.    
  559.     if(__tempInventoryItems[idx][ObjectModel] == 19820 && __tempInventoryItems[idx][TypeIndex] == 0)
  560.     {
  561.         printf("\n\n%s\n\n", __tempInventoryItems[idx][ItemTitle]);
  562.     }
  563.     return true;
  564. }
  565.  
  566. static stock GetFreeInventoryItemSlot()
  567. {
  568.     for(new i = 0; i < MAX_INTERNAL_INVENTORY_ITEMS; i ++)
  569.     {
  570.         if(__tempInventoryItems[i][ObjectModel] == INVALID_INVENTORY_ITEM)
  571.             return i;
  572.     }
  573.     return INVALID_INVENTORY_ITEM;
  574. }
  575.  
  576. stock AddItemInventory(Inventory:id, item, type_index, amount, index = -1)
  577. {
  578.     if(!IsValidInventory(id) || !IsValidInventoryItem(item, type_index))
  579.         return false;
  580.    
  581.     if(CountInventoryItems(id) >= Inv[_:id][MaxItems])
  582.         return false;
  583.    
  584.     if(index == -1)
  585.     {
  586.         new bool:itemExiste;
  587.         for(new i = 0; i < MAX_INVENTORY_ITEMS; i ++)
  588.         {
  589.             if(InventoryData[_:id][i][ObjectModel] == item && InventoryData[_:id][i][TypeIndex] == type_index)
  590.             {
  591.                 InventoryData[_:id][i][Amount] += amount;
  592.                 itemExiste = true;
  593.                 break;
  594.             }
  595.         }
  596.        
  597.         if(!itemExiste)
  598.         {
  599.             for(new i = 0; i < MAX_INVENTORY_ITEMS; i ++)
  600.             {
  601.                 if(InventoryData[_:id][i][ObjectModel] == INVALID_INVENTORY_ITEM)
  602.                 {
  603.                     InventoryData[_:id][i][ObjectModel] = item;
  604.                     InventoryData[_:id][i][TypeIndex] = type_index;
  605.                     InventoryData[_:id][i][Amount] = amount;
  606.                    
  607.                     new titulo[MAX_INVENTORY_TITLE], descricao[MAX_INVENTORY_DESCRIPTION];
  608.                     ItemInfo(item, type_index, titulo, descricao);
  609.                     InventoryData[_:id][i][ItemTitle][0] = '\0';
  610.                     InventoryData[_:id][i][ItemDescription][0] = '\0';
  611.                     strcat(InventoryData[_:id][i][ItemTitle], titulo);
  612.                     strcat(InventoryData[_:id][i][ItemDescription], descricao);
  613.                     break;
  614.                 }
  615.             }
  616.         }
  617.     }
  618.     else
  619.     {
  620.         if(index > -1 && index < MAX_INVENTORY_ITEMS)
  621.         {
  622.             InventoryData[_:id][index][ObjectModel] = item;
  623.             InventoryData[_:id][index][TypeIndex] = type_index;
  624.             InventoryData[_:id][index][Amount] = amount;
  625.            
  626.             new titulo[MAX_INVENTORY_TITLE], descricao[MAX_INVENTORY_DESCRIPTION];
  627.             ItemInfo(item, type_index, titulo, descricao);
  628.             InventoryData[_:id][index][ItemTitle][0] = '\0';
  629.             InventoryData[_:id][index][ItemDescription][0] = '\0';
  630.             strcat(InventoryData[_:id][index][ItemTitle], titulo);
  631.             strcat(InventoryData[_:id][index][ItemDescription], descricao);
  632.         }
  633.     }
  634.     return true;
  635. }
  636.  
  637. stock InfoInventoryItem(Inventory:id, index, &item, &type_index, &amount)
  638. {
  639.     if(!IsValidInventory(id))
  640.         return false;
  641.    
  642.     if(index < 0 || index > MAX_INVENTORY_ITEMS)
  643.         return false;
  644.    
  645.     item = InventoryData[_:id][index][ObjectModel];
  646.     type_index = InventoryData[_:id][index][TypeIndex];
  647.     amount = InventoryData[_:id][index][Amount];
  648.     return true;
  649. }
  650.  
  651. stock Inventory:GetStaticInventoryNearPlayer(playerid, Float:range)
  652. {
  653.     for(new i = 0; i < MAX_SERVER_INVENTORY; i ++)
  654.     {
  655.         if(!IsValidInventory(Inventory:i) || !Inv[i][Static])
  656.             continue;
  657.        
  658.         if(IsPlayerInRangeOfPoint(playerid, range, Inv[i][PosX], Inv[i][PosY], Inv[i][PosZ]))
  659.             return Inventory:i;
  660.     }
  661.     return INVALID_INVENTORY_ID;
  662. }
  663.  
  664. stock GetInventoryIndexAmount(Inventory:id, index)
  665. {
  666.     if(!IsValidInventory(id))
  667.         return 0;
  668.    
  669.     if(index < 0 || index > MAX_INVENTORY_ITEMS)
  670.         return 0;
  671.    
  672.     return InventoryData[_:id][index][Amount];
  673. }
  674.  
  675. stock GetInventoryItemAmount(Inventory:id, item, type_index)
  676. {
  677.     if(!IsValidInventory(id) || !IsValidInventoryItem(item, type_index))
  678.         return 0;
  679.    
  680.     for(new i = 0; i < MAX_INVENTORY_ITEMS; i ++)
  681.     {
  682.         if(InventoryData[_:id][i][ObjectModel] == item && InventoryData[_:id][i][TypeIndex] == type_index)
  683.             return InventoryData[_:id][i][Amount];
  684.     }
  685.    
  686.     return 0;
  687. }
  688.  
  689. stock ItemInfo(item, type_index, title[], description[])
  690. {
  691.     if(!IsValidInventoryItem(item, type_index))
  692.         return false;
  693.    
  694.     for(new i = 0; i < sizeof __tempInventoryItems; i ++)
  695.     {
  696.         if(__tempInventoryItems[i][ObjectModel] == item && __tempInventoryItems[i][TypeIndex] == type_index)
  697.         {
  698.             strcat(title, __tempInventoryItems[i][ItemTitle], MAX_INVENTORY_TITLE);
  699.             strcat(description, __tempInventoryItems[i][ItemDescription], MAX_INVENTORY_DESCRIPTION);
  700.             return true;
  701.         }
  702.     }
  703.     return false;
  704. }
  705.  
  706. stock RemoveInventoryItem(Inventory:id, item, type_index, amount = -1)
  707. {
  708.     if(!IsValidInventory(id) || !IsValidInventoryItem(item, type_index))
  709.         return false;
  710.    
  711.     for(new i = 0; i < MAX_INVENTORY_ITEMS; i ++)
  712.     {
  713.         if(InventoryData[_:id][i][ObjectModel] == item)
  714.         {
  715.             InventoryData[_:id][i][Amount] = amount > -1 ? (InventoryData[_:id][i][Amount] - amount) : 0;
  716.             if(InventoryData[_:id][i][Amount] <= 0)
  717.             {
  718.                 InventoryData[_:id][i][ObjectModel] = INVALID_INVENTORY_ITEM;
  719.                 InventoryData[_:id][i][Amount] = 0;
  720.                 InventoryData[_:id][i][ItemTitle][0] = '\0';
  721.                 InventoryData[_:id][i][ItemDescription][0] = '\0';
  722.             }
  723.             break;
  724.         }
  725.     }
  726.    
  727.     CallLocalFunction("OnRemoveInventoryItem", "iiii", _:id, item, type_index, amount);
  728.     return true;
  729. }
  730.  
  731. stock RemoveInventoryItemIndex(Inventory:id, index)
  732. {
  733.     if(!IsValidInventory(id))
  734.         return false;
  735.    
  736.     InventoryData[_:id][index][ObjectModel] = INVALID_INVENTORY_ITEM;
  737.     InventoryData[_:id][index][Amount] = 0;
  738.     InventoryData[_:id][index][ItemTitle][0] = '\0';
  739.     InventoryData[_:id][index][ItemDescription][0] = '\0';
  740.     return true;
  741. }
  742.  
  743. stock HaveInventoryItem(Inventory:id, item, type_index)
  744. {
  745.     if(!IsValidInventory(id) || !IsValidInventoryItem(item, type_index))
  746.         return false;
  747.    
  748.     for(new i = 0; i < MAX_INVENTORY_ITEMS; i ++)
  749.     {
  750.         if(InventoryData[_:id][i][ObjectModel] == item && InventoryData[_:id][i][TypeIndex] == type_index)
  751.             return true;
  752.     }
  753.     return false;
  754. }
  755.  
  756. stock ClearInventory(Inventory:id)
  757. {
  758.     if(!IsValidInventory(id))
  759.         return false;
  760.    
  761.     for(new i = 0; i < MAX_INVENTORY_ITEMS; i ++)
  762.     {
  763.         InventoryData[_:id][i][ObjectModel] = INVALID_INVENTORY_ITEM;
  764.         InventoryData[_:id][i][Amount] = 0;
  765.         InventoryData[_:id][i][ItemTitle][0] = '\0';
  766.         InventoryData[_:id][i][ItemDescription][0] = '\0';
  767.     }
  768.     return true;
  769. }
  770.  
  771. stock IsValidInventory(Inventory:id)
  772. {
  773.     if(_:id < 0 || _:id > MAX_SERVER_INVENTORY)
  774.         return false;
  775.     return (Inv[_:id][ID] == 1);
  776. }
  777.  
  778. stock IsStaticInventory(Inventory:id)
  779. {
  780.     if(!IsValidInventory(id))
  781.         return false;
  782.    
  783.     return Inv[_:id][Static];
  784. }
  785.  
  786. stock IsTemporaryInventory(Inventory:id)
  787. {
  788.     if(!IsValidInventory(id))
  789.         return false;
  790.    
  791.     return Inv[_:id][TimerDestroy] > 0;
  792. }
  793.  
  794. stock CountInventoryItems(Inventory:id)
  795. {
  796.     if(!IsValidInventory(id))
  797.         return -1;
  798.    
  799.     new itens = 0;
  800.     for(new i = 0; i < MAX_INVENTORY_ITEMS; i ++)
  801.     {
  802.         if(InventoryData[_:id][i][ObjectModel] != INVALID_INVENTORY_ITEM)
  803.             itens ++;
  804.     }
  805.     return itens;
  806. }
  807.  
  808. stock SetInventoryMaxItems(Inventory:id, max_items)
  809. {
  810.     if(!IsValidInventory(id))
  811.         return false;
  812.    
  813.     if(max_items < 1)
  814.         max_items = 1;
  815.     else if(max_items > MAX_INVENTORY_ITEMS)
  816.         max_items = MAX_INVENTORY_ITEMS;
  817.    
  818.     Inv[_:id][MaxItems] = max_items;
  819.     return true;
  820. }
  821.  
  822. stock GetInventoryMaxItems(Inventory:id)
  823. {
  824.     if(!IsValidInventory(id))
  825.         return 0;
  826.    
  827.     return Inv[_:id][MaxItems];
  828. }
  829.  
  830. stock GetLastInventoryItemIndex(Inventory:id)
  831. {
  832.     if(!IsValidInventory(id))
  833.         return -1;
  834.    
  835.     for(new i = MAX_INVENTORY_ITEMS - 1; i > -1; i --)
  836.     {
  837.         if(InventoryData[_:id][i][ObjectModel] != INVALID_INVENTORY_ITEM)
  838.             return i;
  839.     }
  840.     return -1;
  841. }
  842.  
  843. stock IsValidInventoryItem(item, type_index)
  844. {
  845.     for(new i = 0; i < sizeof __tempInventoryItems; i ++)
  846.     {
  847.         if(__tempInventoryItems[i][ObjectModel] == item && __tempInventoryItems[i][TypeIndex] == type_index)
  848.             return true;
  849.     }
  850.     return false;
  851. }
  852.  
  853. stock GetInventoryItemIndex(Inventory:id, item, type_index)
  854. {
  855.     for(new i = 0; i < MAX_INVENTORY_ITEMS; i ++)
  856.     {
  857.         if(InventoryData[_:id][i][ObjectModel] == item && InventoryData[_:id][i][TypeIndex] == type_index)
  858.             return i;
  859.     }
  860.     return -1;
  861. }
  862.  
  863. static stock GetFreeDroppedItemSlot()
  864. {
  865.     for(new i = 0; i < MAX_SERVER_DROPPED_ITEMS; i ++)
  866.     {
  867.         if(__tempServerObjectItem[i] == INVALID_OBJECT_ID)
  868.             return i;
  869.     }
  870.     return -1;
  871. }
  872.  
  873. stock CreateDropItem(item, type_index, amount, Float:x, Float:y, Float:z, Float:rx = 0.0, Float:ry = 0.0, Float:rz = 0.0, vw = -1, interior = -1)
  874. {
  875.     new idxDrop = GetFreeDroppedItemSlot();
  876.     if(!IsValidInventoryItem(item, type_index) || idxDrop == -1)
  877.         return false;
  878.    
  879.     new title[MAX_INVENTORY_TITLE], description[MAX_INVENTORY_DESCRIPTION];
  880.     ItemInfo(item, type_index, title, description);
  881.    
  882.     __tempServerObjectItem[idxDrop] = CreateDynamicObject(item, x, y, z, rx, ry, rz, vw, interior);
  883.    
  884.     new label[50];
  885.     format(label, sizeof label, "%s\nPressione Y", title);
  886.     __tempServerObjectLabel[idxDrop] = CreateDynamic3DTextLabel(label, -1, x, y, z, INVENTORY_LABEL_STREAM, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, vw, interior);
  887.    
  888.     DroppedServerItemData[idxDrop][ObjectModel] = item;
  889.     DroppedServerItemData[idxDrop][TypeIndex] = type_index;
  890.     DroppedServerItemData[idxDrop][Amount] = amount;
  891.     strcat((DroppedServerItemData[idxDrop][ItemTitle][0] = '\0', DroppedServerItemData[idxDrop][ItemTitle]), title, MAX_INVENTORY_TITLE);
  892.     strcat((DroppedServerItemData[idxDrop][ItemDescription][0] = '\0', DroppedServerItemData[idxDrop][ItemDescription]), description, MAX_INVENTORY_DESCRIPTION);
  893.     DroppedServerItemDataPos[idxDrop][0] = x;
  894.     DroppedServerItemDataPos[idxDrop][1] = y;
  895.     DroppedServerItemDataPos[idxDrop][2] = z;
  896.     return true;
  897. }
  898.  
  899. stock RemoveDroppedItem(dropped_index)
  900. {
  901.     DestroyDynamicObject(__tempServerObjectItem[dropped_index]);
  902.     __tempServerObjectItem[dropped_index] = INVALID_OBJECT_ID;
  903.     DestroyDynamic3DTextLabel(__tempServerObjectLabel[dropped_index]);
  904.     __tempServerObjectLabel[dropped_index] = Text3D:0;
  905.    
  906.     DroppedServerItemData[dropped_index][ObjectModel] = INVALID_INVENTORY_ITEM;
  907.     DroppedServerItemData[dropped_index][TypeIndex] = 0;
  908.     DroppedServerItemData[dropped_index][Amount] = 0;
  909.     DroppedServerItemData[dropped_index][ItemTitle][0] = '\0';
  910.     DroppedServerItemData[dropped_index][ItemDescription][0] = '\0';
  911.     DroppedServerItemDataPos[dropped_index][0] = 0.0;
  912.     DroppedServerItemDataPos[dropped_index][1] = 0.0;
  913.     DroppedServerItemDataPos[dropped_index][2] = 0.0;
  914.     return true;
  915. }
  916.  
  917. stock CountDroppedItem(item, type_index = 0)
  918. {
  919.     new count;
  920.     for(new i = 0; i < MAX_SERVER_DROPPED_ITEMS; i ++)
  921.     {
  922.         if(DroppedServerItemData[i][ObjectModel] == INVALID_INVENTORY_ITEM)
  923.             continue;
  924.        
  925.         if(DroppedServerItemData[i][ObjectModel] == item && DroppedServerItemData[i][TypeIndex] == type_index)
  926.             count++;
  927.     }
  928.     return count;
  929. }
  930.  
  931. stock CountDroppedItems()
  932. {
  933.     new count;
  934.     for(new i = 0; i < MAX_SERVER_DROPPED_ITEMS; i ++)
  935.     {
  936.         if(DroppedServerItemData[i][ObjectModel] != INVALID_INVENTORY_ITEM)
  937.             count ++;
  938.     }
  939.     return count;
  940. }
  941.  
  942. stock ShowInventory(Inventory:id, playerid, page = 1, bool:button_use = true, bool:button_drop = true)
  943. {
  944.     if(!IsValidInventory(id) || page < 1)
  945.         return false;
  946.    
  947.     __tempInvAtivo[playerid] = true;
  948.    
  949.     new ultimo_item = GetLastInventoryItemIndex(id);
  950.     new max_paginas = floatround(float(ultimo_item) / 12, floatround_ceil);
  951.     new a_fim_pagina = page == 1 ? 12 : page * 12 - 1;
  952.     new a_inicio_pagina = page == 1 ? 0 : a_fim_pagina - 12 + 1;
  953.    
  954.     if(__tempNoInventario[playerid] == _:INVALID_INVENTORY_ID)
  955.         CallLocalFunction("OnPlayerOpenInventory", "ii", playerid, _:id);
  956.    
  957.     __tempNoInventario[playerid] = _:id;
  958.     __tempBotaoUsar[playerid] = button_use;
  959.     __tempBotaoSoltar[playerid] = button_drop;
  960.     __tempPaginaSelecionada[playerid] = page;
  961.     __tempPaginaInicial[playerid] = a_inicio_pagina;
  962.    
  963.     new stringInv[20];
  964.     format(stringInv, sizeof stringInv, "Inventario (%i/%i)", page, max_paginas < 1 ? 1 : max_paginas);
  965.     PlayerTextDrawSetString(playerid, __playerInvTD[playerid][0], stringInv);
  966.    
  967.     PlayerTextDrawSetPreviewModel(playerid, __playerInvTD[playerid][2], INVALID_INVENTORY_ITEM);
  968.     PlayerTextDrawSetString(playerid, __playerInvTD[playerid][1], "_");
  969.     PlayerTextDrawShow(playerid, __playerInvTD[playerid][1]);
  970.     PlayerTextDrawSetString(playerid, __playerInvTD[playerid][3], "_");
  971.     PlayerTextDrawShow(playerid, __playerInvTD[playerid][3]);
  972.    
  973.     for(new i = 0; i <= 3; i ++)
  974.         TextDrawShowForPlayer(playerid, __globalInvTD[i]);
  975.    
  976.     for(new i = 4, j = 0; i <= 15; i ++, j++) // Itens
  977.     {
  978.         PlayerTextDrawSetPreviewModel(playerid, __playerInvTD[playerid][i], InventoryData[_:id][a_inicio_pagina + j][ObjectModel]);
  979.     }
  980.  
  981.     for(new i = 16, j = 0; i <= 27; i ++, j++) // Valores do itens
  982.     {
  983.         format(stringInv, sizeof stringInv, "%i", InventoryData[_:id][a_inicio_pagina + j][Amount]);
  984.         PlayerTextDrawSetString(playerid, __playerInvTD[playerid][i], stringInv);
  985.     }
  986.    
  987.     for(new i = 4; i <= 15; i ++)
  988.         PlayerTextDrawShow(playerid, __playerInvTD[playerid][i]);
  989.    
  990.     for(new i = 4; i <= 15; i ++)
  991.         PlayerTextDrawColor(playerid, __playerInvTD[playerid][i], -1);
  992.    
  993.     for(new i = 16, j = 0; i <= 27; i ++, j ++)
  994.     {
  995.         if(InventoryData[_:id][a_inicio_pagina + j][ObjectModel] != INVALID_INVENTORY_ITEM)
  996.             PlayerTextDrawShow(playerid, __playerInvTD[playerid][i]);
  997.     }
  998.    
  999.     HideInventoryItemInfo(playerid);
  1000.    
  1001.     SelectTextDraw(playerid, 1687547391);
  1002.     return true;
  1003. }
  1004.  
  1005. stock ShowInventoryItemInfo(playerid)
  1006. {
  1007.     TextDrawShowForPlayer(playerid, __globalInvTD[4]);
  1008.     if(__tempBotaoUsar[playerid])
  1009.         TextDrawShowForPlayer(playerid, __globalInvTD[5]);
  1010.     if(__tempBotaoSoltar[playerid])
  1011.         TextDrawShowForPlayer(playerid, __globalInvTD[6]);
  1012.    
  1013.     for(new i = 1; i <= 3; i ++)
  1014.         PlayerTextDrawShow(playerid, __playerInvTD[playerid][i]);
  1015. }
  1016.  
  1017. stock HideInventoryItemInfo(playerid)
  1018. {
  1019.     for(new i = 4; i <= 6; i ++)
  1020.         TextDrawHideForPlayer(playerid, __globalInvTD[i]);
  1021.    
  1022.     for(new i = 1; i <= 3; i ++)
  1023.         PlayerTextDrawHide(playerid, __playerInvTD[playerid][i]);
  1024. }
  1025.  
  1026. stock HideInventory(playerid)
  1027. {
  1028.     __tempInvAtivo[playerid] = false;
  1029.    
  1030.     for(new i = 0; i <= 6; i ++)
  1031.         TextDrawHideForPlayer(playerid, __globalInvTD[i]);
  1032.    
  1033.     for(new i = 0; i <= 27; i ++)
  1034.         PlayerTextDrawHide(playerid, __playerInvTD[playerid][i]);
  1035.    
  1036.     if(__tempNoInventario[playerid] != _:INVALID_INVENTORY_ID)
  1037.         CallLocalFunction("OnPlayerCloseInventory", "ii", playerid, __tempNoInventario[playerid]);
  1038.    
  1039.     CancelSelectTextDraw(playerid);
  1040.     __tempNoInventario[playerid] = _:INVALID_INVENTORY_ID;
  1041.     __tempItemSelecionado[playerid] = -1;
  1042.     __tempPaginaInicial[playerid] = 0;
  1043.     __tempPaginaSelecionada[playerid] = 0;
  1044.     __tempTextdrawSelecionada[playerid] = INVALID_TEXT_DRAW;
  1045.     return true;
  1046. }
  1047.  
  1048. stock DestroyInventory(Inventory:id)
  1049. {
  1050.     if(!IsValidInventory(id))
  1051.         return false;
  1052.    
  1053.     foreach(new i : Player)
  1054.     {
  1055.         if(__tempNoInventario[i] == _:id)
  1056.         {
  1057.             __tempNoInventario[i] = _:INVALID_INVENTORY_ID;
  1058.             HideInventory(i);
  1059.             CallLocalFunction("OnDestroyOpenedInventory", "ii", i, _:id);
  1060.         }
  1061.     }
  1062.    
  1063.     CallLocalFunction("OnDestroyInventory", "ii", _:id, Inv[_:id][Static]);
  1064.    
  1065.     KillTimer(Inv[_:id][TimerDestroy]);
  1066.     DestroyDynamicObject(Inv[_:id][ObjectID]);
  1067.     DestroyDynamic3DTextLabel(Inv[_:id][Label]);
  1068.     ClearInventory(id);
  1069.     new reset[E_INVENTARIO_SERVER_DATA];
  1070.     Inv[_:id] = reset;
  1071.     return true;
  1072. }
  1073.  
  1074. static stock GetAvaliableInventoryIndex()
  1075. {
  1076.     for(new i = 0; i < MAX_SERVER_INVENTORY; i ++)
  1077.     {
  1078.         if(Inv[i][ID] == 0)
  1079.             return i;
  1080.     }
  1081.     return -1;
  1082. }
  1083.  
  1084. static stock DestroyInventoryTD(playerid)
  1085. {
  1086.     for(new ii = 0; ii <= 27; ii ++)
  1087.     {
  1088.         PlayerTextDrawDestroy(playerid, __playerInvTD[playerid][ii]);
  1089.         __playerInvTD[playerid][ii] = PlayerText:INVALID_TEXT_DRAW;
  1090.     }
  1091.     return true;
  1092. }
  1093.  
  1094. static stock CreateInventoryTD()
  1095. {
  1096.     __globalInvTD[0] = TextDrawCreate(151.000, 174.000, "_");
  1097.     TextDrawLetterSize(__globalInvTD[0], 0.000, 26.100);
  1098.     TextDrawTextSize(__globalInvTD[0], 441.000, 0.000);
  1099.     TextDrawAlignment(__globalInvTD[0], 1);
  1100.     TextDrawColor(__globalInvTD[0], 255);
  1101.     TextDrawUseBox(__globalInvTD[0], 1);
  1102.     TextDrawBoxColor(__globalInvTD[0], 1684300950);
  1103.     TextDrawSetShadow(__globalInvTD[0], 1);
  1104.     TextDrawSetOutline(__globalInvTD[0], 1);
  1105.     TextDrawBackgroundColor(__globalInvTD[0], 255);
  1106.     TextDrawFont(__globalInvTD[0], 0);
  1107.     TextDrawSetProportional(__globalInvTD[0], 1);
  1108.  
  1109.     __globalInvTD[1] = TextDrawCreate(426.000, 174.000, "X");
  1110.     TextDrawLetterSize(__globalInvTD[1], 0.689, 1.798);
  1111.     TextDrawTextSize(__globalInvTD[1], 13.000, 19.000);
  1112.     TextDrawAlignment(__globalInvTD[1], 2);
  1113.     TextDrawColor(__globalInvTD[1], -1);
  1114.     TextDrawSetShadow(__globalInvTD[1], 0);
  1115.     TextDrawSetOutline(__globalInvTD[1], 1);
  1116.     TextDrawBackgroundColor(__globalInvTD[1], -16776961);
  1117.     TextDrawFont(__globalInvTD[1], 1);
  1118.     TextDrawSetProportional(__globalInvTD[1], 1);
  1119.     TextDrawSetSelectable(__globalInvTD[1], 1);
  1120.  
  1121.     __globalInvTD[2] = TextDrawCreate(318.000, 173.000, "LD_BEAT:left");
  1122.     TextDrawTextSize(__globalInvTD[2], 21.000, 20.000);
  1123.     TextDrawAlignment(__globalInvTD[2], 1);
  1124.     TextDrawColor(__globalInvTD[2], -1);
  1125.     TextDrawSetShadow(__globalInvTD[2], 0);
  1126.     TextDrawSetOutline(__globalInvTD[2], 0);
  1127.     TextDrawBackgroundColor(__globalInvTD[2], 255);
  1128.     TextDrawFont(__globalInvTD[2], 4);
  1129.     TextDrawSetProportional(__globalInvTD[2], 1);
  1130.     TextDrawSetSelectable(__globalInvTD[2], 1);
  1131.  
  1132.     __globalInvTD[3] = TextDrawCreate(366.000, 173.000, "LD_BEAT:right");
  1133.     TextDrawTextSize(__globalInvTD[3], 21.000, 20.000);
  1134.     TextDrawAlignment(__globalInvTD[3], 1);
  1135.     TextDrawColor(__globalInvTD[3], -1);
  1136.     TextDrawSetShadow(__globalInvTD[3], 0);
  1137.     TextDrawSetOutline(__globalInvTD[3], 0);
  1138.     TextDrawBackgroundColor(__globalInvTD[3], 255);
  1139.     TextDrawFont(__globalInvTD[3], 4);
  1140.     TextDrawSetProportional(__globalInvTD[3], 1);
  1141.     TextDrawSetSelectable(__globalInvTD[3], 1);
  1142.  
  1143.     __globalInvTD[4] = TextDrawCreate(444.000, 174.000, "_");
  1144.     TextDrawLetterSize(__globalInvTD[4], 0.000, 26.100);
  1145.     TextDrawTextSize(__globalInvTD[4], 574.000, 0.000);
  1146.     TextDrawAlignment(__globalInvTD[4], 1);
  1147.     TextDrawColor(__globalInvTD[4], 255);
  1148.     TextDrawUseBox(__globalInvTD[4], 1);
  1149.     TextDrawBoxColor(__globalInvTD[4], 1684300950);
  1150.     TextDrawSetShadow(__globalInvTD[4], 1);
  1151.     TextDrawSetOutline(__globalInvTD[4], 1);
  1152.     TextDrawBackgroundColor(__globalInvTD[4], 255);
  1153.     TextDrawFont(__globalInvTD[4], 0);
  1154.     TextDrawSetProportional(__globalInvTD[4], 1);
  1155.  
  1156.     __globalInvTD[5] = TextDrawCreate(477.000, 390.000, "Usar");
  1157.     TextDrawLetterSize(__globalInvTD[5], 0.319, 1.600);
  1158.     TextDrawTextSize(__globalInvTD[5], 14.000, 58.000);
  1159.     TextDrawAlignment(__globalInvTD[5], 2);
  1160.     TextDrawColor(__globalInvTD[5], -1199174657);
  1161.     TextDrawUseBox(__globalInvTD[5], 1);
  1162.     TextDrawBoxColor(__globalInvTD[5], 150);
  1163.     TextDrawSetShadow(__globalInvTD[5], 1);
  1164.     TextDrawSetOutline(__globalInvTD[5], 1);
  1165.     TextDrawBackgroundColor(__globalInvTD[5], 150);
  1166.     TextDrawFont(__globalInvTD[5], 2);
  1167.     TextDrawSetProportional(__globalInvTD[5], 1);
  1168.     TextDrawSetSelectable(__globalInvTD[5], 1);
  1169.  
  1170.     __globalInvTD[6] = TextDrawCreate(541.000, 390.000, "Soltar");
  1171.     TextDrawLetterSize(__globalInvTD[6], 0.319, 1.600);
  1172.     TextDrawTextSize(__globalInvTD[6], 14.000, 58.000);
  1173.     TextDrawAlignment(__globalInvTD[6], 2);
  1174.     TextDrawColor(__globalInvTD[6], 2005441023);
  1175.     TextDrawUseBox(__globalInvTD[6], 1);
  1176.     TextDrawBoxColor(__globalInvTD[6], 150);
  1177.     TextDrawSetShadow(__globalInvTD[6], 1);
  1178.     TextDrawSetOutline(__globalInvTD[6], 1);
  1179.     TextDrawBackgroundColor(__globalInvTD[6], 150);
  1180.     TextDrawFont(__globalInvTD[6], 2);
  1181.     TextDrawSetProportional(__globalInvTD[6], 1);
  1182.     TextDrawSetSelectable(__globalInvTD[6], 1);
  1183. }
  1184.  
  1185. static stock CreatePlayerInventoryTD(playerid)
  1186. {
  1187.     if(!IsPlayerConnected(playerid))
  1188.         return false;
  1189.    
  1190.     new tituloInv[20 + MAX_PLAYER_NAME];
  1191.     format(tituloInv, sizeof tituloInv, "Inventario de: %s", NomeJogador(playerid));
  1192.    
  1193.     //InvTD[MAX_PLAYERS][5]
  1194.     __playerInvTD[playerid][0] = CreatePlayerTextDraw(playerid, 156.000, 175.000, "Inventario (1/1)");
  1195.     PlayerTextDrawLetterSize(playerid, __playerInvTD[playerid][0], 0.509, 1.599);
  1196.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][0], 1);
  1197.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][0], -1);
  1198.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][0], 1);
  1199.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][0], 1);
  1200.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][0], 150);
  1201.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][0], 3);
  1202.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][0], 1);
  1203.  
  1204.     __playerInvTD[playerid][1] = CreatePlayerTextDraw(playerid, 510.000, 177.000, "Nome_Do_Item");
  1205.     PlayerTextDrawLetterSize(playerid, __playerInvTD[playerid][1], 0.230, 1.399);
  1206.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][1], 2);
  1207.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][1], -1);
  1208.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][1], 1);
  1209.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][1], 1);
  1210.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][1], 150);
  1211.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][1], 2);
  1212.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][1], 1);
  1213.  
  1214.     __playerInvTD[playerid][2] = CreatePlayerTextDraw(playerid, 454.000, 191.000, "_");
  1215.     PlayerTextDrawTextSize(playerid, __playerInvTD[playerid][2], 109.000, 113.000);
  1216.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][2], 1);
  1217.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][2], -1);
  1218.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][2], 0);
  1219.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][2], 0);
  1220.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][2], 0);
  1221.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][2], 5);
  1222.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][2], 0);
  1223.     PlayerTextDrawSetPreviewModel(playerid, __playerInvTD[playerid][2], -1);
  1224.     PlayerTextDrawSetPreviewRot(playerid, __playerInvTD[playerid][2], 0.000, 0.000, 0.000, 1.000);
  1225.     PlayerTextDrawSetPreviewVehCol(playerid, __playerInvTD[playerid][2], 0, 0);
  1226.  
  1227.     __playerInvTD[playerid][3] = CreatePlayerTextDraw(playerid, 451.000, 302.000, "Descricao do item~n~clicado");
  1228.     PlayerTextDrawLetterSize(playerid, __playerInvTD[playerid][3], 0.300, 1.500);
  1229.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][3], 1);
  1230.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][3], -1);
  1231.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][3], 1);
  1232.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][3], 1);
  1233.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][3], 150);
  1234.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][3], 1);
  1235.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][3], 1);
  1236.  
  1237.     __playerInvTD[playerid][4] = CreatePlayerTextDraw(playerid, 153.000, 193.000, "_");
  1238.     PlayerTextDrawTextSize(playerid, __playerInvTD[playerid][4], 70.000, 70.000);
  1239.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][4], 1);
  1240.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][4], -1);
  1241.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][4], 0);
  1242.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][4], 0);
  1243.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][4], 1887473789);
  1244.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][4], 5);
  1245.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][4], 0);
  1246.     PlayerTextDrawSetPreviewModel(playerid, __playerInvTD[playerid][4], -1);
  1247.     PlayerTextDrawSetPreviewRot(playerid, __playerInvTD[playerid][4], 0.000, 0.000, 0.000, 1.000);
  1248.     PlayerTextDrawSetPreviewVehCol(playerid, __playerInvTD[playerid][4], 0, 0);
  1249.     PlayerTextDrawSetSelectable(playerid, __playerInvTD[playerid][4], 1);
  1250.  
  1251.     __playerInvTD[playerid][5] = CreatePlayerTextDraw(playerid, 225.000, 193.000, "_");
  1252.     PlayerTextDrawTextSize(playerid, __playerInvTD[playerid][5], 70.000, 70.000);
  1253.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][5], 1);
  1254.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][5], -1);
  1255.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][5], 0);
  1256.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][5], 0);
  1257.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][5], 1887473789);
  1258.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][5], 5);
  1259.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][5], 0);
  1260.     PlayerTextDrawSetPreviewModel(playerid, __playerInvTD[playerid][5], -1);
  1261.     PlayerTextDrawSetPreviewRot(playerid, __playerInvTD[playerid][5], 0.000, 0.000, 0.000, 1.000);
  1262.     PlayerTextDrawSetPreviewVehCol(playerid, __playerInvTD[playerid][5], 0, 0);
  1263.     PlayerTextDrawSetSelectable(playerid, __playerInvTD[playerid][5], 1);
  1264.  
  1265.     __playerInvTD[playerid][6] = CreatePlayerTextDraw(playerid, 297.000, 193.000, "_");
  1266.     PlayerTextDrawTextSize(playerid, __playerInvTD[playerid][6], 70.000, 70.000);
  1267.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][6], 1);
  1268.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][6], -1);
  1269.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][6], 0);
  1270.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][6], 0);
  1271.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][6], 1887473789);
  1272.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][6], 5);
  1273.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][6], 0);
  1274.     PlayerTextDrawSetPreviewModel(playerid, __playerInvTD[playerid][6], -1);
  1275.     PlayerTextDrawSetPreviewRot(playerid, __playerInvTD[playerid][6], 0.000, 0.000, 0.000, 1.000);
  1276.     PlayerTextDrawSetPreviewVehCol(playerid, __playerInvTD[playerid][6], 0, 0);
  1277.     PlayerTextDrawSetSelectable(playerid, __playerInvTD[playerid][6], 1);
  1278.  
  1279.     __playerInvTD[playerid][7] = CreatePlayerTextDraw(playerid, 369.000, 193.000, "_");
  1280.     PlayerTextDrawTextSize(playerid, __playerInvTD[playerid][7], 70.000, 70.000);
  1281.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][7], 1);
  1282.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][7], -1);
  1283.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][7], 0);
  1284.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][7], 0);
  1285.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][7], 1887473789);
  1286.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][7], 5);
  1287.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][7], 0);
  1288.     PlayerTextDrawSetPreviewModel(playerid, __playerInvTD[playerid][7], -1);
  1289.     PlayerTextDrawSetPreviewRot(playerid, __playerInvTD[playerid][7], 0.000, 0.000, 0.000, 1.000);
  1290.     PlayerTextDrawSetPreviewVehCol(playerid, __playerInvTD[playerid][7], 0, 0);
  1291.     PlayerTextDrawSetSelectable(playerid, __playerInvTD[playerid][7], 1);
  1292.  
  1293.     __playerInvTD[playerid][8] = CreatePlayerTextDraw(playerid, 153.000, 265.000, "_");
  1294.     PlayerTextDrawTextSize(playerid, __playerInvTD[playerid][8], 70.000, 70.000);
  1295.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][8], 1);
  1296.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][8], -1);
  1297.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][8], 0);
  1298.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][8], 0);
  1299.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][8], 1887473789);
  1300.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][8], 5);
  1301.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][8], 0);
  1302.     PlayerTextDrawSetPreviewModel(playerid, __playerInvTD[playerid][8], -1);
  1303.     PlayerTextDrawSetPreviewRot(playerid, __playerInvTD[playerid][8], 0.000, 0.000, 0.000, 1.000);
  1304.     PlayerTextDrawSetPreviewVehCol(playerid, __playerInvTD[playerid][8], 0, 0);
  1305.     PlayerTextDrawSetSelectable(playerid, __playerInvTD[playerid][8], 1);
  1306.  
  1307.     __playerInvTD[playerid][9] = CreatePlayerTextDraw(playerid, 225.000, 265.000, "_");
  1308.     PlayerTextDrawTextSize(playerid, __playerInvTD[playerid][9], 70.000, 70.000);
  1309.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][9], 1);
  1310.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][9], -1);
  1311.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][9], 0);
  1312.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][9], 0);
  1313.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][9], 1887473789);
  1314.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][9], 5);
  1315.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][9], 0);
  1316.     PlayerTextDrawSetPreviewModel(playerid, __playerInvTD[playerid][9], -1);
  1317.     PlayerTextDrawSetPreviewRot(playerid, __playerInvTD[playerid][9], 0.000, 0.000, 0.000, 1.000);
  1318.     PlayerTextDrawSetPreviewVehCol(playerid, __playerInvTD[playerid][9], 0, 0);
  1319.     PlayerTextDrawSetSelectable(playerid, __playerInvTD[playerid][9], 1);
  1320.  
  1321.     __playerInvTD[playerid][10] = CreatePlayerTextDraw(playerid, 297.000, 265.000, "_");
  1322.     PlayerTextDrawTextSize(playerid, __playerInvTD[playerid][10], 70.000, 70.000);
  1323.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][10], 1);
  1324.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][10], -1);
  1325.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][10], 0);
  1326.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][10], 0);
  1327.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][10], 1887473789);
  1328.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][10], 5);
  1329.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][10], 0);
  1330.     PlayerTextDrawSetPreviewModel(playerid, __playerInvTD[playerid][10], -1);
  1331.     PlayerTextDrawSetPreviewRot(playerid, __playerInvTD[playerid][10], 0.000, 0.000, 0.000, 1.000);
  1332.     PlayerTextDrawSetPreviewVehCol(playerid, __playerInvTD[playerid][10], 0, 0);
  1333.     PlayerTextDrawSetSelectable(playerid, __playerInvTD[playerid][10], 1);
  1334.  
  1335.     __playerInvTD[playerid][11] = CreatePlayerTextDraw(playerid, 369.000, 265.000, "_");
  1336.     PlayerTextDrawTextSize(playerid, __playerInvTD[playerid][11], 70.000, 70.000);
  1337.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][11], 1);
  1338.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][11], -1);
  1339.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][11], 0);
  1340.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][11], 0);
  1341.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][11], 1887473789);
  1342.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][11], 5);
  1343.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][11], 0);
  1344.     PlayerTextDrawSetPreviewModel(playerid, __playerInvTD[playerid][11], -1);
  1345.     PlayerTextDrawSetPreviewRot(playerid, __playerInvTD[playerid][11], 0.000, 0.000, 0.000, 1.000);
  1346.     PlayerTextDrawSetPreviewVehCol(playerid, __playerInvTD[playerid][11], 0, 0);
  1347.     PlayerTextDrawSetSelectable(playerid, __playerInvTD[playerid][11], 1);
  1348.  
  1349.     __playerInvTD[playerid][12] = CreatePlayerTextDraw(playerid, 153.000, 337.000, "_");
  1350.     PlayerTextDrawTextSize(playerid, __playerInvTD[playerid][12], 70.000, 70.000);
  1351.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][12], 1);
  1352.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][12], -1);
  1353.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][12], 0);
  1354.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][12], 0);
  1355.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][12], 1887473789);
  1356.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][12], 5);
  1357.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][12], 0);
  1358.     PlayerTextDrawSetPreviewModel(playerid, __playerInvTD[playerid][12], -1);
  1359.     PlayerTextDrawSetPreviewRot(playerid, __playerInvTD[playerid][12], 0.000, 0.000, 0.000, 1.000);
  1360.     PlayerTextDrawSetPreviewVehCol(playerid, __playerInvTD[playerid][12], 0, 0);
  1361.     PlayerTextDrawSetSelectable(playerid, __playerInvTD[playerid][12], 1);
  1362.  
  1363.     __playerInvTD[playerid][13] = CreatePlayerTextDraw(playerid, 225.000, 337.000, "_");
  1364.     PlayerTextDrawTextSize(playerid, __playerInvTD[playerid][13], 70.000, 70.000);
  1365.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][13], 1);
  1366.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][13], -1);
  1367.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][13], 0);
  1368.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][13], 0);
  1369.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][13], 1887473789);
  1370.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][13], 5);
  1371.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][13], 0);
  1372.     PlayerTextDrawSetPreviewModel(playerid, __playerInvTD[playerid][13], -1);
  1373.     PlayerTextDrawSetPreviewRot(playerid, __playerInvTD[playerid][13], 0.000, 0.000, 0.000, 1.000);
  1374.     PlayerTextDrawSetPreviewVehCol(playerid, __playerInvTD[playerid][13], 0, 0);
  1375.     PlayerTextDrawSetSelectable(playerid, __playerInvTD[playerid][13], 1);
  1376.  
  1377.     __playerInvTD[playerid][14] = CreatePlayerTextDraw(playerid, 297.000, 337.000, "_");
  1378.     PlayerTextDrawTextSize(playerid, __playerInvTD[playerid][14], 70.000, 70.000);
  1379.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][14], 1);
  1380.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][14], -1);
  1381.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][14], 0);
  1382.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][14], 0);
  1383.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][14], 1887473789);
  1384.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][14], 5);
  1385.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][14], 0);
  1386.     PlayerTextDrawSetPreviewModel(playerid, __playerInvTD[playerid][14], -1);
  1387.     PlayerTextDrawSetPreviewRot(playerid, __playerInvTD[playerid][14], 0.000, 0.000, 0.000, 1.000);
  1388.     PlayerTextDrawSetPreviewVehCol(playerid, __playerInvTD[playerid][14], 0, 0);
  1389.     PlayerTextDrawSetSelectable(playerid, __playerInvTD[playerid][14], 1);
  1390.  
  1391.     __playerInvTD[playerid][15] = CreatePlayerTextDraw(playerid, 369.000, 337.000, "_");
  1392.     PlayerTextDrawTextSize(playerid, __playerInvTD[playerid][15], 70.000, 70.000);
  1393.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][15], 1);
  1394.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][15], -1);
  1395.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][15], 0);
  1396.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][15], 0);
  1397.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][15], 1887473789);
  1398.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][15], 5);
  1399.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][15], 0);
  1400.     PlayerTextDrawSetPreviewModel(playerid, __playerInvTD[playerid][15], -1);
  1401.     PlayerTextDrawSetPreviewRot(playerid, __playerInvTD[playerid][15], 0.000, 0.000, 0.000, 1.000);
  1402.     PlayerTextDrawSetPreviewVehCol(playerid, __playerInvTD[playerid][15], 0, 0);
  1403.     PlayerTextDrawSetSelectable(playerid, __playerInvTD[playerid][15], 1);
  1404.  
  1405.     __playerInvTD[playerid][16] = CreatePlayerTextDraw(playerid, 157.000, 247.000, "0");
  1406.     PlayerTextDrawLetterSize(playerid, __playerInvTD[playerid][16], 0.300, 1.500);
  1407.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][16], 1);
  1408.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][16], -1);
  1409.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][16], 1);
  1410.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][16], 1);
  1411.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][16], 150);
  1412.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][16], 1);
  1413.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][16], 1);
  1414.  
  1415.     __playerInvTD[playerid][17] = CreatePlayerTextDraw(playerid, 229.000, 247.000, "0");
  1416.     PlayerTextDrawLetterSize(playerid, __playerInvTD[playerid][17], 0.300, 1.500);
  1417.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][17], 1);
  1418.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][17], -1);
  1419.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][17], 1);
  1420.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][17], 1);
  1421.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][17], 150);
  1422.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][17], 1);
  1423.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][17], 1);
  1424.  
  1425.     __playerInvTD[playerid][18] = CreatePlayerTextDraw(playerid, 301.000, 247.000, "0");
  1426.     PlayerTextDrawLetterSize(playerid, __playerInvTD[playerid][18], 0.300, 1.500);
  1427.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][18], 1);
  1428.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][18], -1);
  1429.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][18], 1);
  1430.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][18], 1);
  1431.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][18], 150);
  1432.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][18], 1);
  1433.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][18], 1);
  1434.  
  1435.     __playerInvTD[playerid][19] = CreatePlayerTextDraw(playerid, 373.000, 247.000, "0");
  1436.     PlayerTextDrawLetterSize(playerid, __playerInvTD[playerid][19], 0.300, 1.500);
  1437.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][19], 1);
  1438.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][19], -1);
  1439.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][19], 1);
  1440.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][19], 1);
  1441.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][19], 150);
  1442.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][19], 1);
  1443.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][19], 1);
  1444.  
  1445.     __playerInvTD[playerid][20] = CreatePlayerTextDraw(playerid, 157.000, 319.000, "0");
  1446.     PlayerTextDrawLetterSize(playerid, __playerInvTD[playerid][20], 0.300, 1.500);
  1447.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][20], 1);
  1448.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][20], -1);
  1449.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][20], 1);
  1450.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][20], 1);
  1451.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][20], 150);
  1452.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][20], 1);
  1453.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][20], 1);
  1454.  
  1455.     __playerInvTD[playerid][21] = CreatePlayerTextDraw(playerid, 229.000, 319.000, "0");
  1456.     PlayerTextDrawLetterSize(playerid, __playerInvTD[playerid][21], 0.300, 1.500);
  1457.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][21], 1);
  1458.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][21], -1);
  1459.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][21], 1);
  1460.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][21], 1);
  1461.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][21], 150);
  1462.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][21], 1);
  1463.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][21], 1);
  1464.  
  1465.     __playerInvTD[playerid][22] = CreatePlayerTextDraw(playerid, 301.000, 319.000, "0");
  1466.     PlayerTextDrawLetterSize(playerid, __playerInvTD[playerid][22], 0.300, 1.500);
  1467.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][22], 1);
  1468.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][22], -1);
  1469.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][22], 1);
  1470.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][22], 1);
  1471.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][22], 150);
  1472.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][22], 1);
  1473.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][22], 1);
  1474.  
  1475.     __playerInvTD[playerid][23] = CreatePlayerTextDraw(playerid, 373.000, 319.000, "0");
  1476.     PlayerTextDrawLetterSize(playerid, __playerInvTD[playerid][23], 0.300, 1.500);
  1477.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][23], 1);
  1478.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][23], -1);
  1479.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][23], 1);
  1480.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][23], 1);
  1481.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][23], 150);
  1482.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][23], 1);
  1483.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][23], 1);
  1484.  
  1485.     __playerInvTD[playerid][24] = CreatePlayerTextDraw(playerid, 157.000, 391.000, "0");
  1486.     PlayerTextDrawLetterSize(playerid, __playerInvTD[playerid][24], 0.300, 1.500);
  1487.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][24], 1);
  1488.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][24], -1);
  1489.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][24], 1);
  1490.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][24], 1);
  1491.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][24], 150);
  1492.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][24], 1);
  1493.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][24], 1);
  1494.  
  1495.     __playerInvTD[playerid][25] = CreatePlayerTextDraw(playerid, 229.000, 391.000, "0");
  1496.     PlayerTextDrawLetterSize(playerid, __playerInvTD[playerid][25], 0.300, 1.500);
  1497.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][25], 1);
  1498.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][25], -1);
  1499.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][25], 1);
  1500.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][25], 1);
  1501.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][25], 150);
  1502.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][25], 1);
  1503.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][25], 1);
  1504.  
  1505.     __playerInvTD[playerid][26] = CreatePlayerTextDraw(playerid, 301.000, 391.000, "0");
  1506.     PlayerTextDrawLetterSize(playerid, __playerInvTD[playerid][26], 0.300, 1.500);
  1507.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][26], 1);
  1508.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][26], -1);
  1509.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][26], 1);
  1510.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][26], 1);
  1511.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][26], 150);
  1512.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][26], 1);
  1513.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][26], 1);
  1514.  
  1515.     __playerInvTD[playerid][27] = CreatePlayerTextDraw(playerid, 373.000, 391.000, "0");
  1516.     PlayerTextDrawLetterSize(playerid, __playerInvTD[playerid][27], 0.300, 1.500);
  1517.     PlayerTextDrawAlignment(playerid, __playerInvTD[playerid][27], 1);
  1518.     PlayerTextDrawColor(playerid, __playerInvTD[playerid][27], -1);
  1519.     PlayerTextDrawSetShadow(playerid, __playerInvTD[playerid][27], 1);
  1520.     PlayerTextDrawSetOutline(playerid, __playerInvTD[playerid][27], 1);
  1521.     PlayerTextDrawBackgroundColor(playerid, __playerInvTD[playerid][27], 150);
  1522.     PlayerTextDrawFont(playerid, __playerInvTD[playerid][27], 1);
  1523.     PlayerTextDrawSetProportional(playerid, __playerInvTD[playerid][27], 1);
  1524.     return true;
  1525. }
  1526.  
  1527. static stock FixText(const string[])
  1528. {
  1529.     new len = strlen(string), output[150];
  1530.     for(new i = 0; i < len; i ++)
  1531.     {
  1532.         switch(string[i])
  1533.         {
  1534.             case '%':       output[i] = 37;
  1535.             case '&':       output[i] = 38;
  1536.             case '¡':      output[i] = 64;
  1537.             case '°':      output[i] = 124;
  1538.             case 'À':      output[i] = 128;
  1539.             case 'Á':      output[i] = 129;
  1540.             case 'Â':      output[i] = 130;
  1541.             case 'Ä', 'Ã':    output[i] = 131;
  1542.             case 'Ç':      output[i] = 133;
  1543.             case 'È':      output[i] = 134;
  1544.             case 'É':      output[i] = 135;
  1545.             case 'Ê':      output[i] = 136;
  1546.             case 'Ë':      output[i] = 137;
  1547.             case 'Ì':      output[i] = 138;
  1548.             case 'Í':      output[i] = 139;
  1549.             case 'Î':      output[i] = 140;
  1550.             case 'Ï':      output[i] = 141;
  1551.             case 'Ò':      output[i] = 142;
  1552.             case 'Ó':      output[i] = 143;
  1553.             case 'Ô':      output[i] = 144;
  1554.             case 'Ö', 'Õ':    output[i] = 145;
  1555.             case 'Ù':      output[i] = 146;
  1556.             case 'Ú':      output[i] = 147;
  1557.             case 'Û':      output[i] = 148;
  1558.             case 'Ü':      output[i] = 149;
  1559.             case 'à':      output[i] = 151;
  1560.             case 'á':      output[i] = 152;
  1561.             case 'â':      output[i] = 153;
  1562.             case 'ä', 'ã':    output[i] = 154;
  1563.             case 'ç':      output[i] = 156;
  1564.             case 'è':      output[i] = 157;
  1565.             case 'é':      output[i] = 158;
  1566.             case 'ê':      output[i] = 159;
  1567.             case 'ë':      output[i] = 160;
  1568.             case 'ì':      output[i] = 161;
  1569.             case 'í':      output[i] = 162;
  1570.             case 'î':      output[i] = 163;
  1571.             case 'ï':      output[i] = 164;
  1572.             case 'ò':      output[i] = 165;
  1573.             case 'ó':      output[i] = 166;
  1574.             case 'ô':      output[i] = 167;
  1575.             case 'ö', 'õ':    output[i] = 168;
  1576.             case 'ù':      output[i] = 169;
  1577.             case 'ú':      output[i] = 170;
  1578.             case 'û':      output[i] = 171;
  1579.             case 'ü':      output[i] = 172;
  1580.             case 'Ñ':      output[i] = 173;
  1581.             case 'ñ':      output[i] = 174;
  1582.             case '¿':      output[i] = 175;
  1583.             case '`':       output[i] = 177;
  1584.             default:        output[i] = string[i];
  1585.         }
  1586.     }
  1587.     return output;
  1588. }
  1589.  
  1590. // ---------------- HOOK ----------------
  1591.  
  1592. #if defined _ALS_OnGameModeInit
  1593.     #undef OnGameModeInit
  1594. #else
  1595.     #define _ALS_OnGameModeInit
  1596. #endif
  1597. #define OnGameModeInit td_invent_OnGameModeInit
  1598. #if defined td_invent_OnGameModeInit
  1599.     forward td_invent_OnGameModeInit();
  1600. #endif
  1601.  
  1602. #if defined _ALS_OnPlayerDisconnect
  1603.     #undef OnPlayerDisconnect
  1604. #else
  1605.     #define _ALS_OnPlayerDisconnect
  1606. #endif
  1607. #define OnPlayerDisconnect td_invent_OnPlayerDisconnect
  1608. #if defined td_invent_OnPlayerDisconnect
  1609.     forward td_invent_OnPlayerDisconnect(playerid, reason);
  1610. #endif
  1611.  
  1612. #if defined _ALS_OnPlayerClickTextDraw
  1613.     #undef OnPlayerClickTextDraw
  1614. #else
  1615.     #define _ALS_OnPlayerClickTextDraw
  1616. #endif
  1617. #define OnPlayerClickTextDraw inv_OnPlayerClickTextDraw
  1618. #if defined inv_OnPlayerClickTextDraw
  1619.     forward inv_OnPlayerClickTextDraw(playerid, Text:clickedid);
  1620. #endif
  1621.  
  1622. #if defined _ALS_OnPlayerClickDynamicTextdr
  1623.     #undef OnPlayerClickDynamicTextdraw
  1624. #else
  1625.     #define _ALS_OnPlayerClickDynamicTextdr
  1626. #endif
  1627. #define OnPlayerClickDynamicTextdraw invOnPlayerClickDynamicTextdraw
  1628. #if defined invOnPlayerClickDynamicTextdraw
  1629.     forward invOnPlayerClickDynamicTextdraw(playerid, PlayerText:playertextid);
  1630. #endif
  1631.  
  1632. #if defined _ALS_OnPlayerKeyStateChange
  1633.     #undef OnPlayerKeyStateChange
  1634. #else
  1635.     #define _ALS_OnPlayerKeyStateChange
  1636. #endif
  1637. #define OnPlayerKeyStateChange invent_OnPlayerKeyStateChange
  1638. #if defined invent_OnPlayerKeyStateChange
  1639.     forward invent_OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
  1640. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement