Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-09-2011, 01:10 AM
Tim_Rocks Tim_Rocks is offline
a true gentlemen
Tim_Rocks's Avatar
Join Date: Aug 2008
Location: USA
Posts: 1,863
Tim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to behold
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?
__________________

Last edited by Tim_Rocks; 11-09-2011 at 01:38 AM..
Reply With Quote
  #2  
Old 11-09-2011, 01:19 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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.
__________________
Quote:

Last edited by fowlplay4; 11-09-2011 at 01:30 AM..
Reply With Quote
  #3  
Old 11-09-2011, 01:39 AM
Tim_Rocks Tim_Rocks is offline
a true gentlemen
Tim_Rocks's Avatar
Join Date: Aug 2008
Location: USA
Posts: 1,863
Tim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to behold
Thanks, that worked. I'm using the class func_numbers on Era though.
__________________
Reply With Quote
  #4  
Old 11-10-2011, 01:40 AM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
PHP Code:
if (UserPrice.text != "Offer") {
  return;

Wouldnt that work?
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #5  
Old 11-10-2011, 09:24 AM
Tim_Rocks Tim_Rocks is offline
a true gentlemen
Tim_Rocks's Avatar
Join Date: Aug 2008
Location: USA
Posts: 1,863
Tim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to behold
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;

__________________
Reply With Quote
  #6  
Old 11-10-2011, 12:54 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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).
__________________
Reply With Quote
  #7  
Old 11-10-2011, 04:05 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by cbk1994 View Post
PHP Code:
if (UserPrice.text != "Offer" && (UserPrice.text || UserPrice.text 2000000)) {
  return;

Probably just a typo but shouldnt it be > 1 and < 2000000?
__________________
MEEP!
Reply With Quote
  #8  
Old 11-11-2011, 07:22 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by callimuc View Post
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.
__________________
Reply With Quote
  #9  
Old 11-12-2011, 07:05 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Man need to concentrate more
__________________
MEEP!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:49 AM.


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