random weaps
#1

It is possible or change the code of a random weapon to the player that enters minigames it is possible that the kit of 4 random weapons to the player thus does not give one

new wepsid[5][2] =
{
{28,100}, //
{22,200}, //
{31,300}, //
{42,400}, //
{26,500} //
};



new rando = random(sizeof(wepsid)); // making a random function.
GivePlayerWeapon(playerid,wepsid[rando][0],wepsid[rando][1])
Reply
#2

help
Reply
#3

This code seems completly correct.

Get it called?

Maybe print it or look in crashdetect if there are some errors
Reply
#4

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
This code seems completly correct.

Get it called?

Maybe print it or look in crashdetect if there are some errors
What I want to say is if it can be modified so that 3 weapons do not 1 weaps

Will this code be adapted to mine?

switch( random( 4 ) )
{
case 0: //random was 0.. give them a set of weapons
{
GivePlayerWeapon(...);
GivePlayerWeapon(...);
GivePlayerWeapon(...);
}
case 1: //random was 1 so give them a different set of weapons
{
GivePlayerWeapon(...);
GivePlayerWeapon(...);
GivePlayerWeapon(...);
}
case 2: //random was 2 so give them a different set of weapons
{
GivePlayerWeapon(...);
GivePlayerWeapon(...);
GivePlayerWeapon(...);
}
case 3: //random was 3 so give them a different set of weapons (You get the idea)
{
GivePlayerWeapon(...);
GivePlayerWeapon(...);
GivePlayerWeapon(...);
}
}
Reply
#5

Ah, now i get it:

PHP код:
stock const wepsid[][] =
{
{
28,100}, // 
{22,200}, // 
{31,300}, // 
{42,400}, // 
{26,500// 
};
new 
last[] = {-1,-1,-1},r;
last[0] = random(sizeof(wepsid));
random(sizeof(wepsid));
while(
== last[0]) random(sizeof(wepsid));
last[1] = r;
random(sizeof(wepsid));
while(
== last[0] || == last[1]) random(sizeof(wepsid));
last[2] = r;
    
for(new 
i,idxi<sizeof(last); i++)
{
    
idx last[i];
    
GivePlayerWeapon(playerid,wepsid[idx][0],wepsid[idx][1]);

This would generate 3 random numbers, and it is save, that not one number is like the other
Reply
#6

I suggest you look into iterators. y_iterate is a good option.

https://sampforum.blast.hk/showthread.php?tid=571159
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)