1. This forum is obsolete and read-only. Feel free to contact us at support.keenswh.com

Visual Script Crashes Dedicated Server (SOLVED)

Discussion in 'Visual Scripting' started by deranjer, May 17, 2017.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. deranjer

    deranjer Trainee Engineer

    Messages:
    10
    So I test my world on my local box (new game -> Custom Game) and it works great. I then copy the folder from Custom Worlds over to my dedicated server box and spin up the server. I connect to it and when I run into the trigger to join the Red Faction the server crashes (the blu faction still works fine on the dedicated server).

    This is the error:
    Code:
    2017-05-16 21:08:51.487 - Thread:  8 ->  Exception occured: System.NullReferenceException: Object reference not set to an instance of an object.
      at Sandbox.Game.MyVisualScriptLogicProvider.GetIdentityFromPlayerId(Int64 playerId)
      at VisualScripting.CustomScripts.Test_Script2.AreaTrigger_Entered(String triggerName, Int64 playerId) in :line 157
      at Sandbox.Game.EntityComponents.MyAreaTriggerComponent.UpdateInternal()
      at Sandbox.Game.SessionComponents.MySessionComponentTriggerSystem.UpdateAfterSimulation()
      at Sandbox.Game.World.MySession.UpdateComponents()
      at Sandbox.Game.World.MySession.Update(MyTimeSpan updateTime)
      at Sandbox.MySandboxGame.Update()
      at Sandbox.Engine.Platform.Game.UpdateInternal()
      at Sandbox.Engine.Platform.Game.RunSingleFrame()
      at Sandbox.Engine.Platform.FixedLoop.<>c__DisplayClass1.<Run>b__0()
      at Sandbox.Engine.Platform.GenericLoop.Run(VoidAction tickCallback)
      at Sandbox.Engine.Platform.Game.RunLoop()
      at Sandbox.MySandboxGame.Run(Boolean customRenderLoop, Action disposeSplashScreen)
      at VRage.Dedicated.DedicatedServer.RunInternal()
      at VRage.Dedicated.DedicatedServer.RunMain(String instanceName, String customPath, Boolean isService, Boolean showConsole)
      at VRage.Dedicated.WindowsService.MainThreadStart(Object obj)
      at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
      at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
      at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
      at System.Threading.ThreadHelper.ThreadStart(Object obj)
    2017-05-16 21:08:51.488 - Thread:  8 ->  Hiding window
    2017-05-16 21:08:51.488 - Thread:  8 ->  Hiding window done
    2017-05-16 21:08:51.488 - Thread:  8 ->  Showing message
    
    This is my compiled script:
    Code:
    1: using System.Collections.Generic;
    2: using Sandbox.Game;
    3: using System;
    4:
    5: namespace VisualScripting.CustomScripts
    6: {
    7:    public class Test_Script2 : IMyLevelScript
    8:    {
    9:        public System.Boolean Setup;
    10:        public System.Boolean StartedGame;
    11:        public System.Boolean Winning;
    12:        public System.Boolean Admin;
    13:        public Test_Script2()
    14:        {
    15:            Setup = false;
    16:            StartedGame = false;
    17:            Winning = false;
    18:            Admin = false;
    19:            Sandbox.Game.MyVisualScriptLogicProvider.PlayerSpawned += PlayerSpawned;
    20:            Sandbox.Game.MyVisualScriptLogicProvider.TimerBlockTriggered += TimerBlockTriggered;
    21:            Sandbox.Game.MyVisualScriptLogicProvider.AreaTrigger_Entered += AreaTrigger_Entered;
    22:        }
    23:
    24:        public void Update()
    25:        {
    26:            if (Winning)
    27:            {
    28:            }
    29:            else
    30:            {
    31:                var outParamFunctionNode_583498370_Return = Sandbox.Game.MyVisualScriptLogicProvider.IsBlockFunctional(name: "PTC.RedBeacon");
    32:                if (outParamFunctionNode_583498370_Return)
    33:                {
    34:                }
    35:                else
    36:                {
    37:                    Sandbox.Game.MyVisualScriptLogicProvider.ShowNotificationToAll(message: "Blue TEAM WINS!!!!", disappearTimeMs: 10000, font: "Red");
    38:                    Winning = true;
    39:                }
    40:
    41:                var outParamFunctionNode_743405966_Return = Sandbox.Game.MyVisualScriptLogicProvider.IsBlockFunctional(name: "PTC.BlueBeacon");
    42:                if (outParamFunctionNode_743405966_Return)
    43:                {
    44:                }
    45:                else
    46:                {
    47:                    Sandbox.Game.MyVisualScriptLogicProvider.ShowNotificationToAll(message: "Red TEAM WINS!!!!!", disappearTimeMs: 10000, font: "Red");
    48:                    Winning = true;
    49:                }
    50:            }
    51:
    52:            if (Setup)
    53:            {
    54:            }
    55:            else
    56:            {
    57:                Sandbox.Game.MyVisualScriptLogicProvider.ShowNotification(message: "Server Setup Complete", disappearTimeMs: 3000);
    58:                Sandbox.Game.MyVisualScriptLogicProvider.SetGridEditable(entityName: "PTC.Training", editable: false);
    59:                Sandbox.Game.MyVisualScriptLogicProvider.SetGridDestructible(entityName: "PTC.Training", destructible: false);
    60:                Sandbox.Game.MyVisualScriptLogicProvider.SetGridEditable(entityName: "PTC.Admin", editable: false);
    61:                Sandbox.Game.MyVisualScriptLogicProvider.SetGridDestructible(entityName: "PTC.Admin", destructible: false);
    62:                Setup = true;
    63:            }
    64:        }
    65:
    66:        public void GameFinished()
    67:        {
    68:        }
    69:
    70:        public void Dispose()
    71:        {
    72:            {
    73:                Sandbox.Game.MyVisualScriptLogicProvider.PlayerSpawned -= PlayerSpawned;
    74:                Sandbox.Game.MyVisualScriptLogicProvider.TimerBlockTriggered -= TimerBlockTriggered;
    75:                Sandbox.Game.MyVisualScriptLogicProvider.AreaTrigger_Entered -= AreaTrigger_Entered;
    76:            }
    77:        }
    78:
    79:        public void GameStarted()
    80:        {
    81:        }
    82:
    83:        public void PlayerSpawned(System.Int64 playerId)
    84:        {
    85:            if (StartedGame)
    86:            {
    87:            }
    88:            else
    89:            {
    90:                Sandbox.Game.MyVisualScriptLogicProvider.ShowNotification(message: "Welcome to PTC!! See the LCD Screens for more info", disappearTimeMs: 5000, playerId: playerId);
    91:            }
    92:        }
    93:
    94:        public void TimerBlockTriggered(System.String entityName)
    95:        {
    96:            if (entityName == "StartGame")
    97:            {
    98:                Sandbox.Game.MyVisualScriptLogicProvider.ShowNotificationToAll(message: "Game has started!!!", disappearTimeMs: 10000);
    99:                Sandbox.Game.MyVisualScriptLogicProvider.RemoveEntity(entityName: "PTC.Training");
    100:                Sandbox.Game.MyVisualScriptLogicProvider.RemoveEntity(entityName: "Ship1");
    101:                Sandbox.Game.MyVisualScriptLogicProvider.RemoveEntity(entityName: "Ship2");
    102:                Sandbox.Game.MyVisualScriptLogicProvider.RemoveEntity(entityName: "Ship3");
    103:                Sandbox.Game.MyVisualScriptLogicProvider.RemoveEntity(entityName: "Ship4");
    104:                Sandbox.Game.MyVisualScriptLogicProvider.RemoveEntity(entityName: "PTC.Training.Projector");
    105:                var outParamFunctionNode_1527385415_Return = VRage.Game.VisualScripting.MyVisualScriptLogicProvider.CreateVector3D(x: -1063746.38F, y: -2507912F, z: 8581689F);
    106:                Sandbox.Game.MyVisualScriptLogicProvider.AddGPSForAll(name: "MiddleAsteroid!", description: "The Ore Rich Asteroid!!!", position: outParamFunctionNode_1527385415_Return, GPSColor: VRageMath.Color.AntiqueWhite, disappearsInS: 1000);
    107:                StartedGame = true;
    108:            }
    109:
    110:            if (entityName == "OpenDoors")
    111:            {
    112:                Sandbox.Game.MyVisualScriptLogicProvider.ChangeDoorState(doorBlockName: "RedDoor");
    113:                Sandbox.Game.MyVisualScriptLogicProvider.ChangeDoorState(doorBlockName: "BlueDoor");
    114:                Sandbox.Game.MyVisualScriptLogicProvider.ShowNotificationToAll(message: "Time to CHOOSE YOUR TEAM!!!", disappearTimeMs: 10000);
    115:            }
    116:        }
    117:
    118:        public void AreaTrigger_Entered(System.String triggerName, System.Int64 playerId)
    119:        {
    120:            if (triggerName == "AdminTrigger2")
    121:            {
    122:                if (Admin)
    123:                {
    124:                }
    125:                else
    126:                {
    127:                    Sandbox.Game.MyVisualScriptLogicProvider.CreateFaction(founderId: playerId, factionTag: "ADM", factionName: "AdminFaction", factionDescription: "RvB Admin");
    128:                    var outParamFunctionNode_1409720492_Return = Sandbox.Game.MyVisualScriptLogicProvider.ChangeOwner(entityName: "PTC.Admin", playerId: playerId, factionShare: true);
    129:                    var outParamFunctionNode_968423129_Return = Sandbox.Game.MyVisualScriptLogicProvider.GetEntityPosition(entityName: "AdTpEnt");
    130:                    Sandbox.Game.MyVisualScriptLogicProvider.SetPlayersPosition(playerId: playerId, position: outParamFunctionNode_968423129_Return);
    131:                    var outParamFunctionNode_1699411118_Return = Sandbox.Game.MyVisualScriptLogicProvider.GetPlayersName(playerId: playerId);
    132:                    System.String constantNode_1101230109 = " has joined the ADMIN team!";
    133:                    var arithmeticResult_1899977402 = outParamFunctionNode_1699411118_Return + constantNode_1101230109;
    134:                    Sandbox.Game.MyVisualScriptLogicProvider.ShowNotificationToAll(message: arithmeticResult_1899977402, disappearTimeMs: 5000, font: "Blue");
    135:                    Sandbox.Game.MyVisualScriptLogicProvider.EnableBlock(blockName: "AdMed");
    136:                    Admin = true;
    137:                }
    138:            }
    139:
    140:            if (triggerName == "RedTrigger")
    141:            {
    142:                var outParamFunctionNode_775685166_Return = Sandbox.Game.MyVisualScriptLogicProvider.GetPlayersFactionTag();
    143:                System.String constantNode_998818720 = "RED";
    144:                var arithmeticResult_1228818669 = outParamFunctionNode_775685166_Return == constantNode_998818720;
    145:                if (arithmeticResult_1228818669)
    146:                {
    147:                }
    148:                else
    149:                {
    150:                    var outParamFunctionNode_1844787029_Return = Sandbox.Game.MyVisualScriptLogicProvider.SetPlayersFaction(playerId: playerId, factionTag: "RED");
    151:                    var outParamFunctionNode_257524851_Return = Sandbox.Game.MyVisualScriptLogicProvider.GetPlayersName(playerId: playerId);
    152:                    System.String constantNode_810445282 = " has joined the Red Faction!";
    153:                    var arithmeticResult_506789764 = outParamFunctionNode_257524851_Return + constantNode_810445282;
    154:                    Sandbox.Game.MyVisualScriptLogicProvider.ShowNotificationToAll(message: arithmeticResult_506789764, disappearTimeMs: 5000, font: "Blue");
    155:                    var outParamFunctionNode_416692278_Return = Sandbox.Game.MyVisualScriptLogicProvider.GetEntityPosition(entityName: "RedTeleport");
    156:                    Sandbox.Game.MyVisualScriptLogicProvider.SetPlayersPosition(position: outParamFunctionNode_416692278_Return);
    157:                }
    158:            }
    159:
    160:            if (triggerName == "BluTrigger")
    161:            {
    162:                var outParamFunctionNode_652500506_Return = Sandbox.Game.MyVisualScriptLogicProvider.GetPlayersFactionTag(playerId: playerId);
    163:                System.String constantNode_1007950120 = "BLU";
    164:                var arithmeticResult_204689256 = outParamFunctionNode_652500506_Return == constantNode_1007950120;
    165:                if (arithmeticResult_204689256)
    166:                {
    167:                }
    168:                else
    169:                {
    170:                    var outParamFunctionNode_288878708_Return = Sandbox.Game.MyVisualScriptLogicProvider.SetPlayersFaction(playerId: playerId, factionTag: "BLU");
    171:                    var outParamFunctionNode_1173107486_Return = Sandbox.Game.MyVisualScriptLogicProvider.GetPlayersName(playerId: playerId);
    172:                    System.String constantNode_1389248059 = " has joined the Blue Faction!";
    173:                    var arithmeticResult_1748608269 = outParamFunctionNode_1173107486_Return + constantNode_1389248059;
    174:                    Sandbox.Game.MyVisualScriptLogicProvider.ShowNotificationToAll(message: arithmeticResult_1748608269, disappearTimeMs: 5000, font: "Blue");
    175:                    var outParamFunctionNode_105703782_Return = Sandbox.Game.MyVisualScriptLogicProvider.GetEntityPosition(entityName: "BluTeleport");
    176:                    Sandbox.Game.MyVisualScriptLogicProvider.SetPlayersPosition(playerId: playerId, position: outParamFunctionNode_105703782_Return);
    177:                }
    178:            }
    179:        }
    180:    }
    181: }
    182:
    
    Anyone know why it crashes on dedicated but not local?
    --- Automerge ---
    Nevermind, for some reason I had missed a connection for the RedTrigger.. don't know why that didn't crash my local instance, but I think if I fix that it should work!
     
Thread Status:
This last post in this thread was made more than 31 days old.