Advertisement
Guest User

Untitled

a guest
Jan 20th, 2015
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. /////////////////////////////////////////////////////////////////////////////////
  2. // TEXT MESSAGES //
  3. /////////////////////////////////////////////////////////////////////////////////
  4. static
  5. message[100],
  6. date[30],
  7. sender;
  8.  
  9. ShowTextMessages(playerid)
  10. {
  11. new
  12. slot = 0;
  13.  
  14. if(CountTextMessages(playerid) == 0)
  15. ShowDialog(playerid, D_UNUSED, DIALOG_STYLE_LIST, "Text Messages List", "Your inbox is empty", ">>>", "", 0);
  16. Count(i, MAX_TEXT_MESSAGES)
  17. {
  18. if(MEM::get_val(Texts[playerid][i], On) == 1)
  19. {
  20. PVar:playerid[DialogInputs][slot] = i;
  21. sender = MEM::get_val(Texts[playerid][i], From);
  22. Format:gText("%sFrom %d - %s\n", gText, sender);
  23. slot++;
  24. }
  25. }
  26. ShowDialog(playerid, D_TEXTS, DIALOG_STYLE_LIST, "Text Messages List", gText, "Select", ">>>", TEXTS_LIST);
  27. return 1;
  28. }
  29.  
  30. ShowTextMessageInfo(playerid, index)
  31. {
  32. MEM::get_arr(Texts[playerid][index], Message, message, 100);
  33. MEM::get_arr(Texts[playerid][index], Date, date, 30);
  34. sender = MEM::get_val(Texts[playerid][index], From);
  35. SetPVarInt(playerid, "TextNumber", sender);
  36. Format:gText("TEXT MESSAGE - from %d\n\n"EMBED_WHITE"Date sent: %s\nContent: %s", sender, date, message);
  37. ShowDialog(playerid, D_TEXTS, DIALOG_STYLE_MSGBOX, "Text Messages List", gText, "Reply", ">>>", TEXT_INFO);
  38. }
  39.  
  40. ShowTextMessageReply(playerid)
  41. {
  42. new to = GetPVarInt(playerid, "TextNumber");
  43. Format:gText("TEXT MESSAGE - reply to %d", to);
  44. ShowDialog(playerid, D_TEXTS, DIALOG_STYLE_INPUT, "Text Messages List", gText, "Send", ">>>", TEXT_REPLY);
  45. return 1;
  46. }
  47.  
  48. AssignTextMessage(playerid, text[], from)
  49. {
  50. new i = FreeMessageSlot(playerid);
  51. if(i == INVALID_VAL_ID) {
  52. ClearMessageSlot(playerid, true);
  53. i = FreeMessageSlot(playerid);
  54. }
  55. MEM::set_arr(Texts[playerid][i], Message, text, 100);
  56. MEM::set_arr(Texts[playerid][i], Date, GetFullDate(), 30);
  57. MEM::set_val(Texts[playerid][i], From, from);
  58. MEM::set_val(Texts[playerid][i], On, 1);
  59. }
  60.  
  61. ClearMessageSlot(playerid, bool:all = false, index = -1)
  62. {
  63. if(all)
  64. {
  65. MEM_MACR_foreach(MAX_TEXT_MESSAGES, i)
  66. {
  67. MEM::set_val(Texts[playerid][i], On, 0);
  68. }
  69. }
  70. else if(index != -1)
  71. {
  72. MEM::set_val(Texts[playerid][index], On, 0);
  73. }
  74. }
  75.  
  76. FreeMessageSlot(playerid)
  77. {
  78. MEM_MACR_foreach(MAX_TEXT_MESSAGES, i)
  79. {
  80. if(MEM::get_val(Texts[playerid][i], On) == 0) return i;
  81. }
  82. return INVALID_VAL_ID;
  83. }
  84.  
  85. CountTextMessages(playerid)
  86. {
  87. new count = 0;
  88. MEM_MACR_foreach(MAX_TEXT_MESSAGES, i)
  89. {
  90. if(MEM::get_val(Texts[playerid][i], On) == 1) count++;
  91. }
  92. return count;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement