Help me again -.-
#1

So i need to know how to aboid scripting like this:
Код:
	if(strcmp("/destroycity", cmdtext, true) == 0)
	{
	    new Random = random(402);
	    CreateExplosion(USAair[Random][0], USAair[Random][1], USAair[Random][2], 6, 10.0);
	    new Random2 = random(402);
	    CreateExplosion(USAair[Random2][0], USAair[Random2][1], USAair[Random2][2], 6, 10.0);
	}
Isn't there anyway to use, hmm.... "Random++;" or something? it would take hundreds lines to create all those random explosions over city.
Reply
#2

No, this is the only way, just make it next to each other.
It will look noobish but has less lines
Reply
#3

So i have create hundreds of randoms?!
Reply
#4

You do do it with a loop:

pawn Код:
new Random = random(402);
for(new i = 0; i < MAX_EXPLOSIONS; i ++)
{
    CreateExplosion(USAair[Random][0], USAair[Random][1], USAair[Random][2], 6, 10.0);
    Random = random(402);
}
This will create as much explosions as you want
Reply
#5

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
You do do it with a loop:

pawn Код:
new Random = random(402);
for(new i = 0; i < MAX_EXPLOSIONS; i ++)
{
    CreateExplosion(USAair[Random][0], USAair[Random][1], USAair[Random][2], 6, 10.0);
    Random = random(402);
}
This will create as much explosions as you want
So
Код:
new Random = random(402);
for(new i = 0; i < MAX_EXPLOSIONS; i ++)
{ 
    CreateExplosion(USAair[Random][0], USAair[Random][1], USAair[Random][2], 6, 10.0);
CreateExplosion(USAair[Random][0], USAair[Random][1], USAair[Random][2], 6, 10.0);
CreateExplosion(USAair[Random][0], USAair[Random][1], USAair[Random][2], 6, 10.0);
CreateExplosion(USAair[Random][0], USAair[Random][1], USAair[Random][2], 6, 10.0);
CreateExplosion(USAair[Random][0], USAair[Random][1], USAair[Random][2], 6, 10.0);
CreateExplosion(USAair[Random][0], USAair[Random][1], USAair[Random][2], 6, 10.0);
    Random = random(402);
}
Yea?
Reply
#6

One CreateExplosion is enuogh, the loop creates a random value, and then creates the explosion at the pos for that value, so multiple CreateExplosions would just create multiple explosions on the same position.
The number of explosions is just definined through MAX_EXPLOSIONS (put here whatever you want) because this sets the maximum number of runs of the loop.
Reply
#7

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)