Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Abilities
- local function Mirage(player)
- print("Enabling Mirage by : ", player.EntityId)
- YaDisplayObjectAPI.SetVisibility(player, false)
- local timer = YaTime:WaitFor(5)
- EventHelper.AddListener(timer, "TimeEvent", function ()
- YaDisplayObjectAPI.SetVisibility(player, true)
- end)
- end
- local function Octane(player)
- print("Enabling Octane by : ", player.EntityId)
- local walk_speed = YaCharacterAPI.Instance(player):GetWalkMaxSpeed()
- local run_speed = YaCharacterAPI.Instance(player):GetRunMaxSpeed()
- YaCharacterAPI.Instance(player):SetWalkMaxSpeed(8)
- YaCharacterAPI.Instance(player):SetRunMaxSpeed(8)
- local timer = YaTime:WaitFor(5)
- EventHelper.AddListener(timer, "TimeEvent", function ()
- YaCharacterAPI.Instance(player):SetWalkMaxSpeed(walk_speed)
- YaCharacterAPI.Instance(player):SetRunMaxSpeed(run_speed)
- end)
- end
- local function Tracer(player)
- print("Enabling Tracer by : ", player.EntityId)
- local walk_speed = YaCharacterAPI.Instance(player):GetWalkMaxSpeed()
- local run_speed = YaCharacterAPI.Instance(player):GetRunMaxSpeed()
- YaCharacterAPI.Instance(player):SetWalkMaxSpeed(100)
- YaCharacterAPI.Instance(player):SetRunMaxSpeed(100)
- local timer = YaTime:WaitFor(0.1)
- EventHelper.AddListener(timer, "TimeEvent", function ()
- YaCharacterAPI.Instance(player):SetWalkMaxSpeed(walk_speed)
- YaCharacterAPI.Instance(player):SetRunMaxSpeed(run_speed)
- end)
- end
- -- Ability assignment
- local PlayerNums = 0
- local AbilityTable = {}
- for i = 1, 6 do
- AbilityTable[i] = {}
- end
- AbilityTable[1][1] = "Mirage"
- AbilityTable[2][1] = "Octane"
- AbilityTable[3][1] = "Tracer"
- AbilityTable[4][1] = "Mirage"
- AbilityTable[5][1] = "Octane"
- AbilityTable[6][1] = "Tracer"
- local AssignArray = {}
- for i = 1, 6 do
- AssignArray[i] = i
- end
- local function Assign(avatar_ent)
- math.randomseed(os.time())
- ---@diagnostic disable-next-line: deprecated
- local arSize = table.getn(AssignArray)
- local rand = math.random(1, arSize)
- local assignPos = table.remove(AssignArray, rand)
- AbilityTable[assignPos][2] = avatar_ent.EntityId
- print("Assigned ability to player ", avatar_ent.EntityId, " with ", AbilityTable[assignPos][1])
- end
- -- Ability activating
- local OnCoolDownA = false
- local OnCoolDownB = false
- local OnCoolDownC = false
- local OnCoolDownD = false
- local OnCoolDownE = false
- local OnCoolDownF = false
- local function PlayerA(player, key)
- if key == 102 then
- print("Pressed F by ", player.EntityId)
- if not OnCoolDownA then
- for i = 1, 6 do
- if AbilityTable[i][2] == player.EntityId then
- local ability = AbilityTable[i][1]
- print("Ability of ", player.EntityId, "is ", ability)
- if ability == "Mirage" then
- Mirage(player)
- elseif ability == "Octane" then
- Octane(player)
- elseif ability == "Tracer" then
- Tracer(player)
- end
- OnCoolDownA = true
- local timer = YaTime:WaitFor(10)
- EventHelper.AddListener(timer, "TimeEvent", function ()
- OnCoolDownA = false
- end)
- end
- end
- end
- end
- end
- local function PlayerB(player, key)
- if key == 102 then
- print("Pressed F by ", player.EntityId)
- if not OnCoolDownB then
- for i = 1, 6 do
- if AbilityTable[i][2] == player.EntityId then
- local ability = AbilityTable[i][1]
- print("Ability of ", player.EntityId, "is ", ability)
- if ability == "Mirage" then
- Mirage(player)
- elseif ability == "Octane" then
- Octane(player)
- elseif ability == "Tracer" then
- Tracer(player)
- end
- OnCoolDownB = true
- local timer = YaTime:WaitFor(10)
- EventHelper.AddListener(timer, "TimeEvent", function ()
- OnCoolDownB = false
- end)
- end
- end
- end
- end
- end
- local function PlayerC(player, key)
- if key == 102 then
- print("Pressed F by ", player.EntityId)
- if not OnCoolDownC then
- for i = 1, 6 do
- if AbilityTable[i][2] == player.EntityId then
- local ability = AbilityTable[i][1]
- print("Ability of ", player.EntityId, "is ", ability)
- if ability == "Mirage" then
- Mirage(player)
- elseif ability == "Octane" then
- Octane(player)
- elseif ability == "Tracer" then
- Tracer(player)
- end
- OnCoolDownC = true
- local timer = YaTime:WaitFor(10)
- EventHelper.AddListener(timer, "TimeEvent", function ()
- OnCoolDownC = false
- end)
- end
- end
- end
- end
- end
- local function PlayerD(player, key)
- if key == 102 then
- print("Pressed F by ", player.EntityId)
- if not OnCoolDownD then
- for i = 1, 6 do
- if AbilityTable[i][2] == player.EntityId then
- local ability = AbilityTable[i][1]
- print("Ability of ", player.EntityId, "is ", ability)
- if ability == "Mirage" then
- Mirage(player)
- elseif ability == "Octane" then
- Octane(player)
- elseif ability == "Tracer" then
- Tracer(player)
- end
- OnCoolDownD = true
- local timer = YaTime:WaitFor(10)
- EventHelper.AddListener(timer, "TimeEvent", function ()
- OnCoolDownD = false
- end)
- end
- end
- end
- end
- end
- local function PlayerE(player, key)
- if key == 102 then
- print("Pressed F by ", player.EntityId)
- if not OnCoolDownE then
- for i = 1, 6 do
- if AbilityTable[i][2] == player.EntityId then
- local ability = AbilityTable[i][1]
- print("Ability of ", player.EntityId, "is ", ability)
- if ability == "Mirage" then
- Mirage(player)
- elseif ability == "Octane" then
- Octane(player)
- elseif ability == "Tracer" then
- Tracer(player)
- end
- OnCoolDownE = true
- local timer = YaTime:WaitFor(10)
- EventHelper.AddListener(timer, "TimeEvent", function ()
- OnCoolDownE = false
- end)
- end
- end
- end
- end
- end
- local function PlayerF(player, key)
- if key == 102 then
- print("Pressed F by ", player.EntityId)
- if not OnCoolDownF then
- for i = 1, 6 do
- if AbilityTable[i][2] == player.EntityId then
- local ability = AbilityTable[i][1]
- print("Ability of ", player.EntityId, "is ", ability)
- if ability == "Mirage" then
- Mirage(player)
- elseif ability == "Octane" then
- Octane(player)
- elseif ability == "Tracer" then
- Tracer(player)
- end
- OnCoolDownF = true
- local timer = YaTime:WaitFor(10)
- EventHelper.AddListener(timer, "TimeEvent", function ()
- OnCoolDownF = false
- end)
- end
- end
- end
- end
- end
- local function OnSpawned(playerID, player, pointEntity)
- print("Player spawned")
- local spawnedPlayer = YaGame:GetPlayer(playerID)
- print(spawnedPlayer:GetName())
- local avatar = spawnedPlayer:GetAvatarEntity()
- Assign(avatar)
- print("Avatar : ", avatar.EntityId)
- PlayerNums = PlayerNums + 1
- if PlayerNums == 1 then
- YaInputAPI.OnKeyDown(avatar, PlayerA)
- elseif PlayerNums == 2 then
- YaInputAPI.OnKeyDown(avatar, PlayerB)
- elseif PlayerNums == 3 then
- YaInputAPI.OnKeyDown(avatar, PlayerC)
- elseif PlayerNums == 4 then
- YaInputAPI.OnKeyDown(avatar, PlayerD)
- elseif PlayerNums == 5 then
- YaInputAPI.OnKeyDown(avatar, PlayerE)
- elseif PlayerNums == 6 then
- YaInputAPI.OnKeyDown(avatar, PlayerF)
- end
- end
- local function OnJoined(playerID)
- local player = YaGame:GetPlayer(playerID)
- print("Player Joined")
- EventHelper.AddListener(player, "SpawnedEvent", OnSpawned)
- end
- -- Event Listeners
- EventHelper.AddListener(YaGame, "PlayerJoinedEvent", OnJoined)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement