Page 1 of 2 1 2 LastLast
Results 1 to 10 of 17

Thread: Trav's scripts

  1. #1
    cat supremacist Lieutenant
    Join Date
    Jul 2016
    Location
    Melbourne
    Posts
    907

    Trav's scripts

    Hey, I'm going to be posting some of the scripts I have made here.
    They may not be the first of its kind but everything here I have made.
    Oh, and if my scripts has some problems, you can always fix it then post it here
    First one :
    PHP Code:
    function onCreated()  {
      
    this.chat "Tell me the diameter (in centimers) of the circle which it's circumference you want to know?";
      }


    function 
    onPlayerChats() {
      
    this.chat player.chat pi;
      } 
    That is a circumference calculator, here is a gif https://gyazo.com/edb50104ace6d16f4defb240516fcee1
    Last edited by leaf me alone; 01-01-2017 at 10:55 PM. Reason: Forgot something

  2. #2
    idk what this is
    Join Date
    Nov 2013
    Location
    Heaven
    Posts
    2,948
    Pretty cool lol. Post more

  3. #3
    cat supremacist Lieutenant
    Join Date
    Jul 2016
    Location
    Melbourne
    Posts
    907
    Quote Originally Posted by Grandpa Illusions View Post
    Pretty cool lol. Post more
    Thanks haha, I'll probably post more when I make a better/cleaner version of this one.
    Maybe a type that filters strings.

  4. #4
    Overlord Sottocapo N!chola$'s Avatar
    Join Date
    Jun 2015
    Location
    Canada
    Posts
    4,784
    Nice
    Ask me anything and ill try my best to answer

  5. #5
    Yes Sottocapo imaginary's Avatar
    Join Date
    Jan 2014
    Location
    Literally a place you don’t wanna be at
    Posts
    11,992
    Hey I don't understand anything about scripts
    But hey pretty cool

  6. #6
    Banned
    Join Date
    Aug 2013
    Location
    France
    Posts
    286
    Quote Originally Posted by mrgadosh View Post
    Hey I don't understand anything about scripts
    But hey pretty cool
    The script simply multiplies the player input by pi.

    Problem with this script though, is that it'll try to multiply anything that the player says, even letters, words or sentences.

    Here's how I'd do it:
    PHP Code:
    // Created by Kirzey
    function onCreated() {
      
    showcharacter();
      
    this.head "head0.png";
      
    this.colors[0] = "orange";
      
    this.colors[1] = "white";
      
    this.colors[2] = "blue";
      
    this.colors[3] = "red";
      
    this.colors[4] = "black";
      
    this.shield "no-shield.png";
      
    this.dir 2;
      
    this.chat "Tell me the diameter (in centimers) of the circle which it's circumference you want to know?";
      
    setcharani("idle",null);
    }

    function 
    onPlayerChats() {
      if (
    player.chat.start("a","b""c","d","e","f","g","h","i","j","k","l","m","o","p","q","r","s","t","u","v","w","x","y","z")) { //If the players chat starts by a letter, return. The NPC will say "-3.141592653" 
          
    return;                                                                                                                               //which is an error. (Can't multiply letters)

    } else { //Else, if the players chat starts by a number
      
    this.chat player.chat pi//Multiply the players chat by Pi
      
    }

    Last edited by Kirzey; 01-01-2017 at 10:03 PM.

  7. #7
    Not Actually Banned Yet Bulletzone's Avatar
    Join Date
    Apr 2015
    Location
    United Kingdom
    Posts
    2,849
    Quote Originally Posted by Kirzey View Post
    The script simply multiplies the player input by pi.

    Problem with this script though, is that it'll try to multiply anything that the player says, even letters, words or sentences.

    Here's how I'd do it:
    PHP Code:
    // Created by Kirzey
    function onCreated() {
      
    showcharacter();
      
    this.head "head0.png";
      
    this.colors[0] = "orange";
      
    this.colors[1] = "white";
      
    this.colors[2] = "blue";
      
    this.colors[3] = "red";
      
    this.colors[4] = "black";
      
    this.shield "no-shield.png";
      
    this.dir 2;
      
    this.chat "Tell me the diameter (in centimers) of the circle which it's circumference you want to know?";
      
    setcharani("idle",null);
    }

    function 
    onPlayerChats() {
      if (
    player.chat.start("a","b""c","d","e","f","g","h","i","j","k","l","m","o","p","q","r","s","t","u","v","w","x","y","z")) { //If the players chat starts by a letter, return. The NPC will say "-3.141592653" 
          
    return;                                                                                                                               //which is an error. (Can't multiply letters)

    } else { //Else, if the players chat starts by a number
      
    this.chat player.chat pi//Multiply the players chat by Pi
      
    }


    Well things just got real
    "A fool thinks they know everything but a wise person knows there's something to learn from everyone"
    -
    "Great leaders don't complain about the tools they are given. They work to sharpen them"

  8. #8
    cat supremacist Lieutenant
    Join Date
    Jul 2016
    Location
    Melbourne
    Posts
    907
    Quote Originally Posted by Kirzey View Post
    The script simply multiplies the player input by pi.

    Problem with this script though, is that it'll try to multiply anything that the player says, even letters, words or sentences.

    Here's how I'd do it:
    PHP Code:
    // Created by Kirzey
    function onCreated() {
      
    showcharacter();
      
    this.head "head0.png";
      
    this.colors[0] = "orange";
      
    this.colors[1] = "white";
      
    this.colors[2] = "blue";
      
    this.colors[3] = "red";
      
    this.colors[4] = "black";
      
    this.shield "no-shield.png";
      
    this.dir 2;
      
    this.chat "Tell me the diameter (in centimers) of the circle which it's circumference you want to know?";
      
    setcharani("idle",null);
    }

    function 
    onPlayerChats() {
      if (
    player.chat.start("a","b""c","d","e","f","g","h","i","j","k","l","m","o","p","q","r","s","t","u","v","w","x","y","z")) { //If the players chat starts by a letter, return. The NPC will say "-3.141592653" 
          
    return;                                                                                                                               //which is an error. (Can't multiply letters)

    } else { //Else, if the players chat starts by a number
      
    this.chat player.chat pi//Multiply the players chat by Pi
      
    }

    Thats close to what thugmuffin wrote for me.
    It wasn't working the way I wanted it to so I just posted the simplified version.
    I never knew player.chat.start was a thing.
    Thanks Learnt quite abit.

  9. #9
    Yes Sottocapo imaginary's Avatar
    Join Date
    Jan 2014
    Location
    Literally a place you don’t wanna be at
    Posts
    11,992

  10. #10
    cat supremacist Lieutenant
    Join Date
    Jul 2016
    Location
    Melbourne
    Posts
    907
    Ok, so we've made a better version.
    PHP Code:
    function onCreated() {
      
    showcharacter();
      
    this.head "head0.png";
      
    this.colors[0] = "orange";
      
    this.colors[1] = "white";
      
    this.colors[2] = "blue";
      
    this.colors[3] = "red";
      
    this.colors[4] = "black";
      
    this.shield "no-shield.png";
      
    this.dir 2;
      
    this.nick="Kirzey";
      
    this.chat "Tell me the diameter (in centimers) of the circle which it's circumference you want to know?";
      
    setcharani("sit",null);
    }

    function 
    onPlayerChats() {
      
    temp.= {"a""b""c""d""e""f""g""h""i""j","k","l","m","o","p","q","r","s","t","u","v","w","x","y","z"};
      
    temp.chat player.chat;
      for (
    temp.0temp.<= 26temp.++) {
        if (
    player.chat==temp.l[temp.n]) { //If the players chat starts by a letter, return. The NPC will say "-3.141592653"
          
    this.chat "Only numbers!";
          return;
        }
        if (
    temp.chat.pos(temp.l[temp.n])>=0) {
          
    this.chat "Only numbers!";
          return;
        }else{ 
    //Else, if the players chat starts by a number
          
    this.chat player.chat pi//Multiply the players chat by Pi
        
    }
      }

    This version is similar to Kirzey's however his only filtered singular letter player chat, this one filters everyting thats a letter however it does not filter symbols like !@#$%^% etc. You can add that but I'm too lazy
    I think a much more simpler version can be made.
    Props to thugmuffin and Kirzey
    Last edited by leaf me alone; 02-12-2017 at 07:26 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •