Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Telecoms control script
- // Usage: /setjob Eugene_Dexter Cool_Guy (sets Eugene Dexter's job to Cool Guy)
- // /setjob all Cool_Guy (sets everyone's job to Cool Guy)
- // /setname Jim_Barry James_Perry (renames Jim Barry to James Perry)
- // /setname all Jeremy (sets everyone's name to Jeremy)
- // /off (disables all messages from being sent)
- // /on (enables all messages to be sent)
- // Initialize the memory variables if they don't exist
- if(!mem("global_job"))
- {
- mem("global_job", "");
- mem("use_global", FALSE);
- mem("comms_enabled", TRUE);
- mem("global_name", "");
- mem("use_global_name", FALSE);
- }
- // Parse the command
- $exploded = explode($content, " ");
- $command = at($exploded, 1);
- // Handle /off command
- if($command == "/off")
- {
- mem("comms_enabled", FALSE);
- broadcast("Communications disabled", $freq, "CommControl", "System");
- $pass = 0;
- }
- // Handle /on command
- elseif($command == "/on")
- {
- mem("comms_enabled", TRUE);
- broadcast("Communications enabled", $freq, "CommControl", "System");
- $pass = 0;
- }
- // Handle /setname command
- elseif($command == "/setname")
- {
- // Check if we have enough arguments
- if(length($exploded) >= 3)
- {
- $target = at($exploded, 2);
- // Build the new name from remaining arguments (index 3 onwards)
- $new_name = "";
- $i = 3;
- while($i <= length($exploded))
- {
- if($i == 3)
- {
- $new_name = at($exploded, $i);
- }
- else
- {
- $new_name = $new_name + " " + at($exploded, $i);
- }
- $i = $i + 1;
- }
- // Replace underscores with spaces in both target and name
- $target = replace($target, "_", " ");
- $new_name = replace($new_name, "_", " ");
- if($target == "all")
- {
- // Set global name for everyone
- mem("global_name", $new_name);
- mem("use_global_name", TRUE);
- broadcast("Setting everyone's name to: " + $new_name, $freq, "NameChanger", "System");
- }
- else
- {
- // Store the individual name change
- mem($target + "_newname", $new_name);
- broadcast("Renaming " + $target + " to " + $new_name, $freq, "NameChanger", "System");
- }
- }
- else
- {
- broadcast("Usage: /setname <name_or_all> <new_name> (use underscores for spaces)", $freq, "NameChanger", "System");
- }
- // Don't pass the command through to normal chat
- $pass = 0;
- }
- // Handle /setjob command
- elseif($command == "/setjob")
- {
- // Check if we have enough arguments
- if(length($exploded) >= 3)
- {
- $target = at($exploded, 2);
- // Build the job name from remaining arguments (index 3 onwards)
- $new_job = "";
- $i = 3;
- while($i <= length($exploded))
- {
- if($i == 3)
- {
- $new_job = at($exploded, $i);
- }
- else
- {
- $new_job = $new_job + " " + at($exploded, $i);
- }
- $i = $i + 1;
- }
- // Replace underscores with spaces in both target and job
- $target = replace($target, "_", " ");
- $new_job = replace($new_job, "_", " ");
- if($target == "all")
- {
- // Set global job for everyone
- mem("global_job", $new_job);
- mem("use_global", TRUE);
- broadcast("Setting everyone's job to: " + $new_job, $freq, "JobSetter", "System");
- }
- else
- {
- // Set specific person's job
- mem($target + "_job", $new_job);
- broadcast("Setting name of " + $target + " to " + $new_job, $freq, "JobSetter", "System");
- }
- }
- else
- {
- broadcast("Usage: /setjob <name_or_all> <job_title> (use underscores for spaces)", $freq, "JobSetter", "System");
- }
- // Don't pass the command through to normal chat
- $pass = 0;
- }
- else
- {
- // Check if communications are enabled
- if(!mem("comms_enabled"))
- {
- $pass = 0;
- }
- else
- {
- // Apply custom names and job names to regular messages
- $custom_name = mem($source + "_newname");
- $global_name = mem("global_name");
- $use_global_name = mem("use_global_name");
- $custom_job = mem($source + "_job");
- $global_job = mem("global_job");
- $use_global = mem("use_global");
- // Check if this person has a custom name
- if($custom_name && $custom_name != "")
- {
- $source = $custom_name;
- }
- // Otherwise check if we should use the global name
- elseif($use_global_name && $global_name && $global_name != "")
- {
- $source = $global_name;
- }
- // Check if this person has a specific custom job
- if($custom_job && $custom_job != "")
- {
- $job = $custom_job;
- }
- // Otherwise check if we should use the global job
- elseif($use_global && $global_job && $global_job != "")
- {
- $job = $global_job;
- }
- // Pass the message through normally
- $pass = 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment