Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Limiting options (https://forums.graalonline.com/forums/showthread.php?t=134265004)

Tim_Rocks 11-09-2011 01:10 AM

Limiting options
 
Okay, so I have this lovely GUI I'm working on, everything works wonders, except this one issue. I want to limit what a player can enter in the GuiTextEditCtrl.

This is the only thing I've been able to get working..
PHP Code:

if (! (UserPrice.text == "Offer")) {
  return;


I only want the following text order to be allowed, other than offer:
PHP Code:

this.format "$" amount "k"

How would I go about do something like this?

fowlplay4 11-09-2011 01:19 AM

Remove all characters that aren't numbers, and use int to convert the leftovers to a valid integer.

Store the integer in your database and just reformat it when you display it in your GUIs.

You can use this to format the number 1000 to 1,000 for example:
http://forums.graalonline.com/forums...hp?t=134262839

Just append a $ at the front.

Also it's == not = in your if statement there.

Tim_Rocks 11-09-2011 01:39 AM

Thanks, that worked. I'm using the class func_numbers on Era though.

Astram 11-10-2011 01:40 AM

PHP Code:

if (UserPrice.text != "Offer") {
  return;


Wouldnt that work?

Tim_Rocks 11-10-2011 09:24 AM

Yes it would, but I was trying to go for something a long the lines of this.

PHP Code:

if (! (UserPrice.text == "Offer" || UserPrice.text => && UserPrice.text =< 2000000) ) {
  return;



cbk1994 11-10-2011 12:54 PM

That's a really weird way to write it. Why not

PHP Code:

if (UserPrice.text != "Offer" && (UserPrice.text || UserPrice.text 2000000)) {
  return;


What you're doing right now is difficult to read and it isn't clear how it's supposed to be executed (left-to-right, but parentheses would make it clearer, just like you sometimes use them in arithmetic even if not dictated by order of operations for clarity).

callimuc 11-10-2011 04:05 PM

Quote:

Originally Posted by cbk1994 (Post 1673775)
PHP Code:

if (UserPrice.text != "Offer" && (UserPrice.text || UserPrice.text 2000000)) {
  return;



Probably just a typo but shouldnt it be > 1 and < 2000000?

cbk1994 11-11-2011 07:22 PM

Quote:

Originally Posted by callimuc (Post 1673781)
Probably just a typo but shouldnt it be > 1 and < 2000000?

No, look at it carefully. It has to be between 1 and 2,000,000. Your solution would only work if it wasn't. return is reached on true, not false.

callimuc 11-12-2011 07:05 PM

Man need to concentrate more


All times are GMT +2. The time now is 11:25 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.