Advertisement
Guest User

Untitled

a guest
May 24th, 2019
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.67 KB | None | 0 0
  1. -- Jonathan Patrick | Entelicon | 2/22/2019
  2.  
  3. local MatchModule = require(game.ReplicatedStorage.Modules.MatchModule);
  4. local RoundModule = require(game.ReplicatedStorage.Modules.RoundModule);
  5. local WeaponModule = require(game.ReplicatedStorage.Modules.WeaponFramework.Weapon);
  6. local BackpackModule = require(game.ReplicatedStorage.Modules.BackpackModule);
  7. local ProjectileModule = require(game.ReplicatedStorage.Modules.WeaponFramework.Projectile);
  8.  
  9. local WeaponFramework = require(game.ReplicatedStorage.Modules.WeaponFramework);
  10.  
  11. local localPlayer = nil;
  12.  
  13. local setStateBindableEvent = nil;
  14. local shopExitedBindableEvent = nil;
  15. local shopEnteredBindableEvent = nil;
  16. local standToggledBindableEvent = nil;
  17. local characterAddedBindableEvent = nil;
  18. local overviewToggledBindableEvent = nil;
  19. local matchInformationDisplayedBindableEvent = nil;
  20.  
  21. local playerJoinedMatchClientRemoteEvent = nil;
  22.  
  23. local replicateWeaponDynamicRemoteEvent = nil;
  24. local replicatedProjectileDynamicRemoteEvent = nil;
  25.  
  26. local hasMatchInformationBeenDisplayed = false;
  27.  
  28. function Initialize()
  29.  
  30. localPlayer = game.Players.LocalPlayer;
  31.  
  32. setStateBindableEvent = game.ReplicatedStorage.Messages.Bindable.Events.SetStateBindableEvent;
  33. shopExitedBindableEvent = game.ReplicatedStorage.Messages.Bindable.Events.Client.ShopExitedBindableEvent;
  34. shopEnteredBindableEvent = game.ReplicatedStorage.Messages.Bindable.Events.Client.ShopEnteredBindableEvent;
  35. standToggledBindableEvent = game.ReplicatedStorage.Messages.Bindable.Events.Client.StandToggledBindableEvent;
  36. characterAddedBindableEvent = game.ReplicatedStorage.Messages.Bindable.Events.Client.CharacterAddedBindableEvent;
  37. overviewToggledBindableEvent = game.ReplicatedStorage.Messages.Bindable.Events.Client.Interface.OverviewToggledBindableEvent;
  38. matchInformationDisplayedBindableEvent = game.ReplicatedStorage.Messages.Bindable.Events.Client.Interface.MatchInformationDisplayedBindableEvent;
  39.  
  40. playerJoinedMatchClientRemoteEvent = game.ReplicatedStorage.Messages.Remote.Events.PlayerJoinedMatchClientRemoteEvent;
  41.  
  42. replicateWeaponDynamicRemoteEvent = game.ReplicatedStorage.Messages.Remote.Events.ReplicateWeaponDynamicRemoteEvent;
  43. replicatedProjectileDynamicRemoteEvent = game.ReplicatedStorage.Messages.Remote.Events.ReplicateProjectileDynamicRemoteEvent;
  44.  
  45. end
  46.  
  47. function OnShopExited(shopName)
  48. WeaponFramework.ToggleAll(true);
  49. end
  50.  
  51. function OnShopEntered(shopName)
  52. WeaponFramework.ToggleAll(false);
  53. end
  54.  
  55. function OnStandToggled(standName, toggleBool)
  56. WeaponFramework.ToggleAll(not toggleBool);
  57. setStateBindableEvent:Fire("DisableStates");
  58. end
  59.  
  60. function OnCharacterAdded(isCharacterFirstLoad)
  61.  
  62. local isEntrantValue = localPlayer:WaitForChild("PlayerValues").GeneralValues.IsEntrantValue.Value;
  63.  
  64. if (isEntrantValue == true) then
  65.  
  66. -- Because Delay
  67. wait(0.1);
  68. hasMatchInformationBeenDisplayed = true;
  69. Scan(localPlayer.Name);
  70.  
  71. end
  72. end
  73.  
  74. function OnOverviewToggled(toggleBool)
  75.  
  76. local isMatchOpen = MatchModule.IsMatchOpen() == true and MatchModule.IsMatchLive() == false;
  77. local isEntrantValue = localPlayer:WaitForChild("PlayerValues").GeneralValues.IsEntrantValue.Value;
  78.  
  79. if (isMatchOpen == true) and (isEntrantValue == true) then return end;
  80.  
  81. WeaponFramework.ToggleAll(not toggleBool);
  82. if (toggleBool == true) then setStateBindableEvent:Fire("DisableStates") end
  83. end
  84.  
  85. function Scan()
  86.  
  87.  
  88. local isMatchOpenBool = MatchModule.IsMatchOpen() == true and MatchModule.IsMatchLive() == false;
  89. local isEntrantValue = localPlayer:WaitForChild("PlayerValues").GeneralValues.IsEntrantValue.Value;
  90. local allowMovementBool = (true == true) and (isMatchOpenBool == false) and (isEntrantValue == true) and hasMatchInformationBeenDisplayed;
  91.  
  92. WeaponFramework.ToggleAll(allowMovementBool);
  93. setStateBindableEvent:Fire("DisableStates");
  94.  
  95. end
  96.  
  97.  
  98.  
  99. function OnPlayerJoinedMatch(playerName)
  100. if (playerName == localPlayer.Name) then
  101. Scan();
  102. end
  103. end
  104.  
  105. function OnRoundStateUpdated(updatedRoundState)
  106.  
  107. local isEntrantValue = localPlayer:WaitForChild("PlayerValues").GeneralValues.IsEntrantValue.Value;
  108.  
  109. if (isEntrantValue == true) then
  110.  
  111. local isMatchFininished = updatedRoundState == "MatchFinished";
  112.  
  113. if (isMatchFininished) then
  114. hasMatchInformationBeenDisplayed = false;
  115. WeaponFramework.ToggleAll(false);
  116. setStateBindableEvent:Fire("DisableStates");
  117. else
  118. WeaponFramework.ToggleAll(true);
  119. end
  120. end
  121. end
  122.  
  123. function OnPlayerAdded(player)
  124.  
  125. local self = BackpackModule.Equipped;
  126.  
  127. if (self.Name ~= "None") and (self.Name ~= "Dead") then
  128. local serverData = {Name = self.Name, Type = self.Type, C0 = self.C0};
  129. replicateWeaponDynamicRemoteEvent:FireServer("Equip", serverData);
  130. end
  131. end
  132.  
  133. function OnMatchInformationDisplayed()
  134. hasMatchInformationBeenDisplayed = true;
  135. Scan();
  136. end
  137.  
  138. Initialize();
  139.  
  140. shopExitedBindableEvent.Event:Connect(OnShopExited);
  141. shopEnteredBindableEvent.Event:Connect(OnShopEntered);
  142. standToggledBindableEvent.Event:Connect(OnStandToggled);
  143. characterAddedBindableEvent.Event:Connect(OnCharacterAdded);
  144. overviewToggledBindableEvent.Event:Connect(OnOverviewToggled);
  145. matchInformationDisplayedBindableEvent.Event:Connect(OnMatchInformationDisplayed);
  146.  
  147. playerJoinedMatchClientRemoteEvent.OnClientEvent:Connect(OnPlayerJoinedMatch);
  148.  
  149. replicatedProjectileDynamicRemoteEvent.OnClientEvent:Connect(function(p,w, f, ...)
  150. if (p ~= localPlayer) then
  151. ProjectileModule[f](w, p, ...);
  152. end
  153. end);
  154.  
  155. replicateWeaponDynamicRemoteEvent.OnClientEvent:Connect(function(p, f, ...)
  156. if (p ~= localPlayer) then
  157. WeaponModule.Replicated[f](p, ...);
  158. end
  159. end);
  160.  
  161. game.Players.PlayerAdded:Connect(OnPlayerAdded);
  162.  
  163. RoundModule.OnRoundStateUpdated():Connect(OnRoundStateUpdated);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement