Page 4 of 5 FirstFirst ... 2 3 4 5 LastLast
Results 31 to 40 of 45

Thread: iMask's Scripts

  1. #31
    Quote Originally Posted by iMask View Post
    Thanks guys!

    I'm trying to create something where if you say /open (number here), the door would open for that many seconds.

    PHP Code:
    function onCreated () {
      
    setimg("door.png");
      
    setshape (1,32,32);
    }
    //#CLIENTSIDE
      
    function onPlayerChats () {
        if (
    player.chat.starts == "/open" && clientr.staff == 1) {
          
    this.time.open player.chat.substring(6).trim();
            
    this.show();
            
    sleep(???); //see below
            
    this.hide();
        }
      } 
    If anyone could tell me what to put inside the sleep function and tell me if I'm doing it right, that would be great!

    That's a useless script.
    We already have one to where you say any number and right click he door, it will open it.
    Questions? Don't be afraid to message me.

  2. #32
    Big Cheese Captain
    Join Date
    Jun 2013
    Posts
    1,029
    Quote Originally Posted by AceLion View Post
    That's a useless script.
    We already have one to where you say any number and right click he door, it will open it.
    1. It's called practise
    2. This is not for iEra
    iEra Developer / SFX Admin

    Need help? Contact me:
    Email: [email protected]

  3. #33
    Big Cheese Captain
    Join Date
    Jun 2013
    Posts
    1,029
    Script Continued
    PHP Code:
    function onCreated () {
      
    setimg("door.png");
      
    setshape (1,32,32);
      
    this.open off;
    }
    //#CLIENTSIDE
      
    function onPlayerChats () {
        if (
    player.chat.starts == "/open" && clientr.staff == 1) {
          
    this.timeOpen player.chat.substring(6).trim();
            
    this.show();
            
    this.open on;
            
    this.chat "Open for "@this.timeOpen@" seconds";
            
    sleep(this.timeOpen);
            
    this.hide();
            
    this.open off;
            
    this.chat "";
        }
      }

    function 
    onPlayerGrabs () {
      if (
    this.open == "on") {
        
    setlevel2 ("level_name.nw"3030);
      }

    Last edited by iMask; 01-14-2015 at 02:49 PM.
    iEra Developer / SFX Admin

    Need help? Contact me:
    Email: [email protected]

  4. #34
    Hi, A few things to take into consideration.
    PHP Code:
      this.open off
    Would be a string so it should be
    PHP Code:
      this.open "off"
    And because you did not put the apostrophes to signal it is a string you can not use an if statement asking if it is certain string.
    Good job none the less, that is all I noticed from a first glance I'll check the whole thing another time!
    Noof was here.

  5. #35
    Big Cheese Captain
    Join Date
    Jun 2013
    Posts
    1,029
    Quote Originally Posted by Noofboy12 View Post
    PHP Code:
      this.open off
    Would be a string so it should be
    PHP Code:
      this.open "off"
    Weird, because the code below is tested, and it works (tested on the testbed server)

    Spawn Staff Blocks
    PHP Code:
    //Coded by iMask
    findplayer("id").addWeapon(name);
      function 
    onActionServerSide () {
        
    putnpc2 (player.0.5player.0.5"join \"imask_block\");");
    }
    //#CLIENTSIDE
      
    function onCreated () {
        
    this.on false;
    }
      function 
    onPlayerChats () {
        if (
    player.chat == "/block on") {
          
    this.on true;
          
    player.chat "On! Press 5 to spawn blocks!";
        }
        if (
    player.chat "/block off") {
          
    this.on false;
          
    player.chat "Off!";
        }
      }

      function 
    onKeyPressed (code,key) {
        if (
    this.on == true && temp.key == 5) {
          
    player.chat "Spawned! Slash to destroy!";
          
    triggerserver ("gui"this.nameNULL);
        }

    IN THE CLASS:

    PHP Code:
    function onCreated () {
      
    setimg ("block.png");
      
    setshape (1,32,32);
    }

    function 
    onWa**** () { //function onWas-Hit, Era Go censored it
      
    this.destroy();

    iEra Developer / SFX Admin

    Need help? Contact me:
    Email: [email protected]

  6. #36
    Big Cheese Captain
    Join Date
    Jun 2013
    Posts
    1,029
    Jail script
    PHP Code:
    //Coded by iMask
    findplayer("id").addweapon(name);
    function 
    onActionServerSide () {
        if (
    pl.account == player.jail) {
        
    setlevel2 ("jail.nw"3030);
      }
    }
    //#CLIENTSIDE
      
    function onPlayerChats () {
        if (
    player.chat.starts == "/jail");
        
    player.jail player.chat.substring(5).trim();
        
    triggerserver("gui"this.nameplayer.jail);
        }

    iEra Developer / SFX Admin

    Need help? Contact me:
    Email: [email protected]

  7. #37
    Big Cheese Captain
    Join Date
    Jun 2013
    Posts
    1,029
    Since I have not updated this thread in ages, I'll post a fully functional lottery script. I still have to add a timer, but other than that, I'm happy with the results.

    Lottery Script

    PHP Code:
    //Coded by iMask
    function onPlayerLogin(temp.pl) {
      
    temp.pl.addweapon(this.name);
    }

    function 
    onActionServerSide(temp.cmd) {
      switch(
    temp.cmd) {
        case
    "one":
          if (
    clientr.coins 25) {
            
    player.chat "I don't have enough to buy a lottery ticket!";
            return;
          }
          if (
    clientr.coins >= 25) {
            
    clientr.coins -= 25;
            
    this.jackpot += 20;
            
    player.chat "Bought one ticket! Coins: " clientr.coins;
            
    this.winners.add(player.account);
          }
          break;
          
          case
    "reset":
            echo(
    "Lottery: " player.account " has ended the lottery!");
            
    sleep(5);
            echo(
    "Lottery: " this.winners.size() @ " tickets were sold");
            
    this.winner int(random(0,this.winners.size()));
            
    sleep(5);
              if (
    findplayer(this.winners[this.winner]) == NULL) {
                
    temp.pl = new TServerPlayer(@this.winners[this.winner]);
                
    temp.pl.clientr.coins += this.jackpot;
                
    serverr.lastlotterywon temp.pl.account;
                echo(
    "Lottery Winner: Offline player " temp.pl.account " ("@temp.pl.nick@") has won!");
                
    temp.pl.saveaccount();
                
    temp.pl.destroy();
              } else {
              
    player.chat "I have won the lottery!";
              
    clientr.coins += this.jackpot;
              
    serverr.lastlotterywon this.winners[this.winner];
              echo(
    "Lottery Winner: Online Winner " this.winners[this.winner] @ ". He won " this.jackpot " coins.");
            }
            
    player.chat this.winners[this.winner] @ " has won!";
            
    this.winners = {};
            
    this.jackpot 0;
            echo(
    "Lottery: Lottery reset!");
            break;
            
          case
    "onlotcheck":
            
    player.chat this.winners.size() @ " tickets have been sold";
            break;
      }
    }

    //#CLIENTSIDE
    function onCreated() {
      
    this.winners = {};
    }
    function 
    onPlayerChats() {
      if (
    player.chat == "/lottery") {
        
    Buy_1.visible true;
        
    Close.visible true;
        
    Timer.visible true;
        
    showGui();
      }
      if (
    player.chat == "/endlottery" && player.account == "Graal762515") {
        
    triggerserver("gui",this.name,"reset");
      }
      if (
    player.chat == "/showlottery" && clientr.isStaff) {
        
    triggerserver("gui",this.name,"onlotcheck");
      }
    }
    function 
    showGui() {
      new 
    GuiButtonCtrl("Buy_1") {
        
    profile GuiBlueButtonProfile;
        
    600;
        
    200;
        
    width 250;
        
    height 30;
        
    text "Buy lottery ticket (25 coins for 1 ticket)";
      }
      new 
    GuiButtonCtrl("Close") {
        
    profile GuiBlueButtonProfile;
        
    600;
        
    230;
        
    width 250;
        
    height 30;
        
    text "Close";
      }
      new 
    GuiTextCtrl("Timer") {
        
    profile GuiBlueTextProfile;
        
    1150;
        
    220;
        
    text this.timer;
      }
    }
    function 
    Buy_1.onAction() {
      
    triggerserver("gui",this.name,"one");
    }
    function 
    Close.onAction() {
      
    Buy_1.visible false;
      
    Close.visible false;
      
    Timer.visible false;

    iEra Developer / SFX Admin

    Need help? Contact me:
    Email: [email protected]

  8. #38
    Big Cheese Sottocapo
    Join Date
    Jan 2015
    Location
    Canada
    Posts
    4,053
    Scripts look so complicated and confusing.

  9. #39
    Quote Originally Posted by Pumpkins View Post
    Scripts look so complicated and confusing.
    Scripting in general can look very intimidating, this is why not many people take the challenge to learn. For a beginner these scripts can look confusing and long.

    If you learn and you get to a good level, this will all make sense.

    Noof was here.

  10. #40
    Big Cheese Captain
    Join Date
    Jun 2013
    Posts
    1,029
    Quote Originally Posted by Noofboy12 View Post
    Scripting in general can look very intimidating, this is why not many people take the challenge to learn. For a beginner these scripts can look confusing and long.

    If you learn and you get to a good level, this will all make sense.

    ^^^ agreed.
    iEra Developer / SFX Admin

    Need help? Contact me:
    Email: [email protected]

Posting Permissions

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