NTSL Scripts: Difference between revisions

12,392 bytes added ,  05:30, 12 May 2014
m
Added script archive.
imported>Kosmos
m (Removed "less annoying job indicator"-script and the mute-scripts as they were reported not working.)
imported>Kosmos
m (Added script archive.)
Line 2: Line 2:


More in [http://forums.nanotrasen.com/viewtopic.php?f=3&t=8147 this thread].
More in [http://forums.nanotrasen.com/viewtopic.php?f=3&t=8147 this thread].
==Old Scripts Archive for Older Revisions==
NOTE: These scripts don't work on the new telecommunications-code. They are archived here in case you are using an older revision of tgstation-code.
{| class="mw-collapsible mw-collapsed wikitable"
|-
!
|-
| scope="row" |
===Less Annoying Job Indicator===
Only shows abbreviations of job titles instead of full titles.<br>
<pre>//code shamelessly copied and pasted from Giacom's pirate script
def Initialize() {
$words = vector(
    "Assistant", "Assnt",
    "Captain", "Capt",
    "Head of Personnel", "HoP",
    "Bartender", "Bar",
    "Chef", "Chef",
    "Botanist", "Hydro",
    "Quartermaster", "QM",
    "Cargo Technician", "Cargo",
    "Shaft Miner", "Miner",
    "Clown", "Clown",
    "Mime", "Mime",
    "Janitor", "Jan-r",
    "Librarian", "Lib-n",
    "Lawyer", "Law",
    "Chaplain", "Chapl",
    "Chief Engineer", "CE",
    "Station Engineer", "Engi",
    "Atmospheric Technician", "Atmos",
    "Chief Medical Officer", "CMO",
    "Medical Doctor", "MD",
    "Chemist", "Chem",
    "Geneticist", "G-tic",
    "Virologist", "Viro",
    "Research Director", "RD",
    "Scientist", "Sci",
    "Roboticist", "Robo",
    "Head of Security", "HoS",
    "Warden", "Ward",
    "Detective", "D-tiv",
    "Security Officer", "Sec",
    "AI", "AI",
    "Cyborg", "Borg",
    "Personal AI", "pAI",
    );
   
    $index = 1;
  while($index <= length($words))
{
  mem(at($words, $index), at($words, $index+1));
  $index += 2;
}
}
if(mem("initialized") != 1)
{
Initialize();
mem("initialized", 1);
}
$foo = "";
if(mem($job)) { $foo = mem($job); }
else { $foo = substr($job, 1, 6); }
if (!find($source, "Unknown") && $job != "No id" && !find($source, " (as ")) {
$source = $source + " (" + $foo + ")"; }</pre>
===Selective Mute===
By Matilda.<br>
Turn a wall com to 146.1 to listen to the output of the script.<br>
authorize yourself via ;/authme PASSWORD, just say it on the general channel.<br>
then use ;/crewlist to find the ID of who you want to mute.<br>
then use ;/mute ID to mute them, and ;/unmute ID to unmute them.
<pre>$password = "<insert password here>";
$originalsource = $source;
$originaljob = $job;
$me = 4;
if(!mem("crewnum")) {
  mem("crewnum",0);
}
$found = 0;
$counter = 0;
$me = 0;
while($counter < mem("crewnum")) {
  if (mem("crewlistsource" + $counter) == $originalsource) {
      $me = $counter;
      $found = 1;
  }
  $counter = $counter + 1;
}
if ($found == 0) {
  $me = mem("crewnum");
  broadcast("Adding new user " + $originalsource + ", " + $originaljob + " to database at location " + mem("crewnum"),1461);
  mem("crewlistsource" + $me,$originalsource);
  mem("crewlistjob" + $me,$originaljob);
  mem("crewlistauth" + $me, 0);
  mem("crewlistmute" + $me, 0);
  mem("crewnum",mem("crewnum") + 1);
}
//HACK ALERT
if ($me < 1) { $me = 0; }
if(!mem("usermessagecount")) {
  mem("usermessagecount",0);
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/crewlist") {
  $counter = 0;
  while($counter < mem("crewnum")) {
      broadcast($counter + " - " + mem("crewlistsource" + $counter) + " - " + mem("crewlistjob" + $counter) + " - auth " + mem("crewlistauth" +
$counter) + " - mute " + mem("crewlistmute" + $counter),1461," "," ");
      $counter = $counter + 1;
  }
  $pass = 0;
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/who") {
  broadcast(mem("crewlistsource" + at($expld1, 2)),1461);
  $pass = 0;
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/crewnum") {
  broadcast(mem("crewnum"), 1461);
  $pass = 0;
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/myid") {
  broadcast("Your ID is " + $me, 1461);
  $pass = 0;
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/mute" && mem("crewlistauth" + $me) >= 2) {
  mem("crewlistmute" + at($expld1, 2),1);
  broadcast(mem("crewlistsource" + at($expld1, 2)) + " has been muted.");
  $pass = 0;
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/unmute" && mem("crewlistauth" + $me) >= 2) {
  mem("crewlistmute" + at($expld1, 2),0);
  broadcast(mem("crewlistsource" + at($expld1, 2)) + " has been unmuted.");
  $pass = 0;
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/authme") {
  if(at($expld1, 2) == $password) {
      mem("crewlistauth" + $me, 2);
  }
  $pass = 0;
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/announce" && mem("crewlistauth" + $me) >= 1) {
  broadcast(" ",$common," "," ");
  broadcast("ANNOUNCEMENT",$common," "," ");
  broadcast("  ",$common," "," ");
  broadcast("  ",$common," "," ");
  broadcast(upper(replace($content, "/announce", " ")),$common," "," ");
  broadcast("    ",$common," "," ");
  broadcast("    ",$common," "," ");
  $pass = 0;
}
if(mem("crewlistmute" + $me) == 1) {
  //$pass = 0;
  $content = " ";
  $source = $originalsource + " (MUTED)";
}</pre>
===Cleaner Selective Mute===
Mute and unmute people merely by saying "/mute FULL NAME" the name has to be capitalized and spelled properly.<br>
Authorizes by one or more sources, but could be configured for a password if you really wanted to.<br>
Great for traitor AIs who don't want their victim screaming about the oxygen siphoning! <br>
<pre>//recursive implode function, takes a vector and
//combines each member into a string with a space to separate
//by perogi
def implode($vector)
{
$str = at($vector, 1);
remove($vector, $str);
if(length($vector) > 0)
{
$str += " ";
$str += implode($vector);
}
return $str;
}
//mute and unmute function
//use: type /mute or /unmute then the name of the person exactly as it is spelled
//by perogi
if($source == "YOUR NAME HERE") //only the name in this line can use script
{
if(at(explode($content, " "), 1) == "/mute")
{
$vec = explode($content, " ");
remove($vec, "/mute");
$name = implode($vec);
$pass = 0;
mem($name,$name);
}
if(at(explode($content, " "),1) == "/unmute")
{
$pass = 0;
$vec = explode($content, " ");
remove($vec, "/unmute");
mem(implode($vec), 0);
}
}
//checks if source is muted
//possible to get around mute by taking off ID and being unknown, hence why unknowns are all blocked
if($source == mem($source) || $source == "Unknown")
{
$pass = 0;
}</pre>
|}


==Useful Non-Malicious Scripts==
==Useful Non-Malicious Scripts==
Line 27: Line 263:
         broadcast($content, $freq, "Anonymous");
         broadcast($content, $freq, "Anonymous");
     }
     }
=== Less annoying job indicator ===
Only shows abbreviations of job titles instead of full titles.
//code shamelessly copied and pasted from Giacom's pirate script
def Initialize() {
$words = vector(
    "Assistant", "Assnt",
    "Captain", "Capt",
    "Head of Personnel", "HoP",
    "Bartender", "Bar",
    "Chef", "Chef",
    "Botanist", "Hydro",
    "Quartermaster", "QM",
    "Cargo Technician", "Cargo",
    "Shaft Miner", "Miner",
    "Clown", "Clown",
    "Mime", "Mime",
    "Janitor", "Jan-r",
    "Librarian", "Lib-n",
    "Lawyer", "Law",
    "Chaplain", "Chapl",
    "Chief Engineer", "CE",
    "Station Engineer", "Engi",
    "Atmospheric Technician", "Atmos",
    "Chief Medical Officer", "CMO",
    "Medical Doctor", "MD",
    "Chemist", "Chem",
    "Geneticist", "G-tic",
    "Virologist", "Viro",
    "Research Director", "RD",
    "Scientist", "Sci",
    "Roboticist", "Robo",
    "Head of Security", "HoS",
    "Warden", "Ward",
    "Detective", "D-tiv",
    "Security Officer", "Sec",
    "AI", "AI",
    "Cyborg", "Borg",
    "Personal AI", "pAI",
    );
   
    $index = 1;
  while($index <= length($words))
  {
  mem(at($words, $index), at($words, $index+1));
  $index += 2;
  }
}
if(mem("initialized") != 1)
{
  Initialize();
  mem("initialized", 1);
}
$foo = "";
if(mem($job)) { $foo = mem($job); }
else { $foo = substr($job, 1, 6); }
if (!find($source, "Unknown") && $job != "No id" && !find($source, " (as ")) {
$source = $source + " (" + $foo + ")"; }
=== Selective mute ===
By Matilda.<br>
Turn a wall com to 146.1 to listen to the output of the script.<br>
authorize yourself via ;/authme PASSWORD, just say it on the general com.<br>
then use ;/crewlist to find the ID of who you want to mute<br>
then use ;/mute ID to mute them, and ;/unmute ID to unmute them
$password = "<insert password here>";
$originalsource = $source;
$originaljob = $job;
$me = 4;
if(!mem("crewnum")) {
    mem("crewnum",0);
}
$found = 0;
$counter = 0;
$me = 0;
while($counter < mem("crewnum")) {
    if (mem("crewlistsource" + $counter) == $originalsource) {
      $me = $counter;
      $found = 1;
    }
    $counter = $counter + 1;
}
if ($found == 0) {
    $me = mem("crewnum");
    broadcast("Adding new user " + $originalsource + ", " + $originaljob + " to database at location " + mem("crewnum"),1461);
    mem("crewlistsource" + $me,$originalsource);
    mem("crewlistjob" + $me,$originaljob);
    mem("crewlistauth" + $me, 0);
    mem("crewlistmute" + $me, 0);
    mem("crewnum",mem("crewnum") + 1);
}
//HACK ALERT
if ($me < 1) { $me = 0; }
if(!mem("usermessagecount")) {
    mem("usermessagecount",0);
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/crewlist") {
    $counter = 0;
    while($counter < mem("crewnum")) {
      broadcast($counter + " - " + mem("crewlistsource" + $counter) + " - " + mem("crewlistjob" + $counter) + " - auth " + mem("crewlistauth" +
$counter) + " - mute " + mem("crewlistmute" + $counter),1461," "," ");
      $counter = $counter + 1;
    }
    $pass = 0;
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/who") {
    broadcast(mem("crewlistsource" + at($expld1, 2)),1461);
    $pass = 0;
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/crewnum") {
    broadcast(mem("crewnum"), 1461);
    $pass = 0;
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/myid") {
    broadcast("Your ID is " + $me, 1461);
    $pass = 0;
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/mute" && mem("crewlistauth" + $me) >= 2) {
    mem("crewlistmute" + at($expld1, 2),1);
    broadcast(mem("crewlistsource" + at($expld1, 2)) + " has been muted.");
    $pass = 0;
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/unmute" && mem("crewlistauth" + $me) >= 2) {
    mem("crewlistmute" + at($expld1, 2),0);
    broadcast(mem("crewlistsource" + at($expld1, 2)) + " has been unmuted.");
    $pass = 0;
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/authme") {
    if(at($expld1, 2) == $password) {
      mem("crewlistauth" + $me, 2);
    }
    $pass = 0;
}
$expld1 = explode($content, " ");
if(at($expld1, 1) ==  "/announce" && mem("crewlistauth" + $me) >= 1) {
    broadcast(" ",$common," "," ");
    broadcast("ANNOUNCEMENT",$common," "," ");
    broadcast("  ",$common," "," ");
    broadcast("  ",$common," "," ");
    broadcast(upper(replace($content, "/announce", " ")),$common," "," ");
    broadcast("    ",$common," "," ");
    broadcast("    ",$common," "," ");
    $pass = 0;
}
if(mem("crewlistmute" + $me) == 1) {
    //$pass = 0;
    $content = " ";
    $source = $originalsource + " (MUTED)";
}
===Cleaner Selective Mute ===
mute and unmute people merely by saying "/mute FULL NAME" the name has to be capitalized and spelled properly.<br>
Authorizes by one or more sources, but could be configured for a password if you really wanted to.<br>
Great for traitor AIs who don't want their victim screaming about the oxygen siphoning!
//recursive implode function, takes a vector and
//combines each member into a string with a space to separate
//by perogi
def implode($vector)
{
$str = at($vector, 1);
remove($vector, $str);
if(length($vector) > 0)
{
$str += " ";
$str += implode($vector);
}
return $str;
}
//mute and unmute function
//use: type /mute or /unmute then the name of the person exactly as it is spelled
//by perogi
if($source == "YOUR NAME HERE") //only the name in this line can use script
{
if(at(explode($content, " "), 1) == "/mute")
{
$vec = explode($content, " ");
remove($vec, "/mute");
$name = implode($vec);
$pass = 0;
mem($name,$name);
}
if(at(explode($content, " "),1) == "/unmute")
{
$pass = 0;
$vec = explode($content, " ");
remove($vec, "/unmute");
mem(implode($vec), 0);
}
}
//checks if source is muted
//possible to get around mute by taking off ID and being unknown, hence why unknowns are all blocked
if($source == mem($source) || $source == "Unknown")
{
$pass = 0;
}


===Horrible Pun Teller===
===Horrible Pun Teller===
Anonymous user