SA-MP Forums Archive
[HELP] Random ATC Names - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] Random ATC Names (/showthread.php?tid=192324)



[HELP] Random ATC Names - [UG]Scripter - 22.11.2010

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.


Re: [HELP] Random ATC Names - [L3th4l] - 22.11.2010

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

pawn Code:
strlen(ATCNames[playerid])



Re: [HELP] Random ATC Names - [UG]Scripter - 22.11.2010

Nope,

Dosent work.



Uploaded with ImageShack.us


Re: [HELP] Random ATC Names - Lorenc_ - 22.11.2010

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);



Re: [HELP] Random ATC Names - [UG]Scripter - 22.11.2010

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.


Re: [HELP] Random ATC Names - Voldemort - 22.11.2010

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"
};



Re: [HELP] Random ATC Names - iggy1 - 22.11.2010

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.


Re: [HELP] Random ATC Names - Voldemort - 22.11.2010

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


Re: [HELP] Random ATC Names - iggy1 - 22.11.2010

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[][] = {



Re: [HELP] Random ATC Names - Lorenc_ - 22.11.2010

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.