• 0
Spin Khan

ExilePlayerInSafezone in Server context?

Question

I'm looking for a way to determine if the player is currently in a SafeZone or not within the context of the server.

I have a player, call it _x, how can I determine if _x is currently IN a safezone?

I'm stumped.  TIA!

Share this post


Link to post
Share on other sites

16 answers to this question

  • 0

Not sure if i  understand correctly what your need is, what's the problem using:

(ExilePlayerInSafezone)
if (ExilePlayerInSafezone) then

{

this;

};

 

Edited by WURSTKETTE

Share this post


Link to post
Share on other sites
  • 0

Yeah, that's not right.  I'm still stuck on this, hoping anyone with a good underlying grasp of Exile might know the best way to answer this question.  Seems like a natural service given a player object to be able to ask this question directly.  However, even if such a service is not available, someone surely know the best way to ask the question,

Given the player, _x, is he in the safezone or not?

 

Thanks

Share this post


Link to post
Share on other sites
Advertisement
  • 0
1 hour ago, Spin Khan said:

Yeah, that's not right.  I'm still stuck on this, hoping anyone with a good underlying grasp of Exile might know the best way to answer this question.  Seems like a natural service given a player object to be able to ask this question directly.  However, even if such a service is not available, someone surely know the best way to ask the question,

Given the player, _x, is he in the safezone or not?

 

Thanks

Actually what @WURSTKETTE posted is correct. Why would this not work for you? and if anyone has a "grasp" of coding in exile its him. As its been told to me and countless others, post the script in question and where you'd like the check be placed and someone can point you in the right direction.

  • Like 2

Share this post


Link to post
Share on other sites
  • 0

Actually, that's not correct, thanks for playing.  Please, if you can't contribute to my problem, step back, please.  I really would like to find a real answer to my question.

Thanks!

Share this post


Link to post
Share on other sites
  • 0
2 hours ago, Spin Khan said:

Yeah, that's not right.  I'm still stuck on this, hoping anyone with a good underlying grasp of Exile might know the best way to answer this question.

While i'm not a expert at all but when a player is in a safezone, (ExilePlayerInSafezone) return "true" - there is your check - not sure what's wrong with that/ why you can't work with that.

Take a look at this function and modify for your needs - (basically) the same as above:

/**
 * ExileClient_util_world_isInTraderZone
 *
 * Exile Mod
 * www.exilemod.com
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 */
 
private["_position", "_result"];
_playerpos = getPosATL player;
_result = false;
{
	if (((_x select 0) distance2D _playerpos) < (_x select 1)) exitWith
	{
		_result = true;
	};
}
forEach ExileTraderZoneMarkerPositionsAndSize;
_result

There would be for sure other ways of checking if a player is in a safezone or not but why not use functions already part of the game.

Without a sample code or any idea what you're trying, it might be hard to tell for others what exactly you're trying to achieve or maybe i just don't understand it at all.

 

Good luck

Edited by WURSTKETTE
  • Like 1

Share this post


Link to post
Share on other sites
  • 0

create a file, lets call it testsafezone.sqf

in it, put the following.

try
{
	if (ExilePlayerInSafezone) throw "Oh look! You're in a savezone!";
	["InfoTitleAndText", ["Yeah", "You are not in a savezone!"]] call ExileClient_gui_toaster_addTemplateToast;
};
catch
{
	["InfoTitleAndText", ["Whoops", _exception]] call ExileClient_gui_toaster_addTemplateToast;
};

call it in a save zone, then call it out of a safe zone, see what happens.

PS: "Actually, that's not correct, thanks for playing.  Please, if you can't contribute to my problem, step back, please.  I really would like to find a real answer to my question.

Thanks!"

If I indeed didn't offer anything of use, wouldn't i be in fact contributing to the problem as requested?

Edited by geekm0nkey
being a smartass!
  • Like 1

Share this post


Link to post
Share on other sites
  • 0
1 hour ago, Spin Khan said:

Actually, that's not correct, thanks for playing.  Please, if you can't contribute to my problem, step back, please.  I really would like to find a real answer to my question.

Thanks!

Play nice or don't play at all. The answer given was correct and can be adjusted to suit almost all needs. Don't tell someone that their solution is incorrect when you're the one who doesn't know how to do something yet.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
1 hour ago, WURSTKETTE said:

While i'm not a expert at all but when a player is in a safezone, (ExilePlayerInSafezone) return "true" - there is your check - not sure what's wrong with that/ why you can't work with that.

Take a look at this function and modify for your needs - (basically) the same as above:


/**
 * ExileClient_util_world_isInTraderZone
 *
 * Exile Mod
 * www.exilemod.com
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 */
 
private["_position", "_result"];
_playerpos = getPosATL player;
_result = false;
{
	if (((_x select 0) distance2D _playerpos) < (_x select 1)) exitWith
	{
		_result = true;
	};
}
forEach ExileTraderZoneMarkerPositionsAndSize;
_result

There would be for sure other ways of checking if a player is in a safezone or not but why not use functions already part of the game.

Without a sample code or any idea what you're trying, it might be hard to tell for others what exactly you're trying to achieve or maybe i just don't understand it at all.

 

Good luck

To add to this, you could do it this way too:

if ((vehicle player) call ExileClient_util_world_isInTraderZone) then
{
	Code code code;
};

 

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
54 minutes ago, kuplion said:

Play nice or don't play at all. The answer given was correct and can be adjusted to suit almost all needs. Don't tell someone that their solution is incorrect when you're the one who doesn't know how to do something yet.

But it's NOT correct.  And please, don't tell ME, I'm not playing nice, Son, I've been in this game far longer I'm sure.  But, I've been deferential and courteous from the outset and will attempt to continue to be so even in the face of being offended that people like you seem to think I need to be bending my knee simply because someone TRIED to answer my question.  The COURTEOUS and respectful answer would be to not be presumptuous and unhelpful and would be to indicate a comprehension of MY needs before tossing out unhelpful or answers you believe adamantly true, and then to continually force them forward.

The fact is, for what I'm doing, for code running in a server context only, this variable is NOT available.   You might look up yourself,

https://community.bistudio.com/wiki/hasInterface

Geek, unhelpful, for the same reasons.  Do I really need to show you my logs?  I mean, I'm ready to be corrected, I want an answer here, this arguing is a complete waste of my very valuable time.  I'm admittedly not an expert and am learning this as I go, but I think I AM able to read where my logs quite plainly tell me, AS I'VE STATED, this variable is undefined!  Shake off the Tribalism mindset!

Additionally, not one answer yet has had the decency or respect to answer my question directly without presumption.  I said quite plainly,

GIVEN player _X ASK if that player is in the safezone.

Now it appears Wurstkette just posted something I need to review because he, now at least, is getting to the core of my question.  BUT, with that possible exception, none of your answers have come close.  Instead, and I find this most OFFENSIVE, you take what you THINK I need to do, translate it into your own presumptions and spew forth the answer you were trained to give.  Well, I'm sorry and, maybe I'm too old, but having been a software engineer my entire adult life, I'm learning ArmA the way I WANT.  And I simply want to know if there is a reasonable way, given a player to determine if he's in the safezone.  Do you see a player in simply checking your variable for T/F?  No!  On it's face, these constant cavegirl demands are slaps in the face! 

Wurstkette, thanks, let me review.   I was afraid this might come down to such actual position checking but I, being new to arma scripting, was hoping there was either a service already surfaced in the server code for this question, which is certainly reasonable, or that there was a best accepted way given that there wasn't such a service directly.  Let me take a look at what you posted.  TA

Share this post


Link to post
Share on other sites
  • 0
2 hours ago, WURSTKETTE said:

Take a look at this function and modify for your needs - (basically) the same as above:

There would be for sure other ways of checking if a player is in a safezone or not but why not use functions already part of the game.

 

1 hour ago, kuplion said:

To add to this, you could do it this way too:



if ((vehicle player) call ExileClient_util_world_isInTraderZone) then
{
	Code code code;
};

 

 

Wurst, yes I agree, unfortunately in this context, as I've been saying that var is unavailable.  But you may be on to something. 

Kuplion, thanks, let me review.  If I can use that client function like that, it's probably what I'm looking for.  I didn't notice it probably because as I searched the client and server code I was using 'safezone' rather than 'traderzone'! 

My initial thoughts, and now this comes right down to me being green and only learning as I move forward, right off the top of my head I'm not sure I know whether or not I can call that client function from the server side.  But I'm still getting my head wrapped around the different subsystems and exactly how they fit together.  I realize the server is also a client, so that'll probably work.  If so, many thanks... I'll review!

Share this post


Link to post
Share on other sites
Advertisement

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

  • Recently Browsing   0 members

    No registered users viewing this page.