[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_
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
Re: [HELP] Random ATC Names -
Lorenc_ - 22.11.2010
Quote:
Originally Posted by iggy1
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
|
yeah like what he said, btw my bad for that long reply.