SA-MP Forums Archive
Prefix and random? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Prefix and random? (/showthread.php?tid=517201)



Prefix and random? - Mark_Weston - 03.06.2014

Hey guys, I was wondering if its possible to use a prefix and a random function?

So for example (1337)&&random(1000000)+9999999

and lets say... the result would be: 13375215721.


Is it possible? If so how would you do it?


Re: Prefix and random? - Deji - 03.06.2014

And do you want fries with that?

Like, what do you want '13375215721' to be, exactly? Just the number? Or a string containing that?


EDIT: If it is just the number, you just add 13370000000 to whatever the output of random(0,99999999) is...

Do note, however, that I don't think Pawn can handle 64-bit numbers, and 13375215721 requires more than 32 bits...


Re: Prefix and random? - Mark_Weston - 04.06.2014

Quote:
Originally Posted by Deji
Посмотреть сообщение
And do you want fries with that?

Like, what do you want '13375215721' to be, exactly? Just the number? Or a string containing that?


EDIT: If it is just the number, you just add 13370000000 to whatever the output of random(0,99999999) is...

Do note, however, that I don't think Pawn can handle 64-bit numbers, and 13375215721 requires more than 32 bits...
Just a number. I am making a prefix system for ID's, Phone numbers, etc. But that was just random numbers its not going to be that long.


Re: Prefix and random? - Deji - 04.06.2014

Well a great lesson about the decimal system and, well, addition.. if you add 100 to 99, you get 199. A trick to working this out, is to imagine the numbers with a matching amount of digits (where any which weren't there are 0) like this:

1000 +
0999 =
1999

2500 +
0099 =
2599

Anywhere there's a 0, a digit can be added (assuming all digits before it are also 0) and it won't change the rest of the number. So I guess you could say it's "prefixed" - but it's simple addition, really