Array of a string value, two integers. Select randomly... - 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)
+--- Thread: Array of a string value, two integers. Select randomly... (
/showthread.php?tid=409308)
Array of a string value, two integers. Select randomly... -
Scenario - 21.01.2013
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?
Re: Array of a string value, two integers. Select randomly... -
RajatPawar - 21.01.2013
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?
Re: Array of a string value, two integers. Select randomly... -
Scenario - 21.01.2013
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.
Re: Array of a string value, two integers. Select randomly... -
Scenario - 21.01.2013
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!
Re: Array of a string value, two integers. Select randomly... -
RajatPawar - 21.01.2013
Thanks for the correction and knowledge, cheers!