Jump to content
Sign in to follow this  
zikofrap

Don't change SIDE in Multiplayer

Recommended Posts

Hello. I would like to protect myself from dishonest players. On my project, the server will run 24/7, missions will last from half an hour to two hours. I would like that the players, choosing the side of the "red" until the end of the mission, could not change the side to the "blue", but I do not know how to do this, so I hope for your help.

Share this post


Link to post
Share on other sites
On 3/19/2022 at 12:13 AM, zikofrap said:

Hello. I would like to protect myself from dishonest players. On my project, the server will run 24/7, missions will last from half an hour to two hours. I would like that the players, choosing the side of the "red" until the end of the mission, could not change the side to the "blue", but I do not know how to do this, so I hope for your help.

 

It's pretty straightforward, something like this should do:

 

Players are given a grace-period when connecting the first time to the given session after which they are locked into their current team.

Once the player's team is locked in the players UID and assigned side is stored on server in a hashmap.

 

When players connect a function (CSR_fnc_newPlayer in the below example) queries the hashmap if they have an existing assignment and executes an appropriate response.

If the player has no assignment, countdown the grace-period and lock their current team as their assigned one as per above.

If the player has an assignment and it differs from their selected team immediately end the mission locally using BIS_fnc_endMission executed ONLY on their client.

If the player has an assignment and its the same as their selected team we only need to give them a welcome message.

 

As long as the hashmap is initialized and stored only during the given mission session the next time mission restarts the team assignments will automatically reset.

 

If you need to reset a player's team assignment mid-session (could be useful if you want to make admin tools) simply delete the player's entry from the hashmap using their id from getPlayerUID.

Here's an example how you would do that using in the attached example mission:

SIDE_RESTRICTIONS_MAP deleteAt getPlayerUID _playerObject;

 

Example mission: https://www.dropbox.com/sh/9dnotrclal8j3vb/AADSabn5zKc2clNDeVux4c8Ua?dl=0

The length of the grace-period can be changed in initPlayerLocal.sqf (it's the last parameter in the remoteExec call to CSR_fnc_newPlayer and is measured in seconds).

 

 

Share this post


Link to post
Share on other sites
5 hours ago, mrcurry said:

 

Это довольно просто, что-то вроде этого должно делать:

 

Игрокам дается льготный период при первом подключении к данному сеансу, после чего они блокируются в своей текущей команде.

После того, как команда игрока заблокирована, UID игрока и назначенная сторона сохраняются на сервере в виде хэш-карты.

 

Когда игроки подключаются, функция (CSR_fnc_newPlayer в приведенном ниже примере) запрашивает хэш-карту, есть ли у них существующее назначение, и выполняет соответствующий ответ.

Если у игрока нет задания, отсчитайте льготный период и заблокируйте его текущую команду в качестве назначенной, как указано выше.

Если у игрока есть задание, и оно отличается от выбранной им команды, немедленно завершите миссию локально, используя BIS_fnc_endMission, выполняемую ТОЛЬКО на их клиенте.

Если у игрока есть задание, и оно такое же, как у выбранной им команды, нам нужно только дать ему приветственное сообщение.

 

Пока хэш-карта инициализируется и сохраняется только во время данного сеанса миссии, при следующем перезапуске миссии назначения команды будут автоматически сброшены.

 

Если вам нужно сбросить назначение команды игрока в середине сессии (может быть полезно, если вы хотите создать инструменты администратора), просто удалите запись игрока из хэш-карты, используя его идентификатор из getPlayerUID.

Вот пример того, как вы могли бы это сделать, используя прилагаемый пример миссии:


 

Пример миссии:  https://www.dropbox.com/sh/9dnotrclal8j3vb/AADSabn5zKc2clNDeVux4c8Ua?dl=0

Продолжительность льготного периода может быть изменена в initPlayerLocal.sqf (это последний параметр в вызове remoteExec для CSR_fnc_newPlayer и измеряется в секундах).

 

 


Thanks, I'll check that out today.

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  

×