26.02.2009, 15:11
First this wont work
because you create an array for arrays also you need two dimensions not one
Than to your random problem
pawn Code:
new Names[] = {"Michael", "John", "Katey", "Richard", "Robbin"};
pawn Code:
new Names[][] =
{ //just made the brace around the names to see better that they are arrays too
{"Michael"},
{"John"},
{"Katey"},
{"Richard"},
{"Robbin"}
};
pawn Code:
new string[128];
format(string, sizeof(string), "%s says hello to you!", Names[random(sizeof(Names))]);
SendClientMessage(playerid, 0xFFFFFFAA, string);
//we get the array size with sizeof(Names) - the size of the first dimension is 5
//so we do indirect random(5); which will return a number from -1 till 5 (0, 1, 2, 3 or 4)
//so when random as example return 3 it will be Names[3] and that is "Richard"