Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.49 KB | None | 0 0
  1. CMD:phone(playerid, params[])
  2. {
  3. if(PlayerInfo[playerid][pJailed] != 0) return SCM(playerid, COLOR_WHITE, "Can't call in jail/ajail.");
  4. if(PlayerIsWounded(playerid)) return SCM(playerid, COLOR_GREY, "You can't call while you are wounded.");
  5. if(PlayerInfo[playerid][pCellPhone] != 1) return CellMSG(playerid, "You don't have a cellphone.");
  6. if(cellOn[playerid] = 1)
  7. {
  8. Dialog_Show(playerid, Phone, DIALOG_STYLE_LIST, "Phone", "Dial Number\nContacts\nSend Text\nMy Music\nTurn Off Phone", "Select", "Cancel");
  9. }
  10. else {
  11. Dialog_Show(playerid, Phone, DIALOG_STYLE_LIST, "Phone", "Dial Number\nContacts\nSend Text\nMy Music\nTurn On Phone", "Select", "Cancel");
  12. }
  13. return 1;
  14. }
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21. ***********************************************************DIALOGS*********************************************************************
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28. GetNumberOwner(number)
  29. {
  30. foreach (new i : Player) if (PlayerInfo[i][pCellPhone] == number) {
  31. return i;
  32. }
  33. return INVALID_PLAYER_ID;
  34. }
  35.  
  36. IsNumeric(const str[])
  37. {
  38. for (new i = 0, l = strlen(str); i != l; i ++)
  39. {
  40. if (i == 0 && str[0] == '-')
  41. continue;
  42.  
  43. else if (str[i] < '0' || str[i] > '9')
  44. return 0;
  45. }
  46. return 1;
  47. }
  48.  
  49. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  50. if(dialogid == 2016) {
  51. if (!response) return SCM(playerid, 0xD6E1EBFF, "Music Search Canceled.");
  52. if(strlen(inputtext)) {
  53. new ola[255];
  54. format(ola, sizeof(ola), "https://6t.pe/?song=%s", inputtext);
  55. PlayAudioStreamForPlayer(playerid, ola);
  56. }
  57. }
  58. return 0;
  59. }
  60.  
  61. Dialog:SendText(playerid, response, listitem, inputtext[])
  62. {
  63. if (response)
  64. {
  65. new number = strval(inputtext);
  66.  
  67. if (isnull(inputtext) || !IsNumeric(inputtext))
  68. return Dialog_Show(playerid, SendText, DIALOG_STYLE_INPUT, "Send Text", "Please enter the number that you wish to send a text message to:", "Text", "Back");
  69.  
  70. if (GetNumberOwner(number) == INVALID_PLAYER_ID)
  71. return Dialog_Show(playerid, SendText, DIALOG_STYLE_INPUT, "Send Text Message", "Error: That number is not online right now.\n\nPlease enter the number that you wish to send a text message to:", "Text", "Back");
  72.  
  73. PlayerInfo[playerid][pContacts] = GetNumberOwner(number);
  74. Dialog_Show(playerid, TextMessage, DIALOG_STYLE_INPUT, "Text Message", "Please enter the message to send to %s:", "Send", "Back", GetName(PlayerInfo[playerid][pContacts], 0));
  75. }
  76. else {
  77. cmd_phone(playerid, "\1");
  78. }
  79. return 1;
  80. }
  81.  
  82. Dialog:TextMessage(playerid, response, listitem, inputtext[])
  83. {
  84. if (response)
  85. {
  86. if (isnull(inputtext))
  87. return Dialog_Show(playerid, TextMessage, DIALOG_STYLE_INPUT, "Text Message", "Error: Please enter a message to send.\n\nPlease enter the message to send to %s:", "Send", "Back", GetName(PlayerInfo[playerid][pContacts], 0));
  88.  
  89. new targetid = PlayerInfo[playerid][pContacts];
  90.  
  91. if (!IsPlayerConnected(targetid) || !PlayerInfo[targetid][pCellPhone])
  92. return SCM(playerid, COLOR_GREY, "The specified phone number went offline.");
  93.  
  94. GiveCash(playerid, -2);
  95. format(msg, sizeof(msg), "You've been charged ~r$2~w~ for the text.");
  96. GameTextForPlayer(playerid, msg, 5000, 1);
  97.  
  98. SCM(targetid, COLOR_YELLOW, "[TEXT]: %s - %s (%d)", inputtext, GetName(playerid, 0), PlayerInfo[playerid][pCellPhone]);
  99. SCM(playerid, COLOR_YELLOW, "[TEXT]: %s - %s (%d)", inputtext, GetName(playerid, 0), PlayerInfo[playerid][pCellPhone]);
  100.  
  101. PlaySound(playerid, 1052);
  102. ActionMessage(playerid, 20.0, "takes out their phone and sends a text.", GetName(playerid, 0));
  103. }
  104. else {
  105. Dialog_Show(playerid, SendText, DIALOG_STYLE_INPUT, "Send Text Message", "Please enter the number that you wish to send a text message to:", "Submit", "Back");
  106. }
  107. return 1;
  108. }
  109.  
  110. Dialog:CallNumber(playerid, response, listitem, inputtext[])
  111. {
  112. if (response)
  113. {
  114. new
  115. string[16];
  116.  
  117. if (isnull(inputtext) || !IsNumeric(inputtext))
  118. return Dialog_Show(playerid, CallNumber, DIALOG_STYLE_INPUT, "Call Number", "Please enter the number that you wish to call below:", "Call", "Back");
  119.  
  120. format(string, 16, "%d", strval(inputtext));
  121. cmd_call(playerid, string);
  122. }
  123. else {
  124. cmd_phone(playerid, "\1");
  125. }
  126. return 1;
  127. }
  128.  
  129. Dialog:Phone(playerid, response, listitem, inputtext[])
  130. {
  131. if (response)
  132. {
  133. switch (listitem)
  134. {
  135. case 0:
  136. {
  137. if(GetIntVar(playerid, "cellOn") == 0)
  138. return SCM(playerid, COLOR_GREY, "Your phone must be powered on.");
  139.  
  140. Dialog_Show(playerid, CallNumber, DIALOG_STYLE_INPUT, "Call Number", "Please enter the number that you wish to call below:", "Call", "Back");
  141. }
  142. case 1:
  143. {
  144. if(GetIntVar(playerid, "cellOn") == 0)
  145. return SCM(playerid, COLOR_GREY, "Your phone must be powered on.");
  146.  
  147. DisplayContactList(playerid);
  148. }
  149. case 2:
  150. {
  151. if(GetIntVar(playerid, "cellOn") == 0)
  152. return SCM(playerid, COLOR_GREY, "Your phone must be powered on.");
  153.  
  154. Dialog_Show(playerid, SendText, DIALOG_STYLE_INPUT, "Send Text", "Please enter the number that you wish to send a text message to:", "Send", "Back");
  155. }
  156. case 3: {
  157. ShowPlayerDialog(playerid, 2016, DIALOG_STYLE_INPUT, "{D6E1EB}Youtube", "{FFFFFF}Insert the video/music title", "Accept", "Cancel");
  158. }
  159. case 4:
  160. {
  161. if(GetIntVar(playerid, "OnCall") == 1) return cmd_hangup(playerid, "\1");
  162. if(cellOn[playerid] == 1)
  163. {
  164. cellOn[playerid] = 0;
  165. ActionMessage(playerid, 20.0, "has powered off their cellphone.");
  166. }
  167. else
  168. {
  169. cellOn[playerid] = 1;
  170. ActionMessage(playerid, 20.0, "has powered on their cellphone.");
  171. }
  172. }
  173. }
  174. }
  175. return 1;
  176. }
  177.  
  178. Dialog:Contacts(playerid, response, listitem, inputtext[])
  179. {
  180. if(response)
  181. {
  182. //Must be +1 because slots are starting from 1
  183. new number = PlayerInfo[playerid][pContacts][listitem+1];
  184. if(number == 0)
  185. {
  186. Dialog_Show(playerid, ContactNoExist, DIALOG_STYLE_MSGBOX, "Contacts List", "The contact you have selected does not exists...", "<<<", "");
  187. }
  188. else
  189. {
  190. PlayerCallTo(playerid, number);
  191. }
  192. }
  193. return 1;
  194. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement