Jump to content
Rosso777

SOLVED: Picking up Radio activates Chat Channel

Recommended Posts

I am trying to simply create a script that allows the player to use/read SideChat ONLY when they have a radio in their inventory. I have tried this a few different ways and have had no luck yet; side chat is ALWAYS available and I cannot figure out why. Any help from the veterans is appreciated.

 

(script placed in initPlayerLocal.sqf on a dedi server)

 

[] spawn {
  while {true} do {

    waitUntil {"ItemRadio" in assigneditems player};
    1 enableChannel true;

    waitUntil !{"ItemRadio" in assigneditems player};
    1 enableChannel false;

  }
};

 

 

SOLVED: (Although this works, I know there is a more efficient way to do it with either "Take" or "Put" EventHandlers, or perhaps a function in some way. Working on that now and I will update this post once complete and tested.)

 

(script placed in initPlayerLocal.sqf on a dedi server)

[] spawn {
while {true} do {
        sleep 1;
        if ("ItemRadio" in assignedItems player) then {
            1 enableChannel true;
        }
        else {
            1 enableChannel false;
        };
    };
};

 

 

Share this post


Link to post
Share on other sites

hmm you have the ! outside the {}. I don't know if that's going work

 

also if that still doesn't work put some systemchat debug messages after both waitUntil

Share this post


Link to post
Share on other sites
1 minute ago, gc8 said:

hmm you have the ! outside the {}. I don't know if that's going work

 

Noted.  I am going to remove the whole FALSE section and rearrange it a bit.

 

[] spawn {
  while {"ItemRadio" in assigneditems player} do {
    1 enableChannel true;

  }
};

Share this post


Link to post
Share on other sites

also don't forget to put ; after each }

Share this post


Link to post
Share on other sites
1 minute ago, gc8 said:

also don't forget to put ; after each }

 

[] spawn {
  while {"ItemRadio" in assigneditems player} do {
    1 enableChannel true;

  }    <--------------  I know I am the new guy here, but I didn't think that was the case here.
};

Share this post


Link to post
Share on other sites
Just now, Rosso777 said:

I know I am the new guy here, but I didn't think that was the case here.

 

that line caught my eye. you should turn error messages on if you haven't already, helps a lot

Share this post


Link to post
Share on other sites
Just now, gc8 said:

 

that line caught my eye. you should turn error messages on if you haven't already, helps a lot

 

Absolutely; I live and die by the server's rpt file.

 

No errors. But still no luck. Going to keep trying. I will crack this and then update the OP.

Share this post


Link to post
Share on other sites
Just now, Rosso777 said:

Absolutely; I live and die by the server's rpt file.

 

check the "show script errors" in launcher (client) to get the errors on screen

  • Like 1

Share this post


Link to post
Share on other sites
18 minutes ago, gc8 said:

 

check the "show script errors" in launcher (client) to get the errors on screen

 

Wow. Yet another thing I was NOT aware of. First go, errors lighting up. Gamechanger! Thanks, @gc8!

Share this post


Link to post
Share on other sites
3 hours ago, gc8 said:

also don't forget to put ; after each }


Add a semicolon before starting a new line within the same scope,

this spawn {
	waitUntil {
		sleep 1;
		if alive _this then {systemChat str alive _this};
		!alive _this
	}
}
this spawn {
	waitUntil {
		sleep 1;
		if alive _this then {systemChat str alive _this};
		!alive _this
	};
	systemChat "exited loop"
}

Have fun!

  • Like 1

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

×