Array of a string value, two integers. Select randomly...
#1

I should know this by now, but quite frankly I took a break from PAWN for awhile and I can't remember much about arrays.

I want to make an array of names and randomly select a value from the array to put into a string. How could I do that?
Reply
#2

pawn Код:
new array[][]=
{
        "Hello",
        "test"
};
OnSomeCallBack
{
 new random=random(sizeof(array));
 new string[50];
 format(string,sizeof(string),"%s",random);
 SendClientMessage(playerid, -1, string);
 return 1;
}
Something like that?
Reply
#3

Assuming that works, yes. Exactly that.

I'm going to start bookmaking the topics I ask for help on because odds are I'll look back on them.
Reply
#4

As it turns out, that didn't work. I had to do a little experimenting. The array works, but then using it in a string, it would have to be done with this:

pawn Код:
array[random(sizeof(array))]
I appreciate your help, though!
Reply
#5

Thanks for the correction and knowledge, cheers!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)