[Таймер] Конец игры как настройть?

Заводишь таймер в стадии DOTA_GAMERULES_STATE_GAME_IN_PROGRESS

Сам таймер, например, такой:
Код:
Timers:CreateTimer(1200, function()
GameRules:SetGameWinner(DOTA_TEAM_BADGUYS)
end)
 
[quote author=Илья link=topic=528.msg2228#msg2228 date=1449416668]
Заводишь таймер в стадии DOTA_GAMERULES_STATE_GAME_IN_PROGRESS

Сам таймер, например, такой:
Код:
Timers:CreateTimer(1200, function()
GameRules:SetGameWinner(DOTA_TEAM_BADGUYS)
end)
[/quote]Что-то я не так сделал походу.
Я не разобрался с таймер я сделал как ты на подобии "Кодим функции: ...STATE_HERO_SELECTION или как задать конкретного персонажа"

Вот моё:

function OnGameRulesStateChange(keys)
local newState = GameRules:State_Get()
if newState == DOTA_GAMERULES_STATE_GAME_IN_PROGRESS then
Timer()
end
end


function Timer()
Timers:CreateTimer(1200, function()
GameRules:SetGameWinner(DOTA_TEAM_GOODGUYS)
end
 
Последнее редактирование модератором:
Ну, ты забыл "end)"

Должно быть так:
Код:
function OnGameRulesStateChange(keys)
  local newState = GameRules:State_Get()
  if newState == DOTA_GAMERULES_STATE_GAME_IN_PROGRESS then
    Timer()
  end
end


function Timer()
Timers:CreateTimer(1200, function()
GameRules:SetGameWinner(DOTA_TEAM_GOODGUYS)
end)

end

Но, где ты это все пишешь, в каком файле? Сдается мне, что не только в этом дело. Скинь содержимое всего файла, если оно не огроменное.
 
Последнее редактирование модератором:
[quote author=Илья link=topic=528.msg2230#msg2230 date=1449428701]
Ну, ты забыл "end)"

Должно быть так:
Код:
function OnGameRulesStateChange(keys)
  local newState = GameRules:State_Get()
  if newState == DOTA_GAMERULES_STATE_GAME_IN_PROGRESS then
    Timer()
  end
end


function Timer()
Timers:CreateTimer(1200, function()
GameRules:SetGameWinner(DOTA_TEAM_GOODGUYS)
end)

end

Но, где ты это все пишешь, в каком файле? Сдается мне, что не только в этом дело. Скинь содержимое всего файла, если оно не огроменное.
[/quote]В addon_game_mode.lua , или надо было в timers?
-- This is the entry-point to your game mode and should be used primarily to precache models/particles/sounds/etc

require('internal/util')
require('gamemode')

function Precache( context )
--[[
This function is used to precache resources/units/items/abilities that will be needed
for sure in your game and that will not be precached by hero selection. When a hero
is selected from the hero selection screen, the game will precache that hero's assets,
any equipped cosmetics, and perform the data-driven precaching defined in that hero's
precache{} block, as well as the precache{} block for any equipped abilities.

See GameMode:PostLoadPrecache() in gamemode.lua for more information
]]

DebugPrint("[BAREBONES] Performing pre-load precache")

-- Particles can be precached individually or by folder
-- It it likely that precaching a single particle system will precache all of its children, but this may not be guaranteed
PrecacheResource("particle", "particles/econ/generic/generic_aoe_explosion_sphere_1/generic_aoe_explosion_sphere_1.vpcf", context)
PrecacheResource("particle_folder", "particles/test_particle", context)

-- Models can also be precached by folder or individually
-- PrecacheModel should generally used over PrecacheResource for individual models
PrecacheResource("model_folder", "particles/heroes/antimage", context)
PrecacheResource("model", "particles/heroes/viper/viper.vmdl", context)
PrecacheModel("models/heroes/viper/viper.vmdl", context)

-- Sounds can precached here like anything else
PrecacheResource("soundfile", "soundevents/game_sounds_heroes/game_sounds_gyrocopter.vsndevts", context)

-- Entire items can be precached by name
-- Abilities can also be precached in this way despite the name
PrecacheItemByNameSync("example_ability", context)
PrecacheItemByNameSync("item_example_item", context)

-- Entire heroes (sound effects/voice/models/particles) can be precached with PrecacheUnitByNameSync
-- Custom units from npc_units_custom.txt can also have all of their abilities and precache{} blocks precached in this way
PrecacheUnitByNameSync("npc_dota_hero_ancient_apparition", context)
PrecacheUnitByNameSync("npc_dota_hero_enigma", context)
end

-- Create the game mode when we activate
function Activate()
GameRules.GameMode = GameMode()
GameRules.GameMode:InitGameMode()
end

function OnGameRulesStateChange(keys)
local newState = GameRules:State_Get()
if newState == DOTA_GAMERULES_STATE_GAME_IN_PROGRESS then
Timer()
end
end


function Timer()
Timers:CreateTimer(1200, function()
GameRules:SetGameWinner(DOTA_TEAM_GOODGUYS)
end
 
Последнее редактирование модератором:
Зайди в gamemode, который подключаешь. И туда уже пихай это:


Код:
function GameMode:InitGameMode()
ListenToGameEvent('game_rules_state_change', Dynamic_Wrap(GameMode, 'OnGameRulesStateChange'), self)
end

function GameMode:OnGameRulesStateChange(keys)
  local newState = GameRules:State_Get()
  if newState == DOTA_GAMERULES_STATE_GAME_IN_PROGRESS then
    GameMode:Timer()
  end
end


function GameMode:Timer()
Timers:CreateTimer(1200, function()
GameRules:SetGameWinner(DOTA_TEAM_GOODGUYS)
end)

end


И совет: для тестов не ставь 1200, ставь минуту - две: 60-120
 
На будущее, используй пожалуйста блок "код" для пометки участков кода: так проще понимать читающему.

И снова читай тот урок.
 
Последнее редактирование модератором:
[quote author=Илья link=topic=528.msg2233#msg2233 date=1449434862]
На будущее, используй пожалуйста блок "код" для пометки участков кода: так проще понимать читающему.

И снова читай тот урок.
[/quote]Сяб.
 
Последнее редактирование модератором:
Реклама: