ownership.inc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #include <YSI_Coding\y_hooks>
  2. new Iterator:OwnedItem[MAX_PLAYERS]<MAX_ITEMS>;
  3. hook OnGameModeInit()
  4. {
  5. Iter_Init(OwnedItem);
  6. }
  7. hook OnPlayerDisconnect(playerid, reason)
  8. {
  9. Iter_Clear(OwnedItem[playerid]);
  10. }
  11. hook OnPlayerFirstSpawn(playerid)
  12. {
  13. foreach(new i : Item)
  14. {
  15. if(Inventory_GetItemOwnerSQLID(i) == Character_GetSQLID(playerid))
  16. {
  17. Iter_Add(OwnedItem[playerid], i);
  18. }
  19. }
  20. }
  21. Inventory_ShowItems(playerid)
  22. {
  23. new count;
  24. new string[1024];
  25. new listitemEx[MAX_ITEMS];
  26. strcat(string, "These are your items:\n");
  27. foreach(new i : OwnedItem[playerid])
  28. {
  29. listitemEx[count] = i;
  30. count++;
  31. strcat(string, va_return("%s (SQL ID %d)\n", Inventory_GetItemName(i), i));
  32. }
  33. inline _response(response, listitem, string:inputtext[])
  34. {
  35. #pragma unused inputtext
  36. if(!response)
  37. return 1;
  38. Inventory_ShowItemMenu(playerid, listitemEx[listitem]);
  39. }
  40. Dialog_ShowCallback(playerid, using inline _response, DIALOG_STYLE_TABLIST_HEADERS, "Your inventory", string, "Next", "Close");
  41. return 1;
  42. }
  43. Inventory_ShowItemMenu(playerid, itemid)
  44. {
  45. inline _response(responseEx, listitemEx, string:inputtextEx[])
  46. {
  47. #pragma unused inputtextEx
  48. if(!responseEx)
  49. return Inventory_ShowItems(playerid);
  50. switch(listitemEx)
  51. {
  52. case 1: Inventory_ShowItems(playerid);
  53. case 2: Inventory_ShowItems(playerid);
  54. }
  55. }
  56. Dialog_ShowCallback(playerid, using inline _response, DIALOG_STYLE_TABLIST_HEADERS, Inventory_GetItemName(itemid), "What do you want to do with this item?\nUse\nDrop", "Next", "Back");
  57. return 1;
  58. }
  59. CMD:inventory(playerid, params[])
  60. {
  61. Inventory_ShowItems(playerid);
  62. return 1;
  63. }