Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Jonathan Patrick | Entelicon | 2/22/2019
- local MatchModule = require(game.ReplicatedStorage.Modules.MatchModule);
- local RoundModule = require(game.ReplicatedStorage.Modules.RoundModule);
- local WeaponModule = require(game.ReplicatedStorage.Modules.WeaponFramework.Weapon);
- local BackpackModule = require(game.ReplicatedStorage.Modules.BackpackModule);
- local ProjectileModule = require(game.ReplicatedStorage.Modules.WeaponFramework.Projectile);
- local WeaponFramework = require(game.ReplicatedStorage.Modules.WeaponFramework);
- local localPlayer = nil;
- local setStateBindableEvent = nil;
- local shopExitedBindableEvent = nil;
- local shopEnteredBindableEvent = nil;
- local standToggledBindableEvent = nil;
- local characterAddedBindableEvent = nil;
- local overviewToggledBindableEvent = nil;
- local matchInformationDisplayedBindableEvent = nil;
- local playerJoinedMatchClientRemoteEvent = nil;
- local replicateWeaponDynamicRemoteEvent = nil;
- local replicatedProjectileDynamicRemoteEvent = nil;
- local hasMatchInformationBeenDisplayed = false;
- function Initialize()
- localPlayer = game.Players.LocalPlayer;
- setStateBindableEvent = game.ReplicatedStorage.Messages.Bindable.Events.SetStateBindableEvent;
- shopExitedBindableEvent = game.ReplicatedStorage.Messages.Bindable.Events.Client.ShopExitedBindableEvent;
- shopEnteredBindableEvent = game.ReplicatedStorage.Messages.Bindable.Events.Client.ShopEnteredBindableEvent;
- standToggledBindableEvent = game.ReplicatedStorage.Messages.Bindable.Events.Client.StandToggledBindableEvent;
- characterAddedBindableEvent = game.ReplicatedStorage.Messages.Bindable.Events.Client.CharacterAddedBindableEvent;
- overviewToggledBindableEvent = game.ReplicatedStorage.Messages.Bindable.Events.Client.Interface.OverviewToggledBindableEvent;
- matchInformationDisplayedBindableEvent = game.ReplicatedStorage.Messages.Bindable.Events.Client.Interface.MatchInformationDisplayedBindableEvent;
- playerJoinedMatchClientRemoteEvent = game.ReplicatedStorage.Messages.Remote.Events.PlayerJoinedMatchClientRemoteEvent;
- replicateWeaponDynamicRemoteEvent = game.ReplicatedStorage.Messages.Remote.Events.ReplicateWeaponDynamicRemoteEvent;
- replicatedProjectileDynamicRemoteEvent = game.ReplicatedStorage.Messages.Remote.Events.ReplicateProjectileDynamicRemoteEvent;
- end
- function OnShopExited(shopName)
- WeaponFramework.ToggleAll(true);
- end
- function OnShopEntered(shopName)
- WeaponFramework.ToggleAll(false);
- end
- function OnStandToggled(standName, toggleBool)
- WeaponFramework.ToggleAll(not toggleBool);
- setStateBindableEvent:Fire("DisableStates");
- end
- function OnCharacterAdded(isCharacterFirstLoad)
- local isEntrantValue = localPlayer:WaitForChild("PlayerValues").GeneralValues.IsEntrantValue.Value;
- if (isEntrantValue == true) then
- -- Because Delay
- wait(0.1);
- hasMatchInformationBeenDisplayed = true;
- OnPlayerJoinedMatch(localPlayer.Name);
- end
- end
- function OnOverviewToggled(toggleBool)
- local isMatchOpen = MatchModule.IsMatchOpen() == true and MatchModule.IsMatchLive() == false;
- local isEntrantValue = localPlayer:WaitForChild("PlayerValues").GeneralValues.IsEntrantValue.Value;
- if (isMatchOpen == true) and (isEntrantValue == true) then return end;
- WeaponFramework.ToggleAll(not toggleBool);
- if (toggleBool == true) then setStateBindableEvent:Fire("DisableStates") end
- end
- function OnPlayerJoinedMatch(playerName)
- if (playerName == localPlayer.Name) then
- local isMatchOpenBool = MatchModule.IsMatchOpen() == true and MatchModule.IsMatchLive() == false;
- local isEntrantValue = localPlayer:WaitForChild("PlayerValues").GeneralValues.IsEntrantValue.Value;
- local allowMovementBool = (true == true) and (isMatchOpenBool == false) and (isEntrantValue == true) and hasMatchInformationBeenDisplayed;
- WeaponFramework.ToggleAll(allowMovementBool);
- setStateBindableEvent:Fire("DisableStates");
- end
- end
- function OnRoundStateUpdated(updatedRoundState)
- local isEntrantValue = localPlayer:WaitForChild("PlayerValues").GeneralValues.IsEntrantValue.Value;
- if (isEntrantValue == true) then
- local isMatchFininished = updatedRoundState == "MatchFinished";
- if (isMatchFininished) then
- hasMatchInformationBeenDisplayed = false;
- WeaponFramework.ToggleAll(false);
- setStateBindableEvent:Fire("DisableStates");
- else
- WeaponFramework.ToggleAll(true);
- end
- end
- end
- function OnPlayerAdded(player)
- local self = BackpackModule.Equipped;
- if (self.Name ~= "None") and (self.Name ~= "Dead") then
- local serverData = {Name = self.Name, Type = self.Type, C0 = self.C0};
- replicateWeaponDynamicRemoteEvent:FireServer("Equip", serverData);
- end
- end
- function Test()
- hasMatchInformationBeenDisplayed = true;
- OnPlayerJoinedMatch(localPlayer.Name);
- end
- Initialize();
- shopExitedBindableEvent.Event:Connect(OnShopExited);
- shopEnteredBindableEvent.Event:Connect(OnShopEntered);
- standToggledBindableEvent.Event:Connect(OnStandToggled);
- characterAddedBindableEvent.Event:Connect(OnCharacterAdded);
- overviewToggledBindableEvent.Event:Connect(OnOverviewToggled);
- matchInformationDisplayedBindableEvent.Event:Connect(Test);
- playerJoinedMatchClientRemoteEvent.OnClientEvent:Connect(OnPlayerJoinedMatch);
- replicatedProjectileDynamicRemoteEvent.OnClientEvent:Connect(function(p,w, f, ...)
- if (p ~= localPlayer) then
- ProjectileModule[f](w, p, ...);
- end
- end);
- replicateWeaponDynamicRemoteEvent.OnClientEvent:Connect(function(p, f, ...)
- if (p ~= localPlayer) then
- WeaponModule.Replicated[f](p, ...);
- end
- end);
- game.Players.PlayerAdded:Connect(OnPlayerAdded);
- RoundModule.OnRoundStateUpdated():Connect(OnRoundStateUpdated);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement