Results 1 to 3 of 3

Thread: I need scripting help!

  1. #1
    Veteran
    Join Date
    Jun 2013
    Posts
    167

    I need scripting help!

    I have two scripts in progress that I can't get to work, can somebody tell me what i'm doing wrong?

    1. When I touch the NPC it gives me 1 coin, and 1 questwine.
    ______
    function onPlayerTouchsMe() {
    this.chat = "I lost my wine bottle! Where could it have gone? Please find it for me!";
    if (player.clientr.questwine >= 1 && player.clientr.winequest = 0); { //checks if player has the wine bottle, and no item "winequest"
    player.clientr.coins += 50 && player.clientr.questwine = 0 && player.clientr.winequest += 1; //gives the player coins and the item. . . . . . "winequest" so they can't redo the quest.
    }
    }
    ______

    2. When I say "deposit" nothing happens, and i'm pretty sure I didnt do the coin transferring correctly.
    ______
    //#CLIENTSIDE
    function onPlayerChats() {
    if (player.chat = "bank") {
    this.chat = "Deposit or Withdraw?";
    } if (this.chat = "Deposit or Withdraw?" && player.chat = "deposit") {
    this.chat = "Please state the amount you would like to deposit."; {
    player.clientr.bankcoins += player.chat && player.clientr.coins -= player.chat;
    }
    }
    }
    ______

    sorry the forums dont show spaces

  2. #2

    Lightbulb

    Hi.

    Code:
    function onPlayerTouchsMe() {
       this.chat = "I lost my wine bottle! Where could it have gone? Please find it for me!";
       if (player.clientr.questwine >= 1 && player.clientr.winequest = 0); { //checks if player has the wine bottle, and no item "winequest"
       player.clientr.coins += 50 && player.clientr.questwine = 0 && player.clientr.winequest += 1; //gives the player coins and the item. . . . . . "winequest" so they can't redo the quest.
       }
    }
    The line highlighted in red will not work. When comparing using conditional statements, you must use "==" instead of "=" for equals to.

    You will also need to separate each of the statements by itself.

    PHP Code:
    Example:

    if (
    player.clientr.questwine >= && player.clientr.winequest == 0); {
       
    player.clientr.coins += 50;
       
    player.clientr.questwine 0;
       
    player.clientr.winequest += 1;

    Code:
    //#CLIENTSIDE
    function onPlayerChats() {
       if (player.chat = "bank") {
          this.chat = "Deposit or Withdraw?";
       } 
        if (this.chat = "Deposit or Withdraw?" && player.chat = "deposit") {
          this.chat = "Please state the amount you would like to deposit.";{ 
          player.clientr.bankcoins += player.chat && player.clientr.coins -= player.chat;
       }
       }
    }
    The highlighted portion will not work, it has incorrect syntax.

    PHP Code:
    Solution:

    //#CLIENTSIDE
    function onPlayerChats() {
       if (
    player.chat "bank") {
          
    this.chat "Deposit or Withdraw?";
       } 
       if (
    this.chat == "Deposit or Withdraw?" && player.chat == "deposit") {  //use "=="
          
    this.chat "Please state the amount you would like to deposit.";
       }
       if (
    this.chat == "Please state the amount you would like to deposit.") {
          
    player.clientr.bankcoins += player.chat;  //here I would suggest checking to see if player.chat 
          
    player.clientr.coins -= player.chat;        //is an integer, has no characters, not a negative number, etc. before depositing 
       
    }


  3. #3
    Street Boss John's Avatar
    Join Date
    Jun 2013
    Location
    Lebanon
    Posts
    825
    Small note, don't store variables that players can see. E.G: this.chat == "Deposit or Withdraw?" wouldn't really be tolerated. It would be better if you can use a variable name like this.w_or_d = true/false; and all you have to do is if (this.w_or_d == true && player.chat == "deposit")...
    -Johnaudi

Posting Permissions

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