Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- util.AddNetworkString("wire_expression2_printColorAll")
- local print_delay = CreateConVar( "wire_expression2_printColorAll_delay", 0.1, {FCVAR_ARCHIVE} )
- local printColor_types = {
- number = tostring,
- string = tostring,
- Vector = function(v) return Color(v[1],v[2],v[3]) end,
- table = function(tbl)
- for i,v in pairs(tbl) do
- if type(i) ~= "number" then return "" end
- if type(v) ~= "number" then return "" end
- if i < 1 or i > 4 then return "" end
- end
- return Color(tbl[1] or 0, tbl[2] or 0,tbl[3] or 0,tbl[4])
- end,
- Player = function(e) return IsValid(e) and e:IsPlayer() and e or "" end,
- }
- local function printColorAllArray(chip, ply, arr)
- if (not IsValid(ply)) then return; end
- local send_array = {}
- for i,tp in ipairs_map(arr,type) do
- if printColor_types[tp] then
- send_array[i] = printColor_types[tp](arr[i])
- else
- send_array[i] = ""
- end
- end
- send_array.chip = chip
- send_array.sender = ply
- --//datastream12.StreamToClients(player.GetAll( ), "wire_expression2_printColorAll", send_array)
- net.Start("wire_expression2_printColorAll")
- net.WriteEntity(chip)
- net.WriteTable(send_array)
- net.Broadcast()
- end
- __e2setcost(5)
- e2function void printColorAll(array arr)
- local ply = self.player
- local lastprint = ply.lastPrint or 0
- if lastprint < CurTime( ) then
- ply.lastPrint = CurTime( ) + print_delay:GetInt()
- printColorAllArray(self.entity, ply, arr)
- end
- end
- __e2setcost(5)
- e2function void printColorAll(...)
- local ply = self.player
- local lastprint = ply.lastPrint or 0
- if lastprint < CurTime( ) then
- ply.lastPrint = CurTime( ) + print_delay:GetInt()
- local arr = { ... }
- printColorAllArray(self.entity, ply, arr)
- end
- end
- __e2setcost(2)
- e2function number printColorAllReady()
- local ply = self.player
- if ply.lastPrint < CurTime( ) then
- return 1
- else
- return 0
- end
- end
- e2function number printColorAllDelay()
- return print_delay:GetInt()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement