Jump to content
  • 0

setVariable Checks?


ElDubya

Question

HI all, 

I am spawning in 2 different infostands, one for entry and one for exit, and have set this variable on each  : 

_this setvariable[" Entrytype", 1];          <-----   Entry

_this setvariable[" Exittype", 0];             <----- Exit

What check would I have to put at the end of these corresponding lines in my fn_SelfActions?

if ( cursorTarget isKindOf "Infostand_2_EP1" && (player distance cursorTarget) < 2 ) then {  <----- Entry

if ( cursorTarget isKindOf "Infostand_1_EP1" && (player distance cursorTarget) < 2 ) then {  <----- Exit

Would it be : 

if ( cursorTarget isKindOf "Infostand_2_EP1" && (player distance cursorTarget) < 2 && (cursortarget getvariable["Entertype", -1] == 1) ) then { <----- Entry

if ( cursorTarget isKindOf "Infostand_1_EP1" && (player distance cursorTarget) < 2 && (cursortarget getvariable["Exittype", -0] == 1) ) then { <-----Exit

 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

From your last post, it seems like something is funky with one of the infostands. Have you tested both types? I haven't done anything with infostands :blush:

What I would do, however, is create a sensor in your mission.sqm to cover the secret trader area. Make it "like" a safezone - that is, copy one of the safezones and just don't call player_traderCity. If the sensor is inactive, have a global variable set like "is_in_secret_trader=false;" and if you're in it, have it set to true. Then, you can do something as simple as:

if ((cursorTarget isKindOf "Infostand_2_EP1") && ((player distance cursorTarget) < 2) && !(is_in_secret_trader) ) then {  <--- entry

if ((cursorTarget isKindOf "Infostand_2_EP1") && ((player distance cursorTarget) < 2) && (is_in_secret_trader) ) then {  <--- exit

To simplify things, and for performance, I would do:

if ((cursorTarget isKindOf "Infostand_2_EP1") && ((player distance cursorTarget) < 2)) then {
    if (is_in_secret_trader) then {
        // player is inside the trader city and needs to exit
    } else {
        // player is not inside the trader city and needs to enter
    };
};                                                                                      

I'll play around with the idea too sometime soon and see if I can get something working for you. 

Edit: It's a little slow at work. lol:

Looking at mission.sqm for chernarus; increase the items to 6 and add item 6 at the bottom:

	class Item6
		{
			position[]={6325.6772,304.99033,7807.7412}; // These would be the coordinates of your secret trader - I believe in xzy
			a=100; // Not exactly sure what a and b are for
			b=100;
			activationBy="WEST";
			repeating=1;
			interruptable=1;
			age="UNKNOWN";
			name="zonesuperdupersecrettrader"; // name this to your trader zone or whatever you want the name of the zone to be
			expCond="(player distance zonesuperdupersecrettrader) < 100;"; // radius to the trader you want the sensor to activate
			expActiv="is_in_secret_trader=true;"; // what happens when you're inside the trader
			expDesactiv="is_in_secret_trader=false;"; // what happens when you're outside of the trader
			class Effects
			{
			};
		};

The expActive and expDesactiv can also call a script. See your mission.sqm to see how it calls player_tradercity.

 

Link to comment
Share on other sites

  • 0
 if ( cursorTarget isKindOf "Infostand_2_EP1" && (player distance cursorTarget) < 2 && (cursortarget getvariable["Entertype", -1] == 1) ) then { <----- Entry

if ( cursorTarget isKindOf "Infostand_1_EP1" && (player distance cursorTarget) < 2 && (cursortarget getvariable["Exittype", -0] == 1) ) then { <-----Exit 

 

Let`s review this... As we hopefully know - the fn_selfActions.sqf is called for each player individually. This in return means, that each player is giving that sign a variable and it get`s overwritten a few thousand times. Correct me, if i`m wrong.. So if each player gives that sign a variable, how in gods name would the script know, what to do?

Solution would be: Don`t put the variable on the Sign, put it on the player or in MissionNamespace.

Also -0 doesn`t exist. This will allways return false, no matter what. Simple maths :P

Link to comment
Share on other sites

  • 0
22 hours ago, ViseVersa said:

 if ( cursorTarget isKindOf "Infostand_2_EP1" && (player distance cursorTarget) < 2 && (cursortarget getvariable["Entertype", -1] == 1) ) then { <----- Entry

if ( cursorTarget isKindOf "Infostand_1_EP1" && (player distance cursorTarget) < 2 && (cursortarget getvariable["Exittype", -0] == 1) ) then { <-----Exit 

 

Let`s review this... As we hopefully know - the fn_selfActions.sqf is called for each player individually. This in return means, that each player is giving that sign a variable and it get`s overwritten a few thousand times. Correct me, if i`m wrong.. So if each player gives that sign a variable, how in gods name would the script know, what to do?

Solution would be: Don`t put the variable on the Sign, put it on the player or in MissionNamespace.

Also -0 doesn`t exist. This will allways return false, no matter what. Simple maths :P

It would know as setVariable would have to be used (see the public parameter); the variable is being set on the object itself. Did you ever get this working ElDubya?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...