SA-MP Forums Archive
Script Question - 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: Script Question (/showthread.php?tid=413794)



Script Question - Blackazur - 06.02.2013

Код:
            	new zskin = random(3);
 	            switch(zskin) {
  	        	case 0:SetPlayerSkin(playerid,230);
            	case 1:SetPlayerSkin(playerid,162);
            	case 2:SetPlayerSkin(playerid,137);
            	case 3:SetPlayerSkin(playerid,212);
            	case 4:SetPlayerSkin(playerid,135);
            	case 5:SetPlayerSkin(playerid,200);
     	        case 6:SetPlayerSkin(playerid,79);
     	        case 7:SetPlayerSkin(playerid,134);
	}
    }
Hello i have an Question, what causes the random(3); ?


Re: Script Question - Grimrandomer - 06.02.2013

random(3); will return a number between 0 and 2 (0,1,2)
random(n); will return a number between 0 and n-1 (0,1,......(n-1))

In your case, you want random( 8 ); so you get 0 to 7 for your switch.


AW: Script Question - Blackazur - 06.02.2013

Also i need for that an random(8); ?


Re: AW: Script Question - Jeffry - 06.02.2013

Quote:
Originally Posted by Blackazur
Посмотреть сообщение
Also i need for that an random(; ?
Yup. Else you will never get the cases 3-7.