View previous topic :: View next topic |
Author |
Message |
violaboy13 Newbie cheater
Reputation: 0
Joined: 23 Jul 2014 Posts: 11
|
Posted: Wed Oct 12, 2016 11:03 pm Post subject: Can't figure out simple greater than and less than on string |
|
|
I have an edit box that I'm putting numbers into. I want only numbers 10-40. Any number outside this range should turn the box red and write #20 into the address. This code sort of works but I can still put numbers 100 and above into the box and they will be written to the address instead of #20. Shouldn't the var3 > "40" take care of any number above 40? What am I doing wrong? Thanks for any help provided.
local number = readBytes("mainapp.exe+13A84CC",1)
var3=(setProperty(MaddenScripts_CEEdit3,"Text",(number)))
function AccClock(sender)
var3=(getProperty(MaddenScripts_CEEdit3,"Text"))
var3=(string.match(var3,"^%d+"))
if (var3 < "10") then
WriteBytes(0x17A84CC,"20")
control_setColor(MaddenScripts_CEEdit3, 255)
elseif (var3 > "40") then
WriteBytes(0x17A84CC,"20")
control_setColor(MaddenScripts_CEEdit3, 255)
else
WriteBytes(0x17A84CC,var3)
control_setColor(MaddenScripts_CEEdit3, 000255000)
end
end
|
|
Back to top |
|
 |
predprey Master Cheater
Reputation: 24
Joined: 08 Oct 2015 Posts: 486
|
Posted: Wed Oct 12, 2016 11:57 pm Post subject: |
|
|
1. what is wrong is you are comparing var3 with a string because of the quotation marks.
2. this is right: var3 < 10; var3 > 40
this is wrong: var3 < "10"; var3 > "40"
3. BOOMZZZ
|
|
Back to top |
|
 |
violaboy13 Newbie cheater
Reputation: 0
Joined: 23 Jul 2014 Posts: 11
|
Posted: Thu Oct 13, 2016 7:04 am Post subject: |
|
|
I thought that too, but if I take away the quotation marks I get an error that I'm comparing a string (var3) with a number. How do I convert the string (var3) to a number so that I'm comparing a number with a number? Thanks
Edit: OK I figured it out; I needed this code to convert string to number
var3=tonumber(var3)
I knew this had to be a simple solution; thanks for your help.
|
|
Back to top |
|
 |
|