And can i add more weapons for example the sniper i could add severel snipers so its random?
Yeah, where it says _sniperRifle or whatever, do this:
_rndSniperRifle = floor(random 2);
switch (_rndSniper) do {
case 0: {_sniperRifle = "gun1");
case 1:{_sniperRifle = "gun2"};
case 2:{_sniperRifle = "gun3"};
};
I don't know off the top of my head if a random 3 will return 1 2 and 3 or of it will return 0 1 2 3 or 0 1 2, so you might test by doing a: diag_log format ["Sniper Rifle %1 selected",_rndSniper]; so that you can see what the results of the random are. If you can't get it figured out, I will jump to my code and figure it out, but you should be able to get there with this code.
I THINK if you do floor(random 3) it will return 0 1 2 3. So you would need 4 weapons in that case. For 3 weapons do a random 2.
If you want to do a weighted system, you can do random 100, and instead of a case do:
if (_rndSniperRifle <=50} then {
_sniperRifle = "gun1";
} else {
if (_rndSniperRifle <=75) then {
_sniperRifle = "gun 2";
} else {
if (_rndSniperRifle <=90) then {
_sniperRifle = "gun 3";
} else {
_sniperRifle = "gun 4";
};
};
};
If you follow that, gun 1 has 50% chance to spawn, gun 2 has 25% chance, gun 3 has 15% chance, and gun 4 has 10% chance. I don't know how realistic those chances are, but in a perfect world where random is truly random, then that would be the case.