PDA

View Full Version : Meaning 2



Mariusz
11th March 2018, 21:13
What does this i < 15 mean?

randombox(weap)
{
weap hide();
o = weap.origin;
cost = 800;

// init set of weapons in this randombox
self.weapons = [];
self.weaponsModel = [];

for(i = 0; i < 15; i++) {
for(i = 0; i < 10; i++) {
for(i = 0; i < 3; i++) {
for(i = 0; i < 2; i++) {
for(i = 0; i < 1; i++) {

voron00
11th March 2018, 21:27
https://msdn.microsoft.com/library/b80153d8.aspx

maxdamage99
12th March 2018, 14:29
i < 15
second argument operator "for" (after first ";") - it condition. Untill condition true (i<15): cycle work

Mariusz
12th March 2018, 15:25
i<15 - 10 items
i<10 - 4 items
i<3 - 8 items
i<2 - 5 items
i<1 - 4 items

What does it mean technically?

Lonsofore
13th March 2018, 01:19
for(i = 0; i < 15; i++) {
for(i = 0; i < 10; i++) {
for(i = 0; i < 3; i++) {
for(i = 0; i < 2; i++) {
for(i = 0; i < 1; i++) {

like this part

Mariusz
13th March 2018, 10:38
I think my script have an error in it originally. It's about weapon like I said before.
The first case is that I don't receive a proper weapon model from the randombox. I have a suspicion to ak74, cause this weapon appears most often.
And the second case; I don't receive a weapon at all but the text something like "Now you have (this) weapon". My hands are empty of this chosed model of weapon.

maxdamage99
13th March 2018, 13:42
probability = true / total || ak47 / 100 weapons (on server) = 1 / 100 = 0,01 = 1% chance for ak47
example random box for 10 weapons:



rand_int = randomint(1000);

if (rand_int <= 100) //10%
giveWeapon(/* your weapon */);
else
if (rand_int <= 200) //10%
giveWeapon(/* your weapon */);
else
if (rand_int <= 300) //10%
giveWeapon(/* your weapon */);
else
if (rand_int <= 700) //40%
giveWeapon(/* your weapon */);

/* etc. */



P.S: cod2 have pseudorandom algorithm :(