Guest User

telecomms script

a guest
Jul 23rd, 2025
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.33 KB | None | 0 0
  1. // Telecoms control script
  2. // Usage: /setjob Eugene_Dexter Cool_Guy (sets Eugene Dexter's job to Cool Guy)
  3. // /setjob all Cool_Guy (sets everyone's job to Cool Guy)
  4. // /setname Jim_Barry James_Perry (renames Jim Barry to James Perry)
  5. // /setname all Jeremy (sets everyone's name to Jeremy)
  6. // /off (disables all messages from being sent)
  7. // /on (enables all messages to be sent)
  8.  
  9. // Initialize the memory variables if they don't exist
  10. if(!mem("global_job"))
  11. {
  12. mem("global_job", "");
  13. mem("use_global", FALSE);
  14. mem("comms_enabled", TRUE);
  15. mem("global_name", "");
  16. mem("use_global_name", FALSE);
  17. }
  18.  
  19. // Parse the command
  20. $exploded = explode($content, " ");
  21. $command = at($exploded, 1);
  22.  
  23. // Handle /off command
  24. if($command == "/off")
  25. {
  26. mem("comms_enabled", FALSE);
  27. broadcast("Communications disabled", $freq, "CommControl", "System");
  28. $pass = 0;
  29. }
  30. // Handle /on command
  31. elseif($command == "/on")
  32. {
  33. mem("comms_enabled", TRUE);
  34. broadcast("Communications enabled", $freq, "CommControl", "System");
  35. $pass = 0;
  36. }
  37. // Handle /setname command
  38. elseif($command == "/setname")
  39. {
  40. // Check if we have enough arguments
  41. if(length($exploded) >= 3)
  42. {
  43. $target = at($exploded, 2);
  44.  
  45. // Build the new name from remaining arguments (index 3 onwards)
  46. $new_name = "";
  47. $i = 3;
  48. while($i <= length($exploded))
  49. {
  50. if($i == 3)
  51. {
  52. $new_name = at($exploded, $i);
  53. }
  54. else
  55. {
  56. $new_name = $new_name + " " + at($exploded, $i);
  57. }
  58. $i = $i + 1;
  59. }
  60.  
  61. // Replace underscores with spaces in both target and name
  62. $target = replace($target, "_", " ");
  63. $new_name = replace($new_name, "_", " ");
  64.  
  65. if($target == "all")
  66. {
  67. // Set global name for everyone
  68. mem("global_name", $new_name);
  69. mem("use_global_name", TRUE);
  70. broadcast("Setting everyone's name to: " + $new_name, $freq, "NameChanger", "System");
  71. }
  72. else
  73. {
  74. // Store the individual name change
  75. mem($target + "_newname", $new_name);
  76. broadcast("Renaming " + $target + " to " + $new_name, $freq, "NameChanger", "System");
  77. }
  78. }
  79. else
  80. {
  81. broadcast("Usage: /setname <name_or_all> <new_name> (use underscores for spaces)", $freq, "NameChanger", "System");
  82. }
  83.  
  84. // Don't pass the command through to normal chat
  85. $pass = 0;
  86. }
  87. // Handle /setjob command
  88. elseif($command == "/setjob")
  89. {
  90. // Check if we have enough arguments
  91. if(length($exploded) >= 3)
  92. {
  93. $target = at($exploded, 2);
  94.  
  95. // Build the job name from remaining arguments (index 3 onwards)
  96. $new_job = "";
  97. $i = 3;
  98. while($i <= length($exploded))
  99. {
  100. if($i == 3)
  101. {
  102. $new_job = at($exploded, $i);
  103. }
  104. else
  105. {
  106. $new_job = $new_job + " " + at($exploded, $i);
  107. }
  108. $i = $i + 1;
  109. }
  110.  
  111. // Replace underscores with spaces in both target and job
  112. $target = replace($target, "_", " ");
  113. $new_job = replace($new_job, "_", " ");
  114.  
  115. if($target == "all")
  116. {
  117. // Set global job for everyone
  118. mem("global_job", $new_job);
  119. mem("use_global", TRUE);
  120. broadcast("Setting everyone's job to: " + $new_job, $freq, "JobSetter", "System");
  121. }
  122. else
  123. {
  124. // Set specific person's job
  125. mem($target + "_job", $new_job);
  126. broadcast("Setting name of " + $target + " to " + $new_job, $freq, "JobSetter", "System");
  127. }
  128. }
  129. else
  130. {
  131. broadcast("Usage: /setjob <name_or_all> <job_title> (use underscores for spaces)", $freq, "JobSetter", "System");
  132. }
  133.  
  134. // Don't pass the command through to normal chat
  135. $pass = 0;
  136. }
  137. else
  138. {
  139. // Check if communications are enabled
  140. if(!mem("comms_enabled"))
  141. {
  142. $pass = 0;
  143. }
  144. else
  145. {
  146. // Apply custom names and job names to regular messages
  147. $custom_name = mem($source + "_newname");
  148. $global_name = mem("global_name");
  149. $use_global_name = mem("use_global_name");
  150. $custom_job = mem($source + "_job");
  151. $global_job = mem("global_job");
  152. $use_global = mem("use_global");
  153.  
  154. // Check if this person has a custom name
  155. if($custom_name && $custom_name != "")
  156. {
  157. $source = $custom_name;
  158. }
  159. // Otherwise check if we should use the global name
  160. elseif($use_global_name && $global_name && $global_name != "")
  161. {
  162. $source = $global_name;
  163. }
  164.  
  165. // Check if this person has a specific custom job
  166. if($custom_job && $custom_job != "")
  167. {
  168. $job = $custom_job;
  169. }
  170. // Otherwise check if we should use the global job
  171. elseif($use_global && $global_job && $global_job != "")
  172. {
  173. $job = $global_job;
  174. }
  175.  
  176. // Pass the message through normally
  177. $pass = 1;
  178. }
  179. }
Advertisement
Add Comment
Please, Sign In to add comment