I figgure il just post the code here so you can see sort of what i want.
Code: Select all
-- satelite_scan.lua
--
function gadget:GetInfo()
return {
name = "Satelite Scan",
desc = "Gives a satelite scan power to players",
author = "Code_Man",
date = "2014-1-3",
license = "Public domain",
layer = 1,
enabled = true
}
end
if (not gadgetHandler:IsSyncedCode()) then
return false
end
local timerTable = {}
local function scan(team)
--if (timerTable[team] < Spring.GetGameSeconds()) then
-- return false
--end
local unit = Spring.CreateUnit("scan_object", Game.mapSizeX / 2, 300, Game.mapSizeZ / 2, 0, team)
timerTable[team] = Spring.GetGameSeconds() + 60
GG.Delay.DelayCall(Spring.DestroyUnit, {unit}, 1000)
end
function gadget:RecvLuaMsg(msg, playerID)
local active, spectator, teamID = Spring.GetPlayerInfo(playerID)
--if (not spectator) and active then
scan(TeamID)
--end
end
function gadget:GameStart()
for _, team in ipairs(Spring.GetTeamList()) do
if (team ~= Spring.GetGaiaTeamID()) then
timerTable[team] = Spring.GetGameSeconds() + 60
end
end
end
function gadget:GameFrame(frame)
for _, team in ipairs(Spring.GetTeamList()) do
if (team ~= Spring.GetGaiaTeamID()) then
if(timerTable[team] >= Spring.GetGameSeconds()) then
Spring.SetTeamRulesParam(team, "SateliteScanTimer", timerTable[team] - Spring.GetGameSeconds())
end
end
end
end