SA-MP Forums Archive
Random number. - 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 number. (/showthread.php?tid=663497)



Random number. - Longover - 02.02.2019

It's ok to create a random item between 1276,1550,1210 and 1247?

Код:
new RandomT = random(4);
	switch(RandomT)
	{
		case 0:
		{
		    return 1276;
		}
		case 1:
		{
		    return 1550;
		}
		case 2:
		{
		    return 1210;
		}
		case 3:
		{
		    return 2710;
		}
		case 4:
		{
		    return 1247;
		}
	}
	ObiectTreasure = CreatePickup(RandomT, 21, gRandomPositions[rand][0], gRandomPositions[rand][1], gRandomPositions[rand][2]);



Re: Random number. - Lokii - 02.02.2019

You could do like this:
PHP код:

static const randobj[] =
{
    
12761550121012701247
};
ObiectTreasure CreateObject(random(sizeof(randobj)), //rest code 



Re: Random number. - Longover - 02.02.2019

Quote:
Originally Posted by Lokii
Посмотреть сообщение
You could do like this:
PHP код:

[CODE]static const randobj[] =
{
    
12761550121012701247
}; //<< ------- HERE IS 15062 
ObiectTreasure CreateObject(random(sizeof(randobj)), // <<--- HERE IS 15064
[/CODE
Код:
C:\Program Files (x86)\Server_Samp\Gamemode-uri\Pear\gamemodes\Pear.pwn(15064) : warning 202: number of arguments does not match definition
C:\Program Files (x86)\Server_Samp\Gamemode-uri\Pear\gamemodes\Pear.pwn(15064) : warning 202: number of arguments does not match definition
C:\Program Files (x86)\Server_Samp\Gamemode-uri\Pear\gamemodes\Pear.pwn(15064) : warning 202: number of arguments does not match definition
C:\Program Files (x86)\Server_Samp\Gamemode-uri\Pear\gamemodes\Pear.pwn(15064) : warning 202: number of arguments does not match definition
C:\Program Files (x86)\Server_Samp\Gamemode-uri\Pear\gamemodes\Pear.pwn(15064) : error 001: expected token: ",", but found ";"
C:\Program Files (x86)\Server_Samp\Gamemode-uri\Pear\gamemodes\Pear.pwn(15062) : warning 203: symbol is never used: "RandomT"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Not work


Re: Random number. - Lokii - 02.02.2019

PHP код:
ObiectTreasure CreatePickup(random(sizeof(randobj)), 21gRandomPositions[rand][0], gRandomPositions[rand][1], gRandomPositions[rand][2]); 



Re: Random number. - Longover - 02.02.2019

Quote:
Originally Posted by Lokii
Посмотреть сообщение
PHP код:
ObiectTreasure CreatePickup(random(sizeof(randobj)), 21gRandomPositions[rand][0], gRandomPositions[rand][1], gRandomPositions[rand][2]); 
symbol is never used "RandomT"

Код:
static const RandomT[] =
	{
    	1276, 1550, 1210, 1270, 1247
	};

	ObiectTreasure = CreatePickup(random(sizeof(RandomT)), 21, gRandomPositions[rand][0], gRandomPositions[rand][1], gRandomPositions[rand][2]);



Re: Random number. - Lokii - 02.02.2019

ohh sorry my bad

PHP код:
ObiectTreasure CreatePickup(RandomT[random(sizeof(RandomT))], 21gRandomPositions[rand][0], gRandomPositions[rand][1], gRandomPositions[rand][2]); 



Re: Random number. - Longover - 02.02.2019

Quote:
Originally Posted by Lokii
Посмотреть сообщение
ohh sorry my bad

PHP код:
ObiectTreasure CreatePickup(RandomT[random(sizeof(RandomT))], 21gRandomPositions[rand][0], gRandomPositions[rand][1], gRandomPositions[rand][2]); 
Thanks! +1