[HELP] Random ATC Names
#1

Okay,

So once again I ran into an issue with my ATC system,

It should be chooseing a random name from the Table, Yet it does not.

CODE:

pawn Code:
new ATCNames[][] = {
"Tango 109",
"Foxtrot 102",
"Adam 554",
"Cactus 1585",
"Julet 282",
"Delta 102",
"American 22",
"United 93",
"Alpha 2321",
"Echo 9",
"Echo 997",
"juliet 882"
};
Command:

pawn Code:
// ***** ATC Request Take Off *****
    if (strcmp("/takeoff", cmdtext, true) == 0)
    {
    new string[128];
    new location[MAX_ZONE_NAME];
    GetPlayer2DZone(playerid, location, MAX_ZONE_NAME);
    format(string,sizeof string,"*** [ATC] %s requesting permission to take off from %s, Over ***",strval(ATCNames[playerid]),location);
    SendMessageToATC(string);
    format(string,sizeof string,"*** [ATC] %s requesting permission to take off from %s, Over ***",strval(ATCNames[playerid]),location);
    SendClientMessage(playerid,COLOR_YELLOW,string);
    ATCAllow[playerid] = 1;
    return 1;
    }
On a Side note:

pawn Code:
ATCNames[random(sizeof(ATCNames))]
was also tried and un sucessful.
Reply
#2

You are formatting 'ATCNames[playerid]' wrong, strval is for integers / digits. Use:

pawn Code:
strlen(ATCNames[playerid])
Reply
#3

Nope,

Dosent work.



Uploaded with ImageShack.us
Reply
#4

pawn Code:
new ATCNames[] = {
"Tango 109",
"Foxtrot 102",
"Adam 554",
"Cactus 1585",
"Julet 282",
"Delta 102",
"American 22",
"United 93",
"Alpha 2321",
"Echo 9",
"Echo 997",
"juliet 882"
};
pawn Code:
new rand = random(sizeof(ATCNames));
    format(string,sizeof(string),"[ATC] %s requesting permission to take off from %s, Over ***",ATCNames[rand], location);
Reply
#5

Quote:
Originally Posted by Lorenc_
View Post
pawn Code:
new ATCNames[] = {
"Tango 109",
"Foxtrot 102",
"Adam 554",
"Cactus 1585",
"Julet 282",
"Delta 102",
"American 22",
"United 93",
"Alpha 2321",
"Echo 9",
"Echo 997",
"juliet 882"
};
pawn Code:
new rand = random(sizeof(ATCNames));
    format(string,sizeof(string),"[ATC] %s requesting permission to take off from %s, Over ***",ATCNames[rand], location);
Yeh now the command dosent work.
Reply
#6

pawn Code:
new ATCNames[] = {
"Tango 109",
"Foxtrot 102",
"Adam 554",
"Cactus 1585",
"Julet 282",
"Delta 102",
"American 22",
"United 93",
"Alpha 2321",
"Echo 9",
"Echo 997",
"juliet 882"
};
Set size, in this case sizeof will be 0, use
pawn Code:
new ATCNames[12][20] = {
"Tango 109",
"Foxtrot 102",
"Adam 554",
"Cactus 1585",
"Julet 282",
"Delta 102",
"American 22",
"United 93",
"Alpha 2321",
"Echo 9",
"Echo 997",
"juliet 882"
};
Reply
#7

Lorencs code looks good to me it uses the same system as the random message tutorial on the wiki and that works.
https://sampwiki.blast.hk/wiki/Random_Messages#


BTW, i know you probably don't need that tut but if you look at it, that is very simalar to what you need.
Reply
#8

The thing is that he use only one [], he need use ATCNames[][], but with ATCNames[12][20], you give exact size
Reply
#9

Oh shit yeah, but you dont need to give them sizes leave them both empty "[][]" (that way you wont need to keep changing the size of the array everytime you add something) the compiler will calculate the size at compile time.

EDIT: for the OP try use lorenc' code but change it to this
pawn Code:
new ATCNames[][] = {
Reply
#10

Quote:
Originally Posted by iggy1
View Post
Oh shit yeah, but you dont need to give them sizes leave them both empty "[][]" (that way you wont need to keep changing the size of the array everytime you add something) the compiler will calculate the size at compile time.

EDIT: for the OP try use lorenc' code but change it to this
pawn Code:
new ATCNames[][] = {
yeah like what he said, btw my bad for that long reply.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)