Jump to content
Sign in to follow this  
-)rStrangelove

Activating areas by players in MP

Recommended Posts

Hey gents,

was thinking about how to keep track of all player positions in MP via scripting, and without using any triggers.

Possible approach:

Activation distance is set to 500m. Areas are represented by markers, set to markersize 0,0 so they can't be seen but you can still use them for storing information. For example, set its color or set its rotation if a player is inside a 500m radius. That way you could activate anything that needs to be done if a player is near, like spawning civilians & enemy forces & special structures.

A MP script handling player activated markers would need to handle 3 situations:

1. Sole player is inside a marker radius

2. Sole player is outside "

3. Several players are inside a marker. 1 player left the marker radius while others are still inside the marker.

Obviously, the 3rd is the tricky one. Imo this can't be done without all scripts synced via a clock signal. For example: if every player checks his position every 1 second, a script would need 2 seconds (2 clocks) to solve the problem of the 3rd situation:

- 1st clock signal: 1st and 2nd player are inside the marker

- 2nd clock signal: 1 is outside, 1 is inside the marker. (we can't know if the marker setting is right now or was overwritten with a false setting)

- 3rd clock signal: only 1 player is signalling: i'm inside

So basically the script would only need to signal once that a player left the marker but only if he was inside the same marker before.

What i'd like to know is if somebody has a more easier approach to this. Anyone? :rolleyes:

Share this post


Link to post
Share on other sites

I know this is not what you asked for (and god knows i hate when i ask something and people post replies like "and why do you want to do it this way, why dont you use ..."), but i cant help it:

Why bothering with a script, when you can use simple triggers?

Maybe only if the condition is very complicated and is too hungry for processor time (because i think i read somewhere that trigger's conditions are processed every frame), but i dont think this is such case of "hungry" conditions.

But maybe i just dont understand your reasons.

Here is what i would probably do, but it may not be the right way for you:

I would use one trigger, and script.

The trigger would be the kind of "ANYBODY" "PRESENT", and the script would be periodically checking who is inside and who is outside:

_all_in = false;
_total_players = 10; // you set it manualy, or by some script before (it doesn't matter for this example, you just need to know how many players are there).
While {true} do {
 _players_inside = {isPlayer _x} Count (List _trigger);
 if ( _players_inside == 1 ) then {
   // 1. SOLE PLAYER IS INSIDE A MARKER RADIUS
 };
 if ( !_all_in && _players_inside == _total_players - 1 ) then {
   // 2. SOLE PLAYER IS OUTSIDE A MARKER RADIUS
 };
 if ( _players_inside == _total_players ) then {
   _all_in = true;
 };
 if ( _all_in && _players_inside < _total_players ) then {
   // 3. SEVERAL PLAYERS ARE INSIDE A MARKER. 1 PLAYER LEFT WHILE OTHERS ARE STILL INSIDE
   _all_in = false;
 };
 sleep 0.01;
}

This is simplified example, not a complete script - i have no idea what exactly do you want to use it for. This is just VERY BASIC sketch.

Also, i am not sure about the point #3 - do you want to check if ALL players were inside, and one just left?

Or if SOME were inside and one just left? - in that case you would need some additional variable to store the "old" number of players inside, and add another condition to check if the fresh new value of _players_inside is one less.

Share this post


Link to post
Share on other sites

Thx mate, i'm happy with any answer i get.

Triggers seem to be the only way how to do it without the pain of heavy scripting.

I'm looking into ways how to save performance. I want to cover the whole island with areas that can detect players and i figured if i can come up with a way to sync scripts that work with local and global markers it would be better performancewise.

I agree my way of thinking might be a bit weird. And maybe i'm totally off target. :P

Another way would be to have every player creating a marker for himself. Could be invisible for players, but all scripts would be able to track players by their markers and then check if spawnzones are near any player. That would be the other way around, might be easier to script.

Edited by ])rStrangelove

Share this post


Link to post
Share on other sites

By local markers you mean local to the server, or clients?

If local to the client, then you'll have to send the marker position to the server, because server have no clue that marker even does exist (i guess the whole marker/player pos thingy is not client side only, so you need the server to know) - i dont think its a good way to do it.

And besides, you can already GetPos _player position, why adding more code to periodically _marker SetMarkerPos _player_pos and GetMarkerPos _marker ?

Again, maybe i misunderstood, but to me it seems the markers would only add another thing you have to take care of (creating them, positioning them, etc.), without much benefit (or i fail to see it).

Its really hard to tell what would be the best way.

Could you write more about what is the purpose of this?

For example i cant imagine (and that my be only my dumbness, not your fault, so be patient with me) why you need to check such different cases of who is where? What is the purpose of this all?

Share this post


Link to post
Share on other sites

Ok :)

1. I want the server to know if any player is inside a 500m radius of a zone.

2. There should be no limitation how many zones were placed by the mission designer. That's why i was thinking NOT to use triggers. I'd like to do this via SQF functions that i can finetune how much cpu resources they need. I don't have this level of control with triggers.

3. The info whether a zone is being visited by a player or not can be used in many ways. I was thinking about usual stuff like spawning / deleting civilians, enemies, structures on the fly. That's all. Without stressing the cpu at all, no matter how many zones are in the mission.

Share this post


Link to post
Share on other sites

What you are suggesting is basically how my PVP scripts work. (I don't use triggers because they are 'edge -triggered' and don't fire repeated when the condition is true.

I have code which can tell you exactly objects/players are inside the area of a marker whether it is elliptical or rectangular and regardless or size.

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  

×