Random Numbers - 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: Random Numbers (
/showthread.php?tid=401017)
Random Numbers -
Zex Tan - 21.12.2012
Anyone know how to script random numbers, like Tag 2323242 Tag 482783 and maybe of something out of the registered accounts, something like that. (Hope you understand)
Re: Random Numbers -
LarzI - 21.12.2012
Random numbers?
https://sampwiki.blast.hk/wiki/Random
Re: Random Numbers -
Zex Tan - 21.12.2012
Quote:
Originally Posted by LarzI
|
No, I mean that the registration number out of all the registered accounts
Example: You registered first then your registration number is #00001 then the second player registered then their registration account will be #00002
Re: Random Numbers -
LarzI - 21.12.2012
You would have to store the number of players registered in a file, read it when registering a player, and set his number to the number of players register + 1.
I bet you know how to save that to a file, so here's how you would save it
In this example, "pRegs" is the function
you would use to store the information from the file
pawn Код:
//put this globally
new regNum[ MAX_PLAYERS ][ 7 ]; //7 cells for #XXXXX
//registration
format( regNum[ playerid ], 7, "#%05i", ( pRegs + 1 ));
The string regNum would now contain - if there were 5 players registered - "#00006"
Remember to save the new number of registered players after a player registeres.
Re: Random Numbers -
Zex Tan - 21.12.2012
Thank you
Re: Random Numbers -
LarzI - 21.12.2012
- ignore -
Re: Random Numbers -
Zex Tan - 19.01.2013
Quote:
Originally Posted by LarzI
You would have to store the number of players registered in a file, read it when registering a player, and set his number to the number of players register + 1.
I bet you know how to save that to a file, so here's how you would save it
In this example, "pRegs" is the function
you would use to store the information from the file
pawn Код:
//put this globally new regNum[ MAX_PLAYERS ][ 7 ]; //7 cells for #XXXXX
//registration format( regNum[ playerid ], 7, "#%05i", ( pRegs + 1 ));
The string regNum would now contain - if there were 5 players registered - "#00006"
Remember to save the new number of registered players after a player registeres.
|
Wait, I still don't get it of how to code it

? Show me an example at OnPlayerConnect