Jump to content
  • 0

typeOF player !=


TolH

Question

Hello,

i have been trying to give different loadout depending on what typeOF player you select at the server slot selection.

Everything works just fine if i select a normal "VirtualMan_EPOCH" slot. It's when i select "B_sniper_F" or "B_Helipilot_F" that the script is skipping part.

I don't get any error on my .rpt but it seems that the script is skipping a couple of line before ending.

So if i select for exemple (typeOf player != "B_sniper_F"), then it will go trough the code but will be skipping those lines:

    player setpos _pos1;
    player enableFatigue false;
    waitUntil{!isNull (findDisplay 46) && !dialog && cameraOn isEqualTo player && cameraView == "INTERNAL"};
    player switchCamera "EXTERNAL";
    HALV_takegive = [player,150];
    publicVariableServer "HALV_takegive";

Then the script will continue to the next part that is the "check" to see if player is either Epoch, sniper or pilot.

It's as if the script is executed before the player as spanwed on the map and don't have time to execute the first couple of line. Any help would be really appreciated to know why some of the line are skipped but not others.

This is the script i made:

Line to check are:

# //waitUntil {typeOF player != "VirtualMan_EPOCH" or typeOf player != "B_sniper_F" or typeOf player != "B_Helipilot_F"};

This is the part that is skipped on script execution:

#   player setpos _pos1;
    player enableFatigue false;
    waitUntil{!isNull (findDisplay 46) && !dialog && cameraOn isEqualTo player && cameraView == "INTERNAL"};
    player switchCamera "EXTERNAL";
    HALV_takegive = [player,150];
    publicVariableServer "HALV_takegive";

private ["_adminlist"];
//-
waitUntil {alive vehicle player}; 
//waitUntil {typeOF player != "VirtualMan_EPOCH" or typeOf player != "B_sniper_F" or typeOf player != "B_Helipilot_F"};
waitUntil {typeOF player != "VirtualMan_EPOCH"};
//-
_pos1 = [14636.907, 16770.1, 0.00143814];
//_adminlist = ["xx","xx","xx","xx","xx","xx"];

//--------------------------------------------------------------------//
if ((EPOCH_playerAliveTime < 0.1) && (EPOCH_playerCrypto < 1)) then 
{
	//spawning_script = [] execVM "custom\spawn.sqf";
	//waitUntil {scriptDone spawning_script};
	player setpos _pos1;
	player enableFatigue false;
	waitUntil{!isNull (findDisplay 46) && !dialog && cameraOn isEqualTo player && cameraView == "INTERNAL"};
	player switchCamera "EXTERNAL";
	HALV_takegive = [player,150];
	publicVariableServer "HALV_takegive";
	/*	if (typeOf player == "VirtualMan_EPOCH") then 
		{
			systemchat "YOU ARE A NORMAL EPOCH PLAYER, TEST!";
		};
		if (typeOf player == "B_sniper_F") then 
		{
			systemchat "YOU ARE A SNIPER, TEST!";
		};
		if (typeOf player == "B_Helipilot_F") then 
		{
			systemchat "YOU ARE A PILOT, TEST!";
		};*/
/*	//For Admin ASORGS Gear Selector
	if ((getPlayerUID player) in _adminlist) then 
	{ 
		systemchat " -=ADMIN=- Detected: -Gear selector loaded. Type !gear to access it.-";
		//player addAction ["<t color='#6a8a19'>Gear Selector</t>", "ASORGS\open.sqf", "", 0, true, true, "", ""];
	};*/
}
else
{
	systemchat "Welcome back!";
	player enableFatigue false;
	waitUntil{!isNull (findDisplay 46) && !dialog && cameraOn isEqualTo player && cameraView == "INTERNAL"};
	player switchCamera "EXTERNAL";
	/*	if (typeOf player == "VirtualMan_EPOCH") then 
		{
			systemchat "YOU ARE A NORMAL EPOCH PLAYER, TEST!";
		};
		if (typeOf player == "B_sniper_F") then 
		{
			systemchat "YOU ARE A SNIPER, TEST!";
		};
		if (typeOf player == "B_Helipilot_F") then 
		{
			systemchat "YOU ARE A PILOT, TEST!";
		};*/
/*	//For Admin ASORGS Gear Selector
	if ((getPlayerUID player) in _adminlist) then 
	{ 
		systemchat " -=ADMIN=- Detected: -Gear selector loaded. Type !gear to access it.-";
		//player addAction ["<t color='#6a8a19'>Gear Selector</t>", "ASORGS\open.sqf", "", 0, true, true, "", ""];
	};*/
};
//--------------------------------------------------------------------//
Edited by TolH
Link to comment
Share on other sites

Recommended Posts

  • 0

I've never tried coding for A3 before, but can you not do something like:

so instead of listing each one as a separate typeOf player !=, it looks at the group of them

waitUntil {typeOF player != ["VirtualMan_EPOCH","B_sniper_F","B_Helipilot_F"]};

As said, I've never coded for epoch/A3 before only for other work related bits, so something like that might not work.

Link to comment
Share on other sites

  • 0

I've never tried coding for A3 before, but can you not do something like:

so instead of listing each one as a separate typeOf player !=, it looks at the group of them

waitUntil {typeOF player != ["VirtualMan_EPOCH","B_sniper_F","B_Helipilot_F"]};

As said, I've never coded for epoch/A3 before only for other work related bits, so something like that might not work.

That way, the script won't execute at all because it will wait until the 3 condition are mets. The way it is now, it will wait until one of the 3 conditions are mets, but thank you :)

Link to comment
Share on other sites

  • 0
waitUntil { uiSleep 0.5; ((typeOf player isEqualTo "VirtualMan_EPOCH") OR (typeOf player isEqualTo "B_sniper_F") OR (typeOf player isEqualTo "B_Helipilot_F")) };

Thank me later.

Thank you for taking the time, but it still didn't quite did it. Nothing was happening that way until i added:

 

waitUntil { uiSleep 0.5; ((typeOf player != "VirtualMan_EPOCH") OR (typeOf player != "B_sniper_F") OR (typeOf player != "B_Helipilot_F")) };

Then it went trhu with the text to detect B_sniper_F and B_Helipilot_F but did not went trhu the player setpos and the other things. I am not sure about it but i think it's something server side on player respawn that reset the typeOf player To epoch man/female skin.

Went with player side detection instead, thank you.

Edited by TolH
Link to comment
Share on other sites

  • 0

Thank you for taking the time, but it still didn't quite did it. Nothing was happening that way until i added:

 

waitUntil { uiSleep 0.5; ((typeOf player != "VirtualMan_EPOCH") OR (typeOf player != "B_sniper_F") OR (typeOf player != "B_Helipilot_F")) };

Then it went trhu with the text to detect B_sniper_F and B_Helipilot_F but did not went trhu the player setpos and the other things. I am not sure about it but i think it's something server side on player respawn that reset the typeOf player To epoch man/female skin.

Went with player side detection instead, thank you.

what exactly are you trying to achive here? ...i really dont get the point here

I've never tried coding for A3 before, but can you not do something like:

so instead of listing each one as a separate typeOf player !=, it looks at the group of them

waitUntil {typeOF player != ["VirtualMan_EPOCH","B_sniper_F","B_Helipilot_F"]};

As said, I've never coded for epoch/A3 before only for other work related bits, so something like that might not work.

you cannot compare a string to an array, if you want to check if the string is in the array, you should do something like this:

waitUntil {!(typeOF player in ["VirtualMan_EPOCH","B_sniper_F","B_Helipilot_F"])};
waitUntil { uiSleep 0.5; ((typeOf player isEqualTo "VirtualMan_EPOCH") OR (typeOf player isEqualTo "B_sniper_F") OR (typeOf player isEqualTo "B_Helipilot_F")) };

Thank me later.

isEqualTo is nice when comparing objects or arrays, unfortunatly it is slower than == when comparing strings ... == is always faster in this case.

Link to comment
Share on other sites

  • 0
@Halvhjearne
do you have proof of your claim? According to my tests, it does not make a bloody difference and is just another "this is faster" myth.

you can do performance tests in the debug console, you can tast yourself if you do not take my word for it.

_arr = [];
if(typeName _arr == "ARRAY")then{
	hintSilent "true";
};

vs.

_arr = [];
if(typeName _arr isEqualTo "ARRAY")then{
	hintSilent "true";
};

i assumed the same as you, but unfortunatly from any test i have made so far, it is always faster to use == for strings.

Edited by Halvhjearne
Link to comment
Share on other sites

  • 0

I have ran tests with for "_i" from 0 to 1000 do.
isEqualTo is much faster than == on that count. On lower counts, very small differences where isEqualTo is slightly faster.

idk how you managed that, i would love to see the results from it tho ...

edit:

 also there is no reason to run the code 1001 times to test, it is already evaluated 10000 times with the performance test to get an average.

9567DF4501CCD5616C9585ADDA703902F5FDCA10

22AD6BBBDC169311F735D4E22B568D12238C6FD1

as i said, the diffrence is only with strings from what i have tested so far.

Edited by Halvhjearne
Link to comment
Share on other sites

  • 0

Do not forget that it is not only the engine that determines how fast commands are. It also depends on your PC hardware.

lol, the time it takes might be diffrent with lesser hardware yes, but == is faster when comparing strings no matter what the pc specs are.

it dosnt matter if there are diffrence in the hardware when the test and end result is the same ...

i would love for you to show me otherwise tho.

Link to comment
Share on other sites

  • 0

This is going way to far for me to really carry on about this speed thing. I did not want to start all of this yes no thing. I like isEqualTo and I will keep using it even if it is 0.00004ms slower or faster. I just do not care about it that much to start an argument about it.

Link to comment
Share on other sites

  • 0

This is going way to far for me to really carry on about this speed thing. I did not want to start all of this yes no thing. I like isEqualTo and I will keep using it even if it is 0.00004ms slower or faster. I just do not care about it that much to start an argument about it.

the stubbornness is strong in this one ...

unfortunatly i still have yet to see any arguments or proof to proove your claims.

however i love how you asked me to prove my claim and now that i proved it, you still do not belive it however you now refuse to discuss it, lol.

also it is more like 0,0002 not 0,00004ms (wich is quite a diffrence) ... granted that 0,0002ms is still not a lot, but when done enough times it will add up eventually and do make quite a diffrence in some cases.

besides that i never dictated how you should write code, that is completly up to you ... however i do sometimes give pointers as to how code can be improved.

Link to comment
Share on other sites

  • 0

Oh almost forgot: https://youtu.be/7mi-3OLloes
 

EDIT: and btw, you are so low for posting those disrespectful pictures trying to prove your point. It is really condescending and childish of you. And all of that from someone that said that I need to grow up... you had my respect for your work but now I am starting to doubt if you are really worth the respect. It is disgusting what you are doing. Asking if I am retarted. Well, take a second look at my work and you will be proven wrong.

Edited by IT07
Link to comment
Share on other sites

  • 0

That is how to properly test code that runs multiple times in a short period of time. With the for loop.
Cycles does not mean how often it is ran. Cycles refers to how much code is allowed to loop in a non-scheduled environment. The debug console is a non-scheduled environment because uiSleep or sleep will throw you an generic error in expression.
The debug console only executes the code once, not 10000 times. If code takes too long to execute, it will stop and resume on another cycle.

Link to comment
Share on other sites

  • 0

That is how to properly test code that runs multiple times in a short period of time. With the for loop.
Cycles does not mean how often it is ran. Cycles refers to how much code is allowed to loop in a non-scheduled environment. The debug console is a non-scheduled environment because uiSleep or sleep will throw you an generic error in expression.
The debug console only executes the code once, not 10000 times. If code takes too long to execute, it will stop and resume on another cycle.

lol, you could not be more wrong.

the debug console is a scheduled enviroment and the cycles means how many times the code was evaluated.

scheduled enviorment means no suspending within the scope, however you can just use spawn to run suspending code within such scope.

testing in the debug console test the code 10000 times/cycles to get an average time, becourse testing the code just once would not give a accurate/useable result.

if the code has not run its full 10000 cycles when the test is complete, that means there was most likely an error or the code is irrelevant for performance messuring (like code that does nothing on completetion).

for obvius reasons that will not give an accurate result either, not to mention the distortion of running the loop 101 times on each test (wich is actually 1010000 instead of the intended 10000).

Link to comment
Share on other sites

  • 0

No the debug console is a non-scheduled environment. Like I said: try using sleep or uiSleep and it will throw an error because it is not allowed in non-scheduled environment.
"like code that does not nothing on completion" what kind of crap is that? code ITSELF does something already. It is code! Sorry but to me it sounds like you have been told some seriously wrong stuff about how the debug console works.

Link to comment
Share on other sites

  • 0

No the debug console is a non-scheduled environment. Like I said: try using sleep or uiSleep and it will throw an error because it is not allowed in non-scheduled environment.
"like code that does not nothing on completion" what kind of crap is that? code ITSELF does something already. It is code! Sorry but to me it sounds like you have been told some seriously wrong stuff about how the debug console works.

ill just leave this here for you, as this is getting to a point where you are seriously degrading yourself ...

never-argue-with-stupid-people-mark-twai

also ...

[]spawn{
    sleep 1;
    hintSilent "i can sleep in scheduled environments";
};

 

Link to comment
Share on other sites

  • 0

Wow, *slow clap* you really know how to disrespect someone huh? That image shows exactly what kind of a douchebag you are.

also ...

[]spawn{
    sleep 1;
    hintSilent "i can sleep in scheduled environments";
};

 

I am really impressed by your amazing scripting knowledge and skills. You obviously know everything much better and obviously know that SPAWN creates a SCHEDULED ENVIRONMENT in a NON-SCHEDULED ENVIRONMENT.
I shall now walk away in big shame because I was totally wrong and I shall rethink my coding because I obviously am so stupid that I should be ignored by everyone according to the image you posted.
Apparently you need an image to speak "wise" words instead of writing them yourself. I wish you a very good day sir.

Link to comment
Share on other sites

  • 0

Wow, *slow clap* you really know how to disrespect someone huh? That image shows exactly what kind of a douchebag you are.

I am really impressed by your amazing scripting knowledge and skills. You obviously know everything much better and obviously know that SPAWN creates a SCHEDULED ENVIRONMENT in a NON-SCHEDULED ENVIRONMENT.I shall now walk away in big shame because I was totally wrong and I shall rethink my coding because I obviously am so stupid that I should be ignored by everyone according to the image you posted.
Apparently you need an image to speak "wise" words instead of writing them yourself. I wish you a very good day sir.

i dont need it, i could write it aswell, i just thought the picture was fitting and says it all ... this one too:

1380117461259184.jpg

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Advertisement
  • Discord

×
×
  • Create New...