Simple game Snippet

By Clayton on Dec 31, 2010

Simple script I whipped up for a game I play while waiting for the new year :D

It's pretty self-explanatory

Constructive criticism welcome :D

Enjoy!

on *:text:!ticketprice*:#:{
  if (!$2) { msg # 4 Usage: !ticketprice price }
  elseif ($2 == %ticketprice) { msg # 4 $2 is already the ticket price }
  else {
    set %ticketprice $2
    msg # 12 The new ticket price is $2
  }
}

on *:text:!currentticketprice:#:{
  if (%ticketprice == $null) { msg # 4 There is no ticket price set }
  else {
    msg # 12 Ticket Price: %ticketprice
  }
}

on *:text:!ticketamount*:#:{
  if (!$2) { msg # 4 Usage: !ticketamount amount }
  elseif ($2 == %ticketamount) { msg # 4 $2 is already the amount of tickets that you have }
  else {
    set %ticketamount $2
    msg # 12 Your new ticket amount is $2
  }
}

on *:text:!currentticketamount:#:{
  if (%ticketamount == $null) { msg # 4 There is no ticket amount set }
  else {
    msg # 12 Ticket amount: %ticketamount
  }
}

Comments

Sign in to comment.
Clayton   -  Jan 01, 2011

@ Jethro_ I will experiment with this snippet and try to consolidate all the text events into one. I do mean price, not prize therefore if($!2 !isnum) is necessary for this script.

Thanks.

 Respond  
Jethro   -  Dec 31, 2010

One critical matter to put into consideration: the $2 can be anything that people enter, so you need to make sure it is a number and nothing else by making an if check:

if ($2 !isnum) { msg # 4 Usage: !ticketprice price }

Unless, of course, you mean prize, not price. There is a difference between these two words.

 Respond  
Jethro   -  Dec 31, 2010

Clayton, experiment with consolidating all the text events into one. There is no useful purpose to make one routine per text event.

 Respond  
Clayton   -  Dec 31, 2010

You are correct that would have been easier, should've thought of that.

Time to edit I think :)

 Respond  
_Teen_   -  Dec 31, 2010

if you didnt set the %ticketprice, why dont use

if (!%ticketprice) { msg # 4 There is no ticket price set }

it will check, if there is any var called %ticketprice, if not, command

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.