Thread: command that cost money, missing something.... 317 (pi)

Results 1 to 5 of 5
  1. #1 command that cost money, missing something.... 317 (pi) 
    Registered Member
    Join Date
    Apr 2016
    Posts
    1
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    hey,

    I am coding for some time now and really having fun into coding but some things arn't as easy that the look

    now i can add commands without problems but this is the first time i wanna try to make a command that cost money.



    Code:
                         if(playerCommand.startsWith("veng"))	{
    				c.getItems().deleteItem(995, 100000);
    				c.getItems().addItem(560, 1000);
    				c.getItems().addItem(565, 1000);
    				c.getItems().addItem(9075, 1000);
                                    c.sendMessage("you need 100k coins to do this");
    				  }
    now i know something is missing like:

    Code:
    } else {
    and than some more but if i do it this: it wont work to...

    Code:
       if(playerCommand.startsWith("veng"))
                                 c.getItems().deleteItem(995, 100000);
    				c.getItems().addItem(560, 1000);
    				c.getItems().addItem(565, 1000);
    				c.getItems().addItem(9075, 1000);
    				   } else { 
    				c.sendMessage("you need 100k coins to do this");
    and so on i did try lot of things but i am missing something small but can't get it what?

    Rep + for anyone who can help me on this.


    Thanks already for replying
    Reply With Quote  
     

  2. #2  
    OS-Saradomin Founder & Developer

    Saradomin's Avatar
    Join Date
    Nov 2015
    Posts
    593
    Thanks given
    296
    Thanks received
    149
    Rep Power
    238
    Your missing this line of code.

    Code:
    c.getPA().playerHasItem(995, 1000000);
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Jun 2013
    Posts
    68
    Thanks given
    15
    Thanks received
    37
    Rep Power
    33
    Hey bro, I can help.

    Add me on Skype luke.hashcake.

    Cheers,

    Luke
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Jan 2013
    Posts
    65
    Thanks given
    25
    Thanks received
    16
    Rep Power
    17
    As you said, your code is missing an if/else statement to check if the player has enough money before giving them the runes. This should work:

    Code:
    if(playerCommand.startsWith("veng")) {
    	if(c.getItems().playerHasItem(995, 100000)) {
    		c.getItems().deleteItem(995, 100000);
    		c.getItems().addItem(560, 1000);
    		c.getItems().addItem(565, 1000);
    		c.getItems().addItem(9075, 1000);
    	} else {
    		c.sendMessage("you need 100k coins to do this.");
    	}
    }
    Reply With Quote  
     

  5. #5  
    Donator
    OldReality's Avatar
    Join Date
    Feb 2016
    Posts
    228
    Thanks given
    19
    Thanks received
    12
    Rep Power
    12
    Quote Originally Posted by elitecodez View Post
    Hey bro, I can help.

    Add me on Skype luke.hashcake.

    Cheers,

    Luke

    Why would he add you on skype

    when all you had to put was:

    c.getPA().playerHasItem(995, 1000000);




    Quote Originally Posted by Saradomin View Post
    Your missing this line of code.

    Code:
    c.getPA().playerHasItem(995, 1000000);
    Nice man!
    Attached image
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [PI]Bank Command That Cost Money or an Item(s)
    By fourshorty in forum Snippets
    Replies: 10
    Last Post: 03-10-2014, 10:53 PM
  2. Replies: 4
    Last Post: 01-12-2014, 12:59 AM
  3. Command that kills all npc around you? (PI)
    By Gaun-Di Designs in forum Requests
    Replies: 2
    Last Post: 08-29-2012, 05:45 PM
  4. Replies: 9
    Last Post: 02-17-2011, 12:03 PM
  5. Replies: 15
    Last Post: 10-01-2009, 08:54 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
  •