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



random textdraws - ancezas - 15.09.2014

Hello, how can i do random textdraws?
pawn Код:
LogIn = TextDrawCreate( 0.000000, -5.226698, "loadsc1:loadsc1" );
    TextDrawTextSize( LogIn, 657.600036, 459.200103 );
    TextDrawAlignment( LogIn, 1 );
    TextDrawColor( LogIn, -1 );
    TextDrawFont( LogIn, 4 );
i have this code, and i whant to make loadsc1:loadsc1 random like loadsc1:loadsc1; loadsc2:loadsc2 and etc.


Re: random textdraws - IamPRO - 15.09.2014

pawn Код:
new mrand = random(4);//I don't know how many are here so lets take 5, note that 0 is also counted.
switch(mrand)
{
    case 0:
    {
        LogIn = TextDrawCreate( 0.000000, -5.226698, "loadsc1:loadsc1" );
        TextDrawTextSize( LogIn, 657.600036, 459.200103 );
        TextDrawAlignment( LogIn, 1 );
        TextDrawColor( LogIn, -1 );
        TextDrawFont( LogIn, 4 );
        return 1;
    }
    case 1:
    {
        //create 2nd textdraw
    }
    // and go on
}



Re: random textdraws - ikey07 - 15.09.2014

More reasonable would be like this.
pawn Код:
new str[64];
format(str,sizeof(str), "loadsc%d:loadsc%d" ,random(10)+1 ,random(10)+1); //Not sure if there was 10 load screens
LogIn = TextDrawCreate( 0.000000, -5.226698,str);
TextDrawTextSize( LogIn, 657.600036, 459.200103 );
TextDrawAlignment( LogIn, 1 );
TextDrawColor( LogIn, -1 );
TextDrawFont( LogIn, 4 );
and +1 is because there is no loadsc0


Re: random textdraws - ancezas - 15.09.2014

Quote:
Originally Posted by ikey07
Посмотреть сообщение
More reasonable would be like this.
pawn Код:
new str[64];
format(str,sizeof(str), "loadsc%d:loadsc%d" ,random(10)+1 ,random(10)+1); //Not sure if there was 10 load screens
LogIn = TextDrawCreate( 0.000000, -5.226698,str);
TextDrawTextSize( LogIn, 657.600036, 459.200103 );
TextDrawAlignment( LogIn, 1 );
TextDrawColor( LogIn, -1 );
TextDrawFont( LogIn, 4 );
and +1 is because there is no loadsc0
not working


Re: random textdraws - AroseKhanNiazi - 15.09.2014

Quote:
Originally Posted by ancezas
Посмотреть сообщение
not working
try 4 to 5 times because he said he was not sure if there are 10 of it if there aren't then change it to the number that there are


Re: random textdraws - ancezas - 15.09.2014

there is 14


Re: random textdraws - AroseKhanNiazi - 15.09.2014

hmm strange should work that way did
pawn Код:
LogIn = TextDrawCreate( 0.000000, -5.226698, "loadsc1:loadsc1" );
    TextDrawTextSize( LogIn, 657.600036, 459.200103 );
    TextDrawAlignment( LogIn, 1 );
    TextDrawColor( LogIn, -1 );
    TextDrawFont( LogIn, 4 );
this worked ?
now i remember
pawn Код:
new str[64];
format(str,sizeof(str), "loadsc%d:loadsc1" ,random(10)+1); //Not sure if there was 10 load screens
LogIn = TextDrawCreate( 0.000000, -5.226698,str);
TextDrawTextSize( LogIn, 657.600036, 459.200103 );
TextDrawAlignment( LogIn, 1 );
TextDrawColor( LogIn, -1 );
TextDrawFont( LogIn, 4 );
i think the first is file name and second the the textdraw and i think there are 1 in each file not sure
and i think u should add
pawn Код:
new str[64];
format(str,sizeof(str), "loadsc%d:loadsc1" ,random(10)+1); //Not sure if there was 10 load screens
TextDrawSetString(LogIn,str);
onplayerconnect for random for each player