Jump to content
Sign in to follow this  
node

if (100 > random 100 then

Recommended Posts

Hello, Trying to make a script that would make it to where you run around and you randomly find a IL(islandlifeitem) item. This is what I have tried so far.

if (100 > random 100 then ['Donut',2] call INV_AddInventoryItem

if (!isServer) exitWith {};

if (100 > random 100 then {
if (random 2 = 1) then {['Donut',2] call INV_AddInventoryItem}
else {exitWith {}};
};

Any ideas how I would do this?

Share this post


Link to post
Share on other sites

if (100 > random 100[color=RED][b])[/b][/color] then [color=RED][b]{[/b][/color]['Donut',2] call INV_AddInventoryItem[color=RED][b]}[/b][/color]

Also, the 100 > effectively means 100% chance, so it's not really random in the given code (but of course works for testing if the code works at all).

Share this post


Link to post
Share on other sites

is there any way to make it to where it adds a item to your inventory randomly. Or did i do this script wrong/another way to do this script.

_player = _this select 0;

if (!isServer) exitWith {};

if ((100 > random 100 then {

if (floor random 100 = 0) then //Item goes here

else {exitWith {}};

};

Share this post


Link to post
Share on other sites

Well, your condition returns always true.

Randomly upon joining or just randomly when playing?

if (!isDedicated) then {
_number = random 100;
if (_number > 85) then {
 player addWeapon "DMR";
 player addMagazine... and so on
 };
};

Share this post


Link to post
Share on other sites

would I still include

_player = _this select 0;

Share this post


Link to post
Share on other sites

Depends how you launch the script. If it runs on the client you can just use player.

Share this post


Link to post
Share on other sites

Viba I want it to whenever I am playing such as walking around.

Share this post


Link to post
Share on other sites
if (!isDedicated) then {
while {true} do {
	waitUntil {sleep 5; (alive player) && (isNull (finddisplay 49))}; // || any other things needed to take into account, respawn dialog and so on?
	_number = random 100; 
	if (_number > 85) then {
		player addWeapon "DMR"; 
		//player addMagazine... and so on 
	};
	//If you loop at fullspeed you'd get DMR's all the time, just modify the random chance and the sleep time so it's balanced.
	sleep 60;
};  
};

Share this post


Link to post
Share on other sites

if (!isDedicated) then {
while {true} do {
	waitUntil {sleep 1; (alive player) && (isNull (finddisplay 49))};
	_number = random 100; 
	if (_number > 100) then {
		player addWeapon "DMR"; 
		player addMagazine "20Rnd_762x51_DMR";
	};
	sleep 60;
};  
};

this is what im doing and it is not working

Share this post


Link to post
Share on other sites

random 100 and check if the number is over 100? Logical error, you have to lower the number you are checking for.

Share this post


Link to post
Share on other sites

doesnt seem to be working i put the script into my mission and try it but it is not working

Share this post


Link to post
Share on other sites

if its not necessary but then you don't have to but if you can add me on skype @ dylanhood999 so u can help me some more

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×