Jump to content
Sign in to follow this  
Dunkstormen

[Tutorial] Enforcing player to be in TFAR channel

Recommended Posts

Author: Dunkstormen

Difficulty: Easy

Description: Blacks out the players screen with a message depending on the state of TaskForceRadio enforcing the player to stay in the channel TaskForceRadio whilst playing.

Step 1:

Copy the following code into the bottom of your core/init.sqf file within your mission.

Quote
    // Checks if user has TaskForceRadio installed
    if(isNil "TFAR_fnc_isTeamSpeakPluginEnabled") exitWith {
        cutText ["<t color='#ff0000' size='2'>Task Force Radio</t><br/><t size='1.5'>TaskForceRadio is not installed!</t>","BLACK",-1,true,true];
        if (player getvariable "taskfr") then {
            player setvariable ["taskfr",false,true];
        };
    };
 
    [] spawn {
        _condition = 0; // Used to store result TFAR check.
        _activeCut = false; // Used to tell if there is an active cuttext.
        _isadmin = false; // Used to tell if the players is an admin.
        while {true} do {
            _TFEnabled = [] call TFAR_fnc_isTeamSpeakPluginEnabled; // Is TaskForceRadio plugin enabled.
            _TFServer = (call TFAR_fnc_getTeamSpeakServerName) == "INSERT TEAMSPEAK NAME HERE"; // Name of the TeamSpeak server. (Must be exact)
            _TFChannel = (call TFAR_fnc_getTeamSpeakChannelName) == "INSERT TFAR CHANNEL NAME HERE"; // Name of the TaskForceRadio channel. (Must be exact)
 
// Checking players life_adminlevel.
            if (!(isNil "life_adminlevel")) then {
                _adminlvl = life_adminlevel call BIS_fnc_parseNumber;
                        
                if (_adminlvl > 0) then {
// If player has life_adminlevel return true.
                    _isadmin = true;
                };
            };
 
            if(!(_TFEnabled) && !(_TFServer) && !(_TFChannel)) then { _condition = 1; }; // Case 1: TeamSpeak plugin is not enabled.
            if(_TFEnabled && !(_TFServer) && !(_TFChannel)) then { _condition = 2; }; // Case 2: Player is on the wrong TeamSpeak server.
            if(_TFEnabled && !(_TFServer) && _TFChannel) then { _condition = 2; }; // Case 2: Player is on the wrong TeamSpeak server.
            if(_TFEnabled && _TFServer && !(_TFChannel)) then { _condition = 3; }; // Case 3: Player is on the correct TeamSpeak but in the wrong channel.
            if(_TFEnabled && _TFServer && _TFChannel) then { _condition = 0; }; // Default: Player is on the correct TeamSpeak and in the correct channel.
            if(_isadmin) then { _condition = 0; }; // Allow admins with life_adminlevel to bypass
 
            switch (_condition) do {
                case 1: {
                    // Case 1: TeamSpeak plugin is not enabled.
                    if(!(_activeCut)) then {
                        _layer1 = "bg" cutText ["","BLACK"];
                        _layer2 = "text" cutText ["<t size='2' color='#FF0000'>TASK FORCE RADIO</t><br/><t size='1.5'>Not enabled!</t>","plain",-1,true,true];
                        player switchMove "Acts_ExecutionVictim_Loop";  // Plays animation on player to prevent them from shooting etc.
                        _activeCut = true;
                    } else {
                        _layer2 = "text" cutText ["<t size='2' color='#FF0000'>TASK FORCE RADIO</t><br/><t size='1.5'>Not enabled!</t>","plain",-1,true,true];
                        _activeCut = true;
                    };
                };
                case 2: {
                    // Case 2: Player is on the wrong TeamSpeak server.
                    if(!(_activeCut)) then {
                        _layer1 = "bg" cutText ["","BLACK"];
                        _layer2 = "text" cutText ["<t size='2' color='#FF0000'>TASK FORCE RADIO</t><br/><t size='1.5'>Wrong TeamSpeak! || Join @ your.teamspeak.server</t>","plain",-1,true,true];
                        player switchMove "Acts_ExecutionVictim_Loop"// Plays animation on player to prevent them from shooting etc.
                        _activeCut = true;
                    } else {
                        _layer2 = "text" cutText ["<t size='2' color='#FF0000'>TASK FORCE RADIO</t><br/><t size='1.5'>Wrong TeamSpeak! || Join @ your.teamspeak.server</t>","plain",-1,true,true];
                        _activeCut = true;
                    };
                };
                case 3: {
                    // Case 3: Player is on the correct TeamSpeak but in the wrong channel.
                    if(!(_activeCut)) then {
                        _layer1 = "bg" cutText ["","BLACK"];
                        _layer2 = "text" cutText ["<t size='2' color='#FF0000'>TASK FORCE RADIO</t><br/><t size='1.5'>Wrong channel!</t>","plain",-1,true,true];
                        player switchMove "Acts_ExecutionVictim_Loop"// Plays animation on player to prevent them from shooting etc.
                        _activeCut = true;
                    } else
                        _layer2 = "text" cutText ["<t size='2' color='#FF0000'>TASK FORCE RADIO</t><br/><t size='1.5'>Wrong channel!</t>","plain",-1,true,true];
                        _activeCut = true;
                    };
                };
                default {
                    // Default: Player is on the correct TeamSpeak and in the correct channel.
                    if(_activeCut) then {
                        _layer1 = "bg" cutText ["","BLACK IN"];
                        _layer2 = "text" cutText ["<t size='2' color='#00ff00'>WELCOME BACK</t><br/><t size='1.5'>Remember to stay in the correct channel at all times.../t>","plain down",-1,true,true];
                        player switchMove "";
                        _activeCut = false;
                    };
                };
            };
 
            // Isn't the code working as expected? Uncomment the line below to enable the hint debug message.
            // Please take a screenshot of the output, and attach it with your post telling the expected behavior.
            
            //hint format ["EN: %1 | SE: %2 | CH: %3 | AC: %4 | CD: %5",_TFEnabled,_TFServer,_TFChannel,_activeCut,_condition];
 
            sleep 2;
        };
    };

 

Edited by Dunkstormen
Clarafication
  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.