Jump to content

Recommended Posts

I want to make a script where the side changes to blufor or opfor with half the probability of a civilian player entering the trigger zone.
We also need a hint message to check if the side has been changed normally.

Share this post


Link to post
Share on other sites

When you place a person on the map the 3 options are:

The person is the player

The person is playable

The person is non-playable

 

If you are the player, and you wish to switch to the playable person, you do so with the stroke of a key. Every person sets up their keyboard for the game so your key will be different to mine.

 

You can create a trigger so that when the trigger fires, you switch to the playable character.

 

.

==============================================================================

 

Problem: You can create lots of person as playable. In which case when you hit your key, you have to choose a character from a list. So it is best to make only one person playable.

 

 

 

 

 

 

 

 

 

 

 

 

 

Share this post


Link to post
Share on other sites
8 hours ago, Joe98 said:

When you place a person on the map the 3 options are:

The person is the player

The person is playable

The person is non-playable

 

If you are the player, and you wish to switch to the playable person, you do so with the stroke of a key. Every person sets up their keyboard for the game so your key will be different to mine.

 

You can create a trigger so that when the trigger fires, you switch to the playable character.

 

.

==============================================================================

 

Problem: You can create lots of person as playable. In which case when you hit your key, you have to choose a character from a list. So it is best to make only one person playable.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I think you had a hard time understanding my question because my English is poor.
Since my English is poor, I would like to ask for your understanding in advance about asking questions through a translator (Papago).


My question is as follows.

1. When a civilian player (not AI!) activated the trigger, it should be changed to Blufor with 50% probability and Opfor with the remaining 50% probability.

2. The number of each Blufor and Opfor player that has been changed cannot exceed half of the total number of civilian players.
If one side first reaches half the total number of civilian players, it is not allowed to be changed to that team and should be changed to the other team.
Example) If there are 100 civilian players, then the number of people who changed to Blufor and Opfor should be 50:50. 49:51. It should be 50:50. If Blufor reaches 50 first, the remaining civilian players should change to Opfor unconditionally.

3. After the team changes, a message should be printed to confirm that the team of the player who activated the trigger has changed correctly. I think it would be a good idea to mark this as a hint.

I had no choice but to borrow your strength because my abilities were at a non-existent level.
I've been using Ghat GPT for a week, but basically my lack of ability and I couldn't figure out what part of the code he created was wrong.

Share this post


Link to post
Share on other sites
// Change sides please
// Get the player who entered the trigger
_player = _this select 0;

// Check if the player is a civilian (not AI)
if (!isPlayer _player || side _player != civilian) exitWith {};

// Get the total number of civilian players
_totalCivilians = civilian countSide (entities [["Man"], [], false, true]);

// Get the number of Blufor players
_bluforCount = west countSide (entities [["Man"], [], false, true]);

// Get the number of Opfor players
_opforCount = east countSide (entities [["Man"], [], false, true]);

// Check if Blufor or Opfor has reached half of the total civilian players
if (_bluforCount >= _totalCivilians / 2) then {
    _player GlobalChat "You cannot join Blufor as they have reached the limit.";
    private _group = createGroup [east, true];
    [player] joinsilent _group;
    _player GlobalChat "Your team has been changed to Opfor.";
} else {
    if (_opforCount >= _totalCivilians / 2) then {
        _player GlobalChat "You cannot join Opfor as they have reached the limit.";
        private _group = createGroup [west, true];
        [_player] joinsilent _group;
        _player GlobalChat "Your team has been changed to Blufor.";
    } else {
        // Randomly assign Blufor or Opfor with 50% probability
        if (random 1 > 0.5) then {
            private _group = createGroup [west, true];
            [_player] joinsilent _group;
            _player GlobalChat "Your team has been changed to Blufor.";
        } else {
            private _group = createGroup [east, true];
            [player] joinsilent _group;
            _player GlobalChat "Your team has been changed to Opfor.";
        }
    }
};

// Print a hint message for confirmation
hint "Your team has been changed. Check side chat for confirmation.";

Create a new text file place it in mission folder. Name it something like MY_fnc_find_proper_side.sqf. Then in your triggers activation put this:

  _handle = thisList execVM "MY_fnc_find_proper_side.sqf";

Hope this helps. 🙂

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

×