--corkgun based on old hostmod's canon command with params per entry --written by Lighto - v2 local corkgunargets = {['example'] = {type = 0, mes = '', smes = '', prec = false}} local corkgunaddname,corkgunremname, corkgunaim, corkgunfire,namefilter, hooks,customtime = nil,nil, nil, nil,nil, {"ThinkFrame","VoteThinker","IntermissionThinker"}, 0 function corkgunaddname(p, ...) if not p then CONS_Printf(p or server, "\x86 WARNING \x80 you or the server are invalid, wtf") return end if not {...} or not ... then CONS_Printf(p,"parameters are:\x83 \n name\x80 \x86 obligaroty\x80 and must be the \x83 first\x80 \n \x83 -b\x80 bans instead of kicking\n \x83 -m\x80 custom message for the victim\n \x83 -s\x80 message that displays for everyone else\n \x83 -p\x80 name must match precisely else it filters to similar names\n \x83 -d\x80 prints the command in the console\n") return end local command, tname,tmes, tsmes, ttype, tprec = '','Sonic','','',0,false for _, k in pairs({...}) do if not _ or not k or (k and (type(k) ~= "string" or k == "" or k == " ")) then continue end k = string.lower(k) if _ == 1 then tname = k continue end command = $ + k if _ < #{...} then command = $ + ' ' end end if string.find(command,'%-b') then ttype = 1 end if string.find(command,'%-m') then tmes = string.sub(command,string.find(command,'%-m[%a%s%d]+')) tmes = string.sub(tmes, 3, string.len(tmes)) end if string.find(command,'%-s') then tsmes = string.sub(command,string.find(command,'%-s[%a%s%d]+')) tsmes = string.sub(tsmes, 3, string.len(tsmes)) end if string.find(command,'%-p') then tprec = true end if string.find(command,'%-d') then CONS_Printf(p,string.format('name:%s type:%d message:%s shame:%s precise:%s',tname,ttype,tmes,tsmes,tostring(tprec))) end --tprec = true corkgunargets[tname] = {type = ttype, mes = tmes, smes = tsmes, prec = tprec} CONS_Printf(p,"\x81 fang\x80 :name added to the list, boss!") end function corkgunremname(p, ...) if not p then CONS_Printf(p or server, "\x86 WARNING \x80 you or the server are invalid, wtf") return end if not corkgunargets or (corkgunargets and #corkgunargets == 1) then CONS_Printf(p, "name list is not valid or no names were added yet") return end if not {...} or not ... then CONS_Printf(p," or type \x83 listnames\x80 to get a list of the names") return end local unmatches, matches, purge = '','', false for _, k in pairs({...}) do if (_ == nil or k == nil) then continue end k = string.lower(k) if k == "listnames" then local namelist = '' for i, j in pairs(corkgunargets) do if (i == nil or j == nil) then continue end if i == "example" then continue end namelist = $ + i + '\n' end CONS_Printf(p,"the names in the list are: \n"..namelist) return elseif k ~= "purge" then if not corkgunargets[k] then unmatches = $ + k +" \n" else matches = $ + k +" \n" corkgunargets[k] = nil end end if k == "purge" then purge = true for i, j in pairs(corkgunargets) do if (i == nil or j == nil) then continue end corkgunargets[i] = nil end end end if not purge then CONS_Printf(p,"\x81 fang\x80 : general report boss! \n\x83 names removed\x80 : \n"..matches.." \n\x86 names i couldn't find\x80 : \n"..unmatches) else CONS_Printf(p,"\x81 fang\x80 : list cleared boss!") end end function namefilter(name, compare) --return name == compare --true if string.find(name,compare) then return true end return false end function corkgunaim(name) if not corkgunargets or not name or type(name) ~= "string" then return end for k, v in pairs(corkgunargets) do if (k == nil or v == nil) then continue end if (k == name and v.prec == true) or (namefilter(name, k) and v.prec == false) then corkgunfire(name, v.mes, v.smes, v.type) end end end function corkgunfire(name, mes, smes, btype) if btype == 0 then --print('kick "'+name+'" '+mes) COM_BufInsertText(server,'kick '+name+' '+mes) elseif btype == 1 then --print('ban "'+name+'" '+mes) COM_BufInsertText(server,'ban '+name+' '+mes) end if smes and smes ~= "" then COM_BufInsertText(server,'csay '+smes) end end for i = 1, #hooks do addHook(hooks[i],do if not((consoleplayer == server or isdedicatedserver) and customtime % (10*TICRATE) == 0) then return end customtime = $ + 1 for p in players.iterate do if not(p and p.valid and p.name) or p.name =="" or IsPlayerAdmin(p) or p == server then continue end corkgunaim(string.lower(p.name)) end customtime = $ % (11*TICRATE) end) end COM_AddCommand("cg_addname",corkgunaddname,COM_ADMIN) COM_AddCommand("cg_remname",corkgunremname,COM_ADMIN) addHook("NetVars",function(net) corkgunargets = net($) end)