Random aircraft tail numbers?
#1

Hey there,

I'm seaking a script that'll assign a random 5 character tail number (AA111 - ZZ999) to each aircraft in my gamemode. I've already created a means to detect when a player enters an aircraft (through OnPlayerStateChange), as I've made a flight instruments textdraw that shows in this case - all I need is the random string.

Bear in mind that I'll need to ensure each tail number is given to the vehicleid, not playerid, and that each is unique (ie no two aircraft could share the same one). It should generate the string, I assume, when a player enters the aircraft, as I'd like it to work for any aircraft I create mid-game.

Any help to get the ball rolling would be greatly appreciated.
Reply
#2

i dont get u
Reply
#3

pawn Код:
new TailNumber[8];
TailNumber[0] = 65 + random(25);
TailNumber[1] = 65 + random(25);
TailNumber[2] = 48 + random(10);
TailNumber[3] = 48 + random(10);
TailNumber[4] = 48 + random(10);
Reply
#4

Quote:
Originally Posted by [ISS]jumbo
Посмотреть сообщение
i dont get u
I'd like a 5 character string (2 random letters + 3 random numbers) to be created for every aircraft. No 2 aircraft can have the same 5 character string, and each aircraft's string will remain the same, no matter who's flying it (at least until a server restart). Essentially a license plate system.

Cheers
Reply
#5

As far as I know, there isn't a way to generate random letters. Unless you made an array with the alphabet and then used "random" to get 2 random letters from that. Otherwise, MadeMan's solution is the best.
Reply
#6

MadeMan's solution does infact generate the letter/number combination I was after. Working well now, thanks alot MadeMan!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)