Jump to content
Sign in to follow this  
luckyhendrix

Loops performance hit

Recommended Posts

I made a little script so that only the player that have radio have acces to radio message. here is it :

_unit = _this select 0;

_TypeofRuck = _this select 1;

_init1 = "1 setradioMsg ""Null""";

_init1 = "1 setradioMsg ""Call Extract""";

waituntil {!isnil "bis_fnc_init"};

_unit setvehicleinit _init1;

processInitCommands;

While{true}do{

_Ruck = _Unit Call ACE_Sys_Ruck_fnc_hasRuck;

While{!_Ruck}do{

_Ruck = _Unit Call ACE_Sys_Ruck_fnc_hasRuck;

sleep 0.1;

};

_inv = [_Unit] call Bis_fnc_invString;

While{_ruck}do{

_Ruck = _Unit Call ACE_Sys_Ruck_fnc_hasRuck;

_inv = [_Unit] call Bis_fnc_invString;

If(_TypeofRuck in _inv)Then{

//hint "You have a Radio";

_Unit setVehicleInit _init2;

processInitCommands;

}Else{

//hint "you don't have a radio";

_unit setvehicleinit _init1;

processInitCommands;

};

sleep 5;

};

};

This script seems to have a big impact on perf, how can I reduce this ?

Share this post


Link to post
Share on other sites

what is Bis_fnc_invString ?

---------- Post added at 01:44 ---------- Previous post was at 01:44 ----------

returns inventory of an object??

---------- Post added at 01:45 ---------- Previous post was at 01:44 ----------

where did you find this function and where can I see other BIS_*** functions?

---------- Post added at 01:47 ---------- Previous post was at 01:45 ----------

OMG !

http://community.bistudio.com/wiki/Image:Fnc_help.jpg

I need to look at this!

Share this post


Link to post
Share on other sites

Bis_fnc_invstring , returns an array with all the classname of all objects in the inventory.

put module fonction then write this in the activation fiels of a radio triggers : player call Bis_fnc_help.

Share this post


Link to post
Share on other sites

why do you have two "_init1" ?

---------- Post added at 02:12 ---------- Previous post was at 02:06 ----------

I think all these complicated constructions are the consequence of BIS's laziness - they haven't made functions to get inventory from vehicles, no events like "onUse" and "onUsed" for actions added by addAction, and so on....

personnaly for me, while {true} is a bad manner in programming... but all this is caused by...... I have written above ))

Share this post


Link to post
Share on other sites

How's this lagwise?

_u = _this select 0;
_t = _this select 1;
waituntil {!isnil "bis_fnc_init"};
while {true} do {
 waituntil {!(_u call ACE_Sys_Ruck_fnc_hasRuck)};
 _u setvehicleinit "1 setradioMsg ""Null""";
 processInitCommands;
 waituntil {_u call ACE_Sys_Ruck_fnc_hasRuck};
 waituntil {_t in ([_u] call Bis_fnc_invString)};
 _u setvehicleinit "1 setradioMsg ""Call Extract""";
 processInitCommands;
};

Share this post


Link to post
Share on other sites
what is Bis_fnc_invString ?

---------- Post added at 01:44 ---------- Previous post was at 01:44 ----------

returns inventory of an object??

---------- Post added at 01:45 ---------- Previous post was at 01:44 ----------

where did you find this function and where can I see other BIS_*** functions?

---------- Post added at 01:47 ---------- Previous post was at 01:45 ----------

OMG !

http://community.bistudio.com/wiki/Image:Fnc_help.jpg

I need to look at this!

:(

Bis_fnc_invString

Note: for vehicles it returns mounted gun and its ammo, not cargo weapons and ammo.

@shk: Forgot the sleep?

Share this post


Link to post
Share on other sites

To check if a player has an ACE radio, something like this is easier and doesn't hurt performance:

while {true} do {
   waitUntil {alive player};
   waitUntil {sleep 0.312; isNumber(configFile >> "CfgWeapons" >> secondaryWeapon player >> "ACE_is_radio")};
   // add whatever you want to the unit
   while {isNumber(configFile >> "CfgWeapons" >> secondaryWeapon player >> "ACE_is_radio")} do {
        // do whatever you want 
   };
};

isNumber(configFile >> "CfgWeapons" >> secondaryWeapon player >> "ACE_is_radio")

gets the correct information.

Xeno

Share this post


Link to post
Share on other sites
@shk: Forgot the sleep?

Nope. It's always stopped at a waituntil.

Share this post


Link to post
Share on other sites
To check if a player has an ACE radio, something like this is easier and doesn't hurt performance:

while {true} do {
   waitUntil {alive player};
   waitUntil {sleep 0.312; isNumber(configFile >> "CfgWeapons" >> secondaryWeapon player >> "ACE_is_radio")};
   // add whatever you want to the unit
   while {isNumber(configFile >> "CfgWeapons" >> secondaryWeapon player >> "ACE_is_radio")} do {
        // do whatever you want 
   };
};

isNumber(configFile >> "CfgWeapons" >> secondaryWeapon player >> "ACE_is_radio")

gets the correct information.

Xeno

Thank you Xeno. You're a master ;)

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  

×