View previous topic :: View next topic |
Author |
Message |
hemersonkla1 Cheater Reputation: 0
Joined: 24 Jun 2015 Posts: 34
|
Posted: Wed Sep 13, 2017 8:32 am Post subject: How to limit ceedit only numbers and only up to an x value? |
|
|
Hello friends. I'm trying to create a ceedit where I can only enter numbers and it only accepts the maximum value of 100. but I have problems when ceedit is empty with no value of an error. would have a simple way to make ceedit only accept numbers and that if you type above a value it erases a house and the message how am I doing? Thanks for the help. I did not find topics about this so I ask. What I did works more or less.
Code: | function CEEdit1Change(sender)
CheckForNumbers()
a=control_getCaption(UDF1_CEEdit1)
b=(tonumber(a))
if b > 100 then
messageDialog("max 100",4,2);
end
end
|
Description: |
|
Filesize: |
60.1 KB |
Viewed: |
3918 Time(s) |
|
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25295 Location: The netherlands
|
Posted: Wed Sep 13, 2017 9:03 am Post subject: |
|
|
Code: |
function CEEdit1Change(sender)
local s=sender.Text
if s=='' then return end
local b=tonumber(sender.Text) --returns nil if not a number
if b~=nil then
if b>100 then
messageDialog('max 100', mtWarning, mbOK)
end
else
messageDialog('Invalid value', mtError, mbOK)
end
end
|
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
hemersonkla1 Cheater Reputation: 0
Joined: 24 Jun 2015 Posts: 34
|
Posted: Wed Sep 13, 2017 9:22 am Post subject: |
|
|
Dark Byte wrote: | Code: |
function CEEdit1Change(sender)
local s=sender.Text
if s=='' then return end
local b=tonumber(sender.Text) --returns nil if not a number
if b~=nil then
if b>100 then
messageDialog('max 100', mtWarning, mbOK)
end
else
messageDialog('Invalid value', mtError, mbOK)
end
end
|
|
Thank you so much. Dark Byte. Another question how can I make a backspace in a house?
In case if the person type 1000 give the message but delete a house and return to 100 or if the person enters 999 delete a house and return to 99. Thank you very much.
Description: |
|
Filesize: |
58.95 KB |
Viewed: |
3908 Time(s) |
|
|
|
Back to top |
|
|
|