HELP - Comparing input to a random number, generating output based on the difference

!commands edit !d50 $(eval var guess = decodeURIComponent("$(querystring)"); var rand = Math.floor((Math.random() * 50) + 1); var difference = Math.Abs(guess - rand); if difference == 0 “You guessed it right!” else "You were off by " + difference “.”)

Hey @d50gaming!

You weren’t too far off getting it right, it was just a question of syntax/formatting.
You’ll notice that I included one more test to handle errors in case someone doesn’t specify a number between 1 and 50.

!editcom !d50 $(eval g=decodeURIComponent(`$(querystring)`);if(isNaN(g)||g==``||g<1||g>50){`Please specify a number between 1 and 50, $(user).`}else{r=Math.floor(Math.random()*50)+1;d=Math.abs(g-r);d==0?`$(user) guessed it right!`:`$(user) was off by ${d}.`;})

Thank you for the help! It works perfectly for what I want right now. I have another question, if I want there to be certain variables that are stored per user (ex: one user is level 9 and has 25 health, and another is level 6 and has 40), would that be possible?

It could technically be possible to store data with a quote api but it would not be something simple to achieve. But is definitely possible.

Yes, it’s definitely possible using the quote system API, not easy at all, but I’ve made similar commands for others in the past if I remember correctly, so I can give it a try, however you need to have a clear idea of the leveling system you want.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.