Script problem

Hello developers . I have found a script in third person multiplayer . I azume it is regarding some chat application . Don’t know if i am wrong ! .

https://playcanvas.com/project/810313/overview/thirdperson-multiplayer

the code is below

var GamePlayManagerScript = pc.createScript('gamePlayManagerScript');

// GamePlayManagerScript.attributes.add('mainMenuComp', {type: 'entity'});

// GamePlayManagerScript.attributes.add('inputBoxNickNameComp', {type: 'entity'});

// GamePlayManagerScript.attributes.add('playButtonComp', {type: 'entity'});

GamePlayManagerScript.attributes.add('chatBoxPanelComp', {type: 'entity'});

GamePlayManagerScript.attributes.add('inputBoxChatMsgComp', {type: 'entity'});

GamePlayManagerScript.attributes.add('scrollContentPanelComp', {type: 'entity'});

GamePlayManagerScript.attributes.add('verticalScrollbarComp', {type: 'entity'});

GamePlayManagerScript.attributes.add('msgHolderImageComp', {type: 'entity'});

// GamePlayManagerScript.attributes.add('networkEntity', {type: 'entity'});

// GamePlayManagerScript.attributes.add('playerEntity', {type: 'entity'});

// GamePlayManagerScript.attributes.add('otherEntity', {type: 'entity'});

// initialize code called once per entity

// GamePlayManagerScript.prototype.initialize = function() {

   

//     this.app.mouse.disableContextMenu();

   

//     this.mainMenuComp.enabled = true;

//     this.networkEntity.enabled = false;

//     this.playerEntity.enabled = false;

//     this.otherEntity.enabled = false;

//     this.chatBoxPanelComp.enabled = false;

   

//     this.gameStarted = false;

//     this.allowMovement = false;

//     this.lastMsg = "";

   

//     this.nicknameVal = "";

   

//     this.playButtonComp.element.on('click', function (evt) {

       

//         setTimeout(function(){

           

//             this.nicknameVal = this.inputBoxNickNameComp.script.input.getCleanValue();

//             // console.log('btn clicked ' , this.nicknameVal);

//             if(this.nicknameVal !== "")

//             {

//                 this.playerEntity.findByName('playerNickText').element.text = this.nicknameVal;

               

//                 this.mainMenuComp.enabled = false;

//                 this.networkEntity.enabled = true;

//                 this.playerEntity.enabled = true;

//                 this.chatBoxPanelComp.enabled = true;

               

//                 this.gameStarted = true;

//                 this.allowMovement = true;

//             }

//             else

//             {

//                 alert("Please enter proper NickName!");

//             }

   

//         }.bind(this),100);

       

//     }, this);

   

// };

// update code called every frame

GamePlayManagerScript.prototype.update = function(dt) {

   

    if(this.gameStarted === true)

    {

        if (this.app.keyboard.wasPressed(pc.KEY_ENTER))

        {

            // console.log(this.inputBoxChatMsgComp.script.input.checkFocus());

           

            if(this.inputBoxChatMsgComp.script.input.isFocued() === true)

            {

                var textBoxVal = this.inputBoxChatMsgComp.script.input.getCleanValue();

               

                this.lastMsg = textBoxVal;

                this.inputBoxChatMsgComp.script.input.deleteValue();

                this.inputBoxChatMsgComp.script.input.blur();

               

                if(this.lastMsg !== "")

                {

                    this.networkEntity.script.network.sendMsg(this.nicknameVal,this.lastMsg);

                }

            }

            else

            {

                this.inputBoxChatMsgComp.script.input.focus();

            }

           

            // console.log("this.lastMsg = ", this.lastMsg);

        }

       

        if(this.inputBoxChatMsgComp.script.input.isFocued() === true)

        {

            this.allowMovement = false;

        }

        else

        {

            this.allowMovement = true;

        }

    }

};

// GamePlayManagerScript.prototype.addMsgInChatBox = function(nicknameVal, actualMsg) {

   

//     // console.log("GamePlayManagerScript.prototype.addMsgInChatBox = ",nicknameVal, actualMsg);

//     var msgHolderImageComp = this.msgHolderImageComp.clone();

//     msgHolderImageComp.findByName('sentMsgText').element.text = nicknameVal + " : " +actualMsg;

//     msgHolderImageComp.tags.add('msgBlock');

   

//     this.scrollContentPanelComp.addChild(msgHolderImageComp);

//     msgHolderImageComp.enabled = true;

       

//     if(this.scrollContentPanelComp.findByTag('msgBlock').length * msgHolderImageComp.element.height > 260)

//     {

//         this.scrollContentPanelComp.element.height = this.scrollContentPanelComp.findByTag('msgBlock').length * msgHolderImageComp.element.height;

//         this.verticalScrollbarComp.scrollbar.value = 1;

//     }

// };

// swap method called for script hot-reloading

// inherit your script state here

// GamePlayManagerScript.prototype.swap = function(old) { };

// to learn more about script anatomy, please read:

// http://developer.playcanvas.com/en/user-manual/scripting/

is there any use of this script in this project ?

script location assets-> script → networkingscripts → gamePlayManagerScript.js

Hi @Tr_andreson,

I can’t seem to find any script named gamePlayManagerScript.js in that project.

https://playcanvas.com/project/955719/overview/metaverse2

sorry wrong link …

That’s a heavily commented out script. It seems to be chat related as you said. If you are asking what’s its use, better try to locate and ask the original developer of that project.

1 Like