sellWarningLabel = sellTab:createLabel(vec2(200, size.y - 30), "Warning! You will not get refunds for crews or turrets!"%_t, 15)
sellWarningLabel = sellTab:createLabel(vec2(200, size.y - 30), "Warning! You will not get refunds for crews or turrets!"%_t, 15)
sellWarningLabel.color = ColorRGB(1, 1, 0)
sellWarningLabel.color = ColorRGB(1, 1, 0)
-- create a second tab
-- create a second tab
local salvageTab = tabbedWindow:createTab("Salvaging /*UI Tab title*/"%_t, "", "Buy a salvaging license"%_t)
local salvageTab = tabbedWindow:createTab("Salvaging /*UI Tab title*/"%_t, "", "Buy a salvaging license"%_t)
size = salvageTab.size -- not really required, all tabs have the same size
size = salvageTab.size -- not really required, all tabs have the same size
local textField = salvageTab:createTextField(Rect(0, 0, size.x, 50), "You can buy a temporary salvaging license here. This license makes it legal to damage or mine wreckages in this sector."%_t)
local textField = salvageTab:createTextField(Rect(0, 0, size.x, 50), "You can buy a temporary salvaging license here. This license makes it legal to damage or mine wreckages in this sector."%_t)
Sector():broadcastChatMessage(station.title, 0, "Get a salvaging license now and try your luck with the wreckages!"%_t)
Sector():broadcastChatMessage(station.title, 0, "Get a salvaging license now and try your luck with the wreckages!"%_t)
newsBroadcastCounter = 0
newsBroadcastCounter = 0
end
end
for factionIndex, actions in pairs(illegalActions) do
-- counter for update, this is only executed once per second to save performance.
for playerIndex, actions in pairs(illegalActions) do
actions = actions - 1
actions = actions - 1
if actions <= 0 then
if actions <= 0 then
illegalActions[factionIndex] = nil
illegalActions[playerIndex] = nil
else
else
illegalActions[factionIndex] = actions
illegalActions[playerIndex] = actions
end
end
end
end
for factionIndex, time in pairs(licenses) do
for playerIndex, time in pairs(licenses) do
time = time - timeStep
time = time - timeStep
local faction = Faction(factionIndex)
if not faction then goto continue end
local here = false
if faction.isAlliance then
faction = Alliance(factionIndex)
elseif faction.isPlayer then
faction = Player(factionIndex)
local px, py = faction:getSectorCoordinates()
local sx, sy = Sector():getCoordinates()
here = (px == sx and py == sy)
end
local doubleSend = false
local msg = nil
-- warn player if his time is running out
-- warn player if his time is running out
if time + 1 > 10 and time <= 10 then
if time + 1 > 10 and time <= 10 then
if here then
Player(playerIndex):sendChatMessage(station.title, 0, "Your salvaging license will run out in 10 seconds."%_t);
msg = "Your salvaging license will run out in 10 seconds."%_t
Player(playerIndex):sendChatMessage(station.title, 2, "Your salvaging license will run out in 10 seconds."%_t);
else
msg = "Your salvaging license in %s will run out in 10 seconds."%_t
end
doubleSend = true
end
end
if time + 1 > 20 and time <= 20 then
if time + 1 > 20 and time <= 20 then
if here then
Player(playerIndex):sendChatMessage(station.title, 0, "Your salvaging license will run out in 20 seconds."%_t);
msg = "Your salvaging license will run out in 20 seconds."%_t
Player(playerIndex):sendChatMessage(station.title, 2, "Your salvaging license will run out in 20 seconds."%_t);
else
msg = "Your salvaging license in %s will run out in 20 seconds."%_t
end
doubleSend = true
end
end
if time + 1 > 30 and time <= 30 then
if time + 1 > 30 and time <= 30 then
if here then
Player(playerIndex):sendChatMessage(station.title, 0, "Your salvaging license will run out in 30 seconds. Renew it and save yourself some trouble!"%_t);
msg = "Your salvaging license will run out in 30 seconds. Renew it and save yourself some trouble!"%_t
else
msg = "Your salvaging license in %s will run out in 30 seconds. Renew it and save yourself some trouble!"%_t
end
end
end
if time + 1 > 60 and time <= 60 then
if time + 1 > 60 and time <= 60 then
if here then
Player(playerIndex):sendChatMessage(station.title, 0, "Your salvaging license will run out in 60 seconds. Renew it NOW and save yourself some trouble!"%_t);
msg = "Your salvaging license will run out in 60 seconds. Renew it NOW and save yourself some trouble!"%_t
else
msg = "Your salvaging license in %s will run out in 60 seconds. Renew it NOW and save yourself some trouble!"%_t
end
end
end
if time + 1 > 120 and time <= 120 then
if time + 1 > 120 and time <= 120 then
if here then
Player(playerIndex):sendChatMessage(station.title, 0, "Your salvaging license will run out in 2 minutes. Renew it immediately and save yourself some trouble!"%_t);
msg = "Your salvaging license will run out in 2 minutes. Renew it immediately and save yourself some trouble!"%_t
else
msg = "Your salvaging license in %s will run out in 2 minutes. Renew it immediately and save yourself some trouble!"%_t
end
end
end
if time < 0 then
if time < 0 then
licenses[factionIndex] = nil
licenses[playerIndex] = nil
if here then
Player(playerIndex):sendChatMessage(station.title, 0, "Your salvaging license expired. You may no longer salvage in this area."%_t);
msg = "Your salvaging license expired. You may no longer salvage in this area."%_t
else
msg = "Your salvaging license in %s expired. You may no longer salvage in this area."%_t
function Scrapyard.unallowedDamaging(shooter, faction, damage)
function Scrapyard.unallowedDamaging(shooter, faction, damage)
local pilots = {}
local pilots = {}
if faction.isAlliance then
if faction.isAlliance then
for _, playerIndex in pairs({shooter:getPilotIndices()}) do
for _, playerIndex in pairs({shooter:getPilotIndices()}) do
local player = Player(playerIndex)
local player = Player(playerIndex)
if player then
if player then
table.insert(pilots, player)
table.insert(pilots, player)
end
end
end
end
elseif faction.isPlayer then
elseif faction.isPlayer then
table.insert(pilots, Player(faction.index))
table.insert(pilots, Player(faction.index))
end
end
local station = Entity()
local station = Entity()
local actions = illegalActions[faction.index]
local actions = illegalActions[faction.index]
if actions == nil then
if actions == nil then
actions = 0
actions = 0
end
end
newActions = actions + damage
newActions = actions + damage
for _, player in pairs(pilots) do
for _, player in pairs(pilots) do
if actions < 10 and newActions >= 10 then
if actions < 10 and newActions >= 10 then
player:sendChatMessage(station.title, 0, "Salvaging or damaging wreckages in this sector is illegal. Please buy a salvaging license."%_t);
player:sendChatMessage(station.title, 0, "Salvaging or damaging wreckages in this sector is illegal. Please buy a salvaging license."%_t);
player:sendChatMessage(station.title, 2, "You need a salvaging license for this sector."%_t);
player:sendChatMessage(station.title, 2, "You need a salvaging license for this sector."%_t);
end
end
if actions < 200 and newActions >= 200 then
if actions < 200 and newActions >= 200 then
player:sendChatMessage(station.title, 0, "Salvaging wreckages in this sector is forbidden. Please buy a salvaging license."%_t);
player:sendChatMessage(station.title, 0, "Salvaging wreckages in this sector is forbidden. Please buy a salvaging license."%_t);
player:sendChatMessage(station.title, 2, "You need a salvaging license for this sector."%_t);
player:sendChatMessage(station.title, 2, "You need a salvaging license for this sector."%_t);
end
end
if actions < 500 and newActions >= 500 then
if actions < 500 and newActions >= 500 then
player:sendChatMessage(station.title, 0, "Wreckages in this sector are the property of %s. Please buy a salvaging license."%_t, Faction().name);
player:sendChatMessage(station.title, 0, "Wreckages in this sector are the property of %s. Please buy a salvaging license."%_t, Faction().name);
player:sendChatMessage(station.title, 2, "You need a salvaging license for this sector."%_t);
player:sendChatMessage(station.title, 2, "You need a salvaging license for this sector."%_t);
end
end
if actions < 1000 and newActions >= 1000 then
if actions < 1000 and newActions >= 1000 then
player:sendChatMessage(station.title, 0, "Illegal salvaging will be punished by destruction. Buy a salvaging license or there will be consequences."%_t);
player:sendChatMessage(station.title, 0, "Illegal salvaging will be punished by destruction. Buy a salvaging license or there will be consequences."%_t);
player:sendChatMessage(station.title, 2, "You need a salvaging license for this sector."%_t);
player:sendChatMessage(station.title, 2, "You need a salvaging license for this sector."%_t);
end
end
if actions < 1500 and newActions >= 1500 then
if actions < 1500 and newActions >= 1500 then
player:sendChatMessage(station.title, 0, "This is your last warning. If you do not stop salvaging without a license, you will be destroyed."%_t);
player:sendChatMessage(station.title, 0, "This is your last warning. If you do not stop salvaging without a license, you will be destroyed."%_t);
player:sendChatMessage(station.title, 2, "You need a salvaging license for this sector."%_t);
player:sendChatMessage(station.title, 2, "You need a salvaging license for this sector."%_t);
end
end
if actions < 2000 and newActions >= 2000 then
if actions < 2000 and newActions >= 2000 then
player:sendChatMessage(station.title, 0, "You have been warned. You will be considered an enemy of %s if you do not stop your illegal activities."%_t, Faction().name);
player:sendChatMessage(station.title, 0, "You have been warned. You will be considered an enemy of %s if you do not stop your illegal activities."%_t, Faction().name);
player:sendChatMessage(station.title, 2, "You need a salvaging license for this sector."%_t);
player:sendChatMessage(station.title, 2, "You need a salvaging license for this sector."%_t);
if not pcall(require, "mods/ScrapyardPlus/scripts/entity/merchants/scrapyard") then print("Failed to load ScrapyardPlus") end -- DNightmare/ScrapyardPlus END
if not pcall(require, 'mods.MoveUI.scripts.entity.merchants.scrapyard') then print('Mod: MoveUI, failed to extend scrapyard.lua!') end