SA-MP Forums Archive
random problem - 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: random problem (/showthread.php?tid=163407)



random problem - vuch_hovi - 27.07.2010

i try to do this:
PHP код:
new sl;
new 
rd[26][] = {
"A""B""C""D""E""F""G""H""I","J","K","L","M","N""O","P","Q","R","S","T","U","V","W","X","Y","Z"
}; 
PHP код:
new rand random(sizeof(rd));
sl rd[rand]; 
but this give me error
PHP код:
error 006must be assigned to an array 
on line
sl = rd[rand];


Re: random problem - vuch_hovi - 27.07.2010

somone? sory if i broke the ruls i'm new


Re: random problem - Shadow™ - 27.07.2010

pawn Код:
forward RandomEx(min, max);
pawn Код:
new charset[26]= "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
pawn Код:
array = charset[RandomEx(0,26)]
pawn Код:
public RandomEx(min, max) // by ****** (Similar to PHP Random)
{
    return random(max - min) + min;
}



Re: random problem - vuch_hovi - 27.07.2010

this is not work 1 error:
PHP код:
error 018initialization data exceeds declared size 
in line
PHP код:
new charset[26]= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"



Re: random problem - Kar - 27.07.2010

change new rand = random(26);


Re: random problem - vuch_hovi - 27.07.2010

man i do letters random not numbers!


Re: random problem - smeti - 27.07.2010

Try:
pawn Код:
new
    sl,
    rd[]= { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };

new
    rand = random(sizeof(rd));
sl = rd[rand];
printf("%c Pos: %d", sl, rand);
pawn Код:
new
    sl[2],
    rd[26][] =
{
    "A", "B", "C", "D", "E", "F", "G", "H", "I","J","K","L","M","N", "O","P","Q","R","S","T","U","V","W","X","Y","Z"
};

new
    rand = random(sizeof(rd));
sl = rd[rand]; // 'B' '\0' 2 cells
printf("%s Pos: %d", sl, rand);



Re: random problem - vuch_hovi - 28.07.2010

ohhh this work!!!!!!!!!!!!!!