ID:1297761
 
(See the best response by Pirion.)
Problem description:
Essentially, in my 'world' you gain stat points each level and distribute them. How would I make the input for the number of points you wish to enter into each stat an integer? At the minute I'm simply using 'as num' but it seems that it's being exploited by players.. :p

Thanks a lot!
how is it being exploited exactly? Are they inputting higher numbers then they have points to distribute? As num should work fine you just have to check to make sure they are inputting a valid integer by checking that it isn't below 0, or above the amount of stat points that they have.
I've seen people that check the value before the input - for true validation, it needs to be done after the input to ensure it is still there.
As in, people are putting 3.5 points in, and getting 4 out of it.

I have some validation before obviously making sure they can only put in the amount they have and what not. The issue is putting decimals in!
Best response
use round(var,1) to round to the nearest whole number.
use round(var-0.5,1) to round to the last whole number.
Thanks!

Edit - Whoever sees this can lock it up.
In response to Pirion
Pirion wrote:
use round(var-0.5,1) to round to the last whole number.

round(var) accomplishes this same thing. It always rounds down to the nearest whole number when you use this form.
#define floor(x) round(x)
#define ceil(x) -round(-x)


My goto functions.