When printing a single character (which is just a number), use %c (which stands for character, obviously). %s is for strings (arrays).
Also be more specific. "It doesn't work". What doesn't work? Does it print weird characters? (Which is likely since you used specificer s instead of c). Or does it not work at all? If so, there is another problem going on.
random() takes as parameter "max", not a "range". For example, if the input is 15 it will return a random value from 0 up to 14. Negative values (0-9 = -9) will print large values.
When wrapping something in single quotes (eg. 'a', '9') it will return the numeric value of that character. For example, '5' is 5, but 'a' has numeric value 97. So when using:
You're actually doing:
Note that these character numbers are ASCII numbers (if I'm not wrong): http://www.asciitable.com/ (I believe SAMP covers 128 of them?)
Also be more specific. "It doesn't work". What doesn't work? Does it print weird characters? (Which is likely since you used specificer s instead of c). Or does it not work at all? If so, there is another problem going on.
Quote:random('0'-'9')https://open.mp/docs/scripting/functions/random
random() takes as parameter "max", not a "range". For example, if the input is 15 it will return a random value from 0 up to 14. Negative values (0-9 = -9) will print large values.
When wrapping something in single quotes (eg. 'a', '9') it will return the numeric value of that character. For example, '5' is 5, but 'a' has numeric value 97. So when using:
Code:
'A' random('Z' - 'A' 1)
Code:
65 random(90 - 65 1) //65 random(26): Output will be 65 (0-25), so output will be atleast 65 ('A') and maximal 65(90) ('Z')
Quote:Computers can only understand numbers, so an ASCII code is the numerical representation of a character such as 'a' or '@' or an action of some sort