random weaps - 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 weaps (
/showthread.php?tid=661824)
random weaps -
nbx2000 - 16.12.2018
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])
Re: random weaps -
nbx2000 - 16.12.2018
help
Re: random weaps -
Kaliber - 17.12.2018
This code seems completly correct.
Get it called?
Maybe print it or look in crashdetect if there are some errors
Re: random weaps -
nbx2000 - 17.12.2018
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(...);
}
}
Re: random weaps -
Kaliber - 17.12.2018
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));
r = random(sizeof(wepsid));
while(r == last[0]) r = random(sizeof(wepsid));
last[1] = r;
r = random(sizeof(wepsid));
while(r == last[0] || r == last[1]) r = random(sizeof(wepsid));
last[2] = r;
for(new i,idx; i<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
Re: random weaps -
Threshold - 18.12.2018
I suggest you look into iterators. y_iterate is a good option.
https://sampforum.blast.hk/showthread.php?tid=571159