Forum Jump :

Author Message


Posts: 23
Rank:


Level: Member

Country: us
Location: Charleston, SC
Occupation:
Age: 37
In-game name:

 
#145843 Posted at 2013-06-21 04:53        
     
Bomber.SQF
if(isServer) then {
_bomberGroup = [civ,civ_1,civ_2,civ_3,civ_4,civ_5,civ_6,civ_7,civ_8,civ_9];
_playerBomberGroup = [];
_bombHint = "You have the bomb";

waitUntil {(getPlayerUID player) != ""};

for "_i" from 0 to 10 step 1 do {if ( _bomberGroup select _i == player) then {     
_bombuild = _bomberGroup select _i;
_playerBomberGroup set [_i, _bombuild];};

diag_log text format ["ReturnedCounter: %1", _i];		//print the where the counter is at to rpt
diag_log text format ["ReturnedUnitAdded: %1", _bombuild];	//print the units that were added to rpt
};

_rnd =  floor (random( count (_playerBomberGroup)));

_bomber = _playerBomberGroup select _rnd;

diag_log text format ["ReturnedRandomInt: %1", _rnd]; //print the generated random number to rpt
diag_log text format ["ReturnedBomber: %1", _bomber]; //print the generated bomber unit to rpt

_bomber addBackpack "B_AssaultPack_khk";
_bomber addMagazine  "DemoCharge_Remote_Mag";

if (_bomber == player) then {
 hint _bombHint;
};
};

RPT file
ReturnedCounter: 0
ReturnedUnitAdded: any
Error in expression <g text format ["ReturnedUnitAdded: %1", _bombuild];
};

_rnd =  floor (random( c>
  Error position: <_bombuild];
};

_rnd =  floor (random( c>
  Error Undefined variable in expression: _bombuild
File mpmissions\RandomBombingV0%2e11.Stratis\SuicideBomber.sqf, line 14
ReturnedCounter: 1
ReturnedUnitAdded: any
Error in expression <g text format ["ReturnedUnitAdded: %1", _bombuild];
};

_rnd =  floor (random( c>
  Error position: <_bombuild];
};

_rnd =  floor (random( c>
  Error Undefined variable in expression: _bombuild
File mpmissions\RandomBombingV0%2e11.Stratis\SuicideBomber.sqf, line 14
ReturnedCounter: 2
ReturnedUnitAdded: any
Error in expression <g text format ["ReturnedUnitAdded: %1", _bombuild];
};

_rnd =  floor (random( c>
  Error position: <_bombuild];
};

_rnd =  floor (random( c>
  Error Undefined variable in expression: _bombuild
File mpmissions\RandomBombingV0%2e11.Stratis\SuicideBomber.sqf, line 14
ReturnedCounter: 3
ReturnedUnitAdded: any
Error in expression <g text format ["ReturnedUnitAdded: %1", _bombuild];
};

_rnd =  floor (random( c>
  Error position: <_bombuild];
};

_rnd =  floor (random( c>
  Error Undefined variable in expression: _bombuild
File mpmissions\RandomBombingV0%2e11.Stratis\SuicideBomber.sqf, line 14
ReturnedCounter: 4
ReturnedUnitAdded: any
Error in expression <g text format ["ReturnedUnitAdded: %1", _bombuild];
};

_rnd =  floor (random( c>
  Error position: <_bombuild];
};

_rnd =  floor (random( c>
  Error Undefined variable in expression: _bombuild
File mpmissions\RandomBombingV0%2e11.Stratis\SuicideBomber.sqf, line 14
ReturnedCounter: 5
ReturnedUnitAdded: any
Error in expression <g text format ["ReturnedUnitAdded: %1", _bombuild];
};

_rnd =  floor (random( c>
  Error position: <_bombuild];
};

_rnd =  floor (random( c>
  Error Undefined variable in expression: _bombuild
File mpmissions\RandomBombingV0%2e11.Stratis\SuicideBomber.sqf, line 14
ReturnedCounter: 6
ReturnedUnitAdded: any
Error in expression <g text format ["ReturnedUnitAdded: %1", _bombuild];
};

_rnd =  floor (random( c>
  Error position: <_bombuild];
};

_rnd =  floor (random( c>
  Error Undefined variable in expression: _bombuild
File mpmissions\RandomBombingV0%2e11.Stratis\SuicideBomber.sqf, line 14
ReturnedCounter: 7
ReturnedUnitAdded: any
Error in expression <g text format ["ReturnedUnitAdded: %1", _bombuild];
};

_rnd =  floor (random( c>
  Error position: <_bombuild];
};

_rnd =  floor (random( c>
  Error Undefined variable in expression: _bombuild
File mpmissions\RandomBombingV0%2e11.Stratis\SuicideBomber.sqf, line 14
ReturnedCounter: 8
ReturnedUnitAdded: any
Error in expression <g text format ["ReturnedUnitAdded: %1", _bombuild];
};

_rnd =  floor (random( c>
  Error position: <_bombuild];
};

_rnd =  floor (random( c>
  Error Undefined variable in expression: _bombuild
File mpmissions\RandomBombingV0%2e11.Stratis\SuicideBomber.sqf, line 14
ReturnedCounter: 9
ReturnedUnitAdded: any
Error in expression <g text format ["ReturnedUnitAdded: %1", _bombuild];
};

_rnd =  floor (random( c>
  Error position: <_bombuild];
};

_rnd =  floor (random( c>
  Error Undefined variable in expression: _bombuild
File mpmissions\RandomBombingV0%2e11.Stratis\SuicideBomber.sqf, line 14
ReturnedCounter: 10
ReturnedUnitAdded: any
Error in expression <g text format ["ReturnedUnitAdded: %1", _bombuild];
};

_rnd =  floor (random( c>
  Error position: <_bombuild];
};

_rnd =  floor (random( c>
  Error Undefined variable in expression: _bombuild
File mpmissions\RandomBombingV0%2e11.Stratis\SuicideBomber.sqf, line 14
ReturnedRandomInt: 0
ReturnedBomber: <null>
Error in expression <_log text format ["ReturnedBomber: %1", _bomber];

_bomber addBackpack "B_Assaul>
  Error position: <_bomber];

_bomber addBackpack "B_Assaul>
  Error Undefined variable in expression: _bomber
File mpmissions\RandomBombingV0%2e11.Stratis\SuicideBomber.sqf, line 22

I don't understand what i'm doing wrong at this point


I found a major mistake i made...
if you noticed I added unit to the array and assigned its index _playerBomberGroup set [_i, _bombuild];};
then when picking the random unit from that array based on the size of the array
so if only 1 unit was added to the array but it was on the 3rd loop because i was starting mission in a couple slots down to see if i could see if the error was created by the player or the start of the loop
the _rnd would only be index of 0, while i was added in the array at index 2
which is why _bomber was null

This post was edited by pAXton (2013-06-21 05:08, ago)