1
0
mirror of https://github.com/metrostroi-repo/MetrostroiAddon.git synced 2026-05-02 00:42:29 +00:00

#263 new arg metrostroi_wire

This commit is contained in:
Hellss
2021-07-14 21:40:28 +03:00
parent 4a2786967d
commit 066ce7ecf2
2 changed files with 13 additions and 9 deletions

View File

@@ -792,7 +792,10 @@ end]]
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
function ENT:LeaderReadTrainWire(id) function ENT:LeaderReadTrainWire(id)
if self.TrainWireOverrides[id] then return self.TrainWireOverrides[id] end if self.TrainWireOverrides[id] then return self.TrainWireOverrides[id] end
if self.TrainWireOutside[id] then return self.TrainWireOutside[id] end local w = self.TrainWireOutside[id]
if w then
if isnumber(w) then return w elseif (self.TrainWireTurbostroi[tonumber(w)] or 0) > 0 then return 1 end
end
return (self.TrainWireTurbostroi[id] or 0)+(self.TrainWireWriters[id] or 0) return (self.TrainWireTurbostroi[id] or 0)+(self.TrainWireWriters[id] or 0)
end end

View File

@@ -321,7 +321,7 @@ concommand.Add("metrostroi_fail", function(ply, _, args)
if train then if train then
if IsValid(ply) then if IsValid(ply) then
ply:PrintMessage(HUD_PRINTCONSOLE,"Generating random failure in your train!") ply:PrintMessage(HUD_PRINTCONSOLE,"Generating random failure in your train!")
print("Player "..tostring(ply).." generated random failure in train "..train:EntIndex()) print(tostring(ply).." generated random failure in train "..train:EntIndex())
else else
print("Generating random failure in train "..train:EntIndex()) print("Generating random failure in train "..train:EntIndex())
end end
@@ -355,7 +355,7 @@ concommand.Add("metrostroi_fail_reset", function(ply, _, args)
if #trainList > 0 then if #trainList > 0 then
if IsValid(ply) then if IsValid(ply) then
ply:PrintMessage(HUD_PRINTCONSOLE,"Reset all failures in your train!") ply:PrintMessage(HUD_PRINTCONSOLE,"Reset all failures in your train!")
print("Player "..tostring(ply).." reset all failures in train "..trainList[1]:EntIndex()) print(tostring(ply).." reset all failures in train "..trainList[1]:EntIndex())
else else
print("Reset all failures in train "..trainList[1]:EntIndex()) print("Reset all failures in train "..trainList[1]:EntIndex())
end end
@@ -390,14 +390,15 @@ concommand.Add("metrostroi_wire", function(ply, _, args)
if train then if train then
if IsValid(ply) then if IsValid(ply) then
args[1] = tonumber(args[1]) args[1] = tonumber(args[1])
if not args[1] then ply:PrintMessage(HUD_PRINTCONSOLE,"Argument must be a number") return end if not args[1] then ply:PrintMessage(HUD_PRINTCONSOLE,"1st argument must be a number") return end
ply:PrintMessage(HUD_PRINTCONSOLE,"sets outside power in train wire"..args[1].."!") if args[2] and not tonumber(args[2]) then ply:PrintMessage(HUD_PRINTCONSOLE,"2nd argument must be a number") return end
print("Player "..tostring(ply).." sets outside power in train "..args[1].." wire failure in train "..train:EntIndex()) ply:PrintMessage(HUD_PRINTCONSOLE,"sets outside power in train wire"..args[1]..(args[2] and "(from "..args[2].." wire)" or "").."!")
print(tostring(ply).." sets outside power in train "..args[1].." wire"..(args[2] and "(from "..args[2].." wire)" or "").." failure in train "..train:EntIndex())
else else
print("sets outside power in train wire "..train:EntIndex()) print("sets outside power in train wire "..train:EntIndex())
end end
--if train.WriteTrainWire then train:WriteTrainWire(args[1],1) end --if train.WriteTrainWire then train:WriteTrainWire(args[1],1) end
train.TrainWireOutside[args[1]] = 1 train.TrainWireOutside[args[1]] = args[2] and args[2] or 1
--if train.WriteTrainWire then train:WriteTrainWire(args[1],1) end --if train.WriteTrainWire then train:WriteTrainWire(args[1],1) end
else else
if IsValid(ply) then if IsValid(ply) then
@@ -427,7 +428,7 @@ concommand.Add("metrostroi_wire_reset", function(ply, _, args)
if #trainList > 0 then if #trainList > 0 then
if IsValid(ply) then if IsValid(ply) then
ply:PrintMessage(HUD_PRINTCONSOLE,"reset wire outside power in train!") ply:PrintMessage(HUD_PRINTCONSOLE,"reset wire outside power in train!")
print("Player "..tostring(ply).." reset outside power in train ") print(tostring(ply).." reset outside power in train ")
else else
print("Reset outside power in trains ") print("Reset outside power in trains ")
end end
@@ -453,7 +454,7 @@ concommand.Add("metrostroi_can", function(ply, _, args)
if tonumber(args[4]) then value = tonumber(args[4]) end if tonumber(args[4]) then value = tonumber(args[4]) end
local srcid = tonumber(args[5]) local srcid = tonumber(args[5])
ply:PrintMessage(HUD_PRINTCONSOLE,"Hacking CAN!") ply:PrintMessage(HUD_PRINTCONSOLE,"Hacking CAN!")
print(Format("Player %s hack CAN(%s->%s:%s %s=%s)",ply,srcid,system,id,name,value)) print(Format("%s hack CAN(%s->%s:%s %s=%s)",ply,srcid,system,id,name,value))
train:CANWrite("Hacker",srcid or train:GetWagonNumber(),system,id,name,value) train:CANWrite("Hacker",srcid or train:GetWagonNumber(),system,id,name,value)
end) end)