Ulysses

Ulysses Stuff => Releases => Topic started by: Boxama on February 23, 2014, 10:20:55 AM

Title: Murder ULX commands
Post by: Boxama on February 23, 2014, 10:20:55 AM
I made a few ULX commands for use specifically with the Murder gamemode.
It includes several that I thought useful for my community's server:

The commands should appear under the section named "Murder" in the xgui by default. You can change the name of the category in the config inside the file.

You can download the addon at my GitHub repository (http://github.com/boxama/addons) or from the attached zip file.
Installation is as simple as any other addon - drag and drop into the addons folder.

I hope some of you find this useful.
Title: Re: Murder ULX commands
Post by: pants on February 23, 2014, 12:10:18 PM
woah, dude, is there anyway I could get the slaynr that bans on leave working with TTT? that would be awesome.
Title: Re: Murder ULX commands
Post by: Cobalt on February 23, 2014, 03:02:07 PM
woah, dude, is there anyway I could get the slaynr that bans on leave working with TTT? that would be awesome.
hook.Add( "PlayerDisconnected", "BanOnLeave", function( ply )
if ply:GetPData( "whatever the value is" ) then
--ban
end
end )
Title: Re: Murder ULX commands
Post by: Boxama on February 25, 2014, 09:25:57 AM
woah, dude, is there anyway I could get the slaynr that bans on leave working with TTT? that would be awesome.
Code: [Select]
if SERVER then
local banmins = 200
local culumativeban = true

hook.Add( "PlayerDisconnected", "BanThemSlayEvaders", function( ply )

local slays = tonumber( ply:GetPData( "slaynr_slays" ) ) or 0

if slays > 0 then
local reason, mins = "Attempting to evade "..slays.." autoslays.", ( culumativeban and slays*banmins or banmins )
ULib.kickban( ply, mins, reason )
ulx.fancyLogAdmin( nil, false, "Automatically banned #T for #i minutes (#s) ", ply, mins, reason )
end

end )
end
Drop this at the bottom of addons/Trouble In Terrorist Town ULX Commands/lua/ulx/modules/sh/ttt_admin.lua
Assuming you're using Bender180's ULX TTT commands.
Title: Re: Murder ULX commands
Post by: pants on February 25, 2014, 07:40:52 PM
Sweet thanks, that worked almost perfect! console just randomly spurts out this error
[ERROR] addons/ulx/lua/ulx/modules/sh/ttt_admin.lua:14: '=' expected near 'local'
  1. unknown - addons/ulx/lua/ulx/modules/sh/ttt_admin.lua:0


Line 14&15
local CATEGORY_NAME  = "TTT Admin"
local gamemode_error = "The current gamemode is not trouble in terrorest town"

any ideas on why it'd do that?
Title: Re: Murder ULX commands
Post by: Boxama on February 26, 2014, 08:46:53 AM
Are you sure you put it at the end of the file? It works perfectly when I try it myself.
Title: Re: Murder ULX commands
Post by: pants on February 26, 2014, 01:49:13 PM
Yeah I put it at the very end
It works just fine too just randomly spits out that = sign lua error notifications. It isn't too big of a deal just obnoxious haha
I had to delete some of the code to make it fit in the post
Code: [Select]
a--[=[-------------------------------------------------------------------------------------------
?                              Trouble in Terrorist Town Commands                              ?
?                                   By: Skillz and Bender180                                   ?
?                              ?????????????????????????????????                               ?
?                              ? ??? ??? ?? ??? ??? ?? ??? ??? ?                               ?
?                              ??? ? ? ?????? ? ? ?????? ? ? ???                               ?
???????????????????????????????????? ?????????? ?????????? ?????????????????????????????????????
???????????????????????????????????? ?????????? ?????????? ?????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????????????????????
?                  All code included is completely original or extracted                       ?
?            from the base ttt files that are provided with the ttt gamemode.                  ?
?                                                                                              ?
---------------------------------------------------------------------------------------------]=]
local CATEGORY_NAME  = "TTT Admin"
local gamemode_error = "The current gamemode is not trouble in terrorest town"



--[Ulx Completes]------------------------------------------------------------------------------
ulx.target_role = {}
function updateRoles()
table.Empty( ulx.target_role )
   
    table.insert(ulx.target_role,"traitor")
    table.insert(ulx.target_role,"detective")
    table.insert(ulx.target_role,"innocent")
end
hook.Add( ULib.HOOK_UCLCHANGED, "ULXRoleNamesUpdate", updateRoles )
updateRoles()
--[End]----------------------------------------------------------------------------------------



--[Global Helper Functions][Used by more than one command.]------------------------------------
--[[send_messages][Sends messages to player(s)]
@param  {[PlayerObject]} v       [The player(s) to send the message to.]
@param  {[String]}       message [The message that will be sent.]
--]]
function send_messages(v, message)
if type(v) == "Players" then
v:ChatPrint(message)
elseif type(v) == "table" then
for i=1, #v do
v[i]:ChatPrint(message)
end
end
end

--[[corpse_find][Finds the corpse of a given player.]
@param  {[PlayerObject]} v       [The player that to find the corpse for.]
--]]
function corpse_find(v)
for _, ent in pairs( ents.FindByClass( "prop_ragdoll" )) do
if ent.uqid == v:UniqueID() and IsValid(ent) then
return ent or false
end
end
end

--[[corpse_remove][removes the corpse given.]
@param  {[Ragdoll]} corpse [The corpse to be removed.]
--]]
function corpse_remove(corpse)
CORPSE.SetFound(corpse, false)
if string.find(corpse:GetModel(), "zm_", 6, true) then
corpse:Remove()
elseif corpse.player_ragdoll then
corpse:Remove()
end
end

--[[corpse_identify][identifies the given corpse.]
@param  {[Ragdoll]} corpse [The corpse to be identified.]
--]]
function corpse_identify(corpse)
if corpse then
local ply = player.GetByUniqueID(corpse.uqid)
ply:SetNWBool("body_found", true)
CORPSE.SetFound(corpse, true)
end
end
--[End]----------------------------------------------------------------------------------------




--[Force role]---------------------------------------------------------------------------------
--[[ulx.force][Forces <target(s)> to become a specified role.]
@param  {[PlayerObject]} calling_ply   [The player who used the command.]
@param  {[PlayerObject]} target_plys   [The player(s) who will have the effects of the command applied to them.]
@param  {[Number]}       target_role   [The role that target player(s) will have there role set to.]
@param  {[Boolean]}      should_silent [Hidden, determines weather the output will be silent or not.]
--]]
function ulx.slaynr( calling_ply, target_ply, num_slay, should_slaynr )
if not GetConVarString("gamemode") == "terrortown" then ULib.tsayError( calling_ply, gamemode_error, true ) else
local affected_plys = {}
local slays_left = tonumber(target_ply:GetPData("slaynr_slays")) or 0
local current_slay
local new_slay
   

if ulx.getExclusive( target_ply, calling_ply ) then
ULib.tsayError( calling_ply, ulx.getExclusive( target_ply, calling_ply ), true )
elseif num_slay < 0 then
ULib.tsayError( calling_ply, "Invalid integer:\"" .. num_slay .. "\" specified.", true )
else
current_slay = tonumber(target_ply:GetPData("slaynr_slays")) or 0
if not should_slaynr then
                new_slay = current_slay + num_slay 
            else
                new_slay = current_slay - num_slay
            end

            --local slay_reason = reason
            --if slay_reason == "reason" then
            -- slay_reason = false
            --end

if new_slay > 0 then
                target_ply:SetPData("slaynr_slays", new_slay)
                --target_ply:SetPData("slaynr_reason", slay_reason)
            else
target_ply:RemovePData("slaynr_slays")
                --target_ply:RemovePData("slaynr_reason")   
            end

    local slays_left = tonumber(target_ply:GetPData("slaynr_slays"))  or 0
local slays_removed = ( current_slay - slays_left ) or 0

if slays_removed==0 then
chat_message = ("#T will not be slain next round.")
elseif slays_removed > 0 then
chat_message = ("#A removed ".. slays_removed .." round(s) of slaying from #T.")
elseif slays_left == 1 then
chat_message = ("#A will slay #T next round.")
elseif slays_left > 1 then
chat_message = ("#A will slay #T for the next ".. tostring(slays_left) .." rounds.")
end
ulx.fancyLogAdmin( calling_ply, chat_message, target_ply, reason )
end
end
end
local slaynr = ulx.command( CATEGORY_NAME, "ulx slaynr", ulx.slaynr, "!slaynr" )
slaynr:addParam{ type=ULib.cmds.PlayerArg }
slaynr:addParam{ type=ULib.cmds.NumArg, default=1, hint="rounds", ULib.cmds.optional, ULib.cmds.round }
--slaynr:addParam{ type=ULib.cmds.StringArg, hint="reason",  ULib.cmds.optional}
slaynr:addParam{ type=ULib.cmds.BoolArg, invisible=true }
slaynr:defaultAccess( ULib.ACCESS_ADMIN )
slaynr:help( "Slays target(s) for a number of rounds" )
slaynr:setOpposite( "ulx rslaynr", {_, _, _, true}, "!rslaynr" )
--[Helper Functions]---------------------------------------------------------------------------
hook.Add("TTTBeginRound", "SlayPlayersNextRound", function()
local affected_plys = {}

for _,v in pairs(player.GetAll()) do
local slays_left = tonumber(v:GetPData("slaynr_slays")) or 0
       
if v:Alive() and slays_left > 0 then
local slays_left=slays_left -1

if slays_left == 0 then
                v:RemovePData("slaynr_slays")
                v:RemovePData("slaynr_reason")
else
                v:SetPData("slaynr_slays", slays_left)
            end

v:Kill()
table.insert( affected_plys, v )
local corpse = corpse_find(v)
if corpse then
corpse_identify(corpse)
corpse_remove(corpse)
end
end
end

local slay_message
for i=1, #affected_plys do
local v = affected_plys[ i ]
local string_inbetween

if i > 1 and #affected_plys == i then
string_inbetween=" and "
elseif i > 1 then
string_inbetween=", "
end

string_inbetween = string_inbetween or ""
slay_message = ( ( slay_message or "") .. string_inbetween )
slay_message = ( ( slay_message or "") .. v:Nick() )
end

local slay_message_context
if #affected_plys == 1 then slay_message_context ="was" else slay_message_context ="were" end
if #affected_plys ~= 0 then
ULib.tsay(_, slay_message .. " ".. slay_message_context .." slain.")
end
end)

hook.Add("PlayerSpawn", "Inform" , function(ply)
local slays_left = tonumber(ply:GetPData("slaynr_slays")) or 0
local slay_reason = false
       
if ply:Alive() and slays_left > 0 then
local chat_message = ""

if slays_left > 0 then
chat_message = (chat_message .. "You will be slain this round.")
end
if slays_left > 1 then
chat_message = (chat_message .. " and ".. (slays_left - 1) .." round(s) after the current round")
end
if slay_reason then
chat_message = (chat_message .. " for \"".. slays_reason .."\".")
else
chat_message = (chat_message .. ".")
end
ply:ChatPrint(chat_message)
end
end)
--[End]----------------------------------------------------------------------------------------
------------------------------ Next Round  ------------------------------
ulx.next_round = {}
local function updateNextround()
table.Empty( ulx.next_round ) -- Don't reassign so we don't lose our refs
   
    table.insert(ulx.next_round,"traitor") -- Add "traitor" to the table.
    table.insert(ulx.next_round,"detective") -- Add "detective" to the table.
    table.insert(ulx.next_round,"unmark") -- Add "unmark" to the table.

end
hook.Add( ULib.HOOK_UCLCHANGED, "ULXNextRoundUpdate", updateNextround )
updateNextround() -- Init


local PlysMarkedForTraitor = {}
local PlysMarkedForDetective = {}
function ulx.nextround( calling_ply, target_plys, next_round )
    local affected_plys = {}
local unaffected_plys = {}
    for i=1, #target_plys do
        local v = target_plys[ i ]
        local ID = v:UniqueID()
       
        if next_round == "traitor" then
            if PlysMarkedForTraitor[ID] == true or PlysMarkedForDetective[ID] == true then
                ULib.tsayError( calling_ply, "that player is already marked for the next round", true )
            else
                PlysMarkedForTraitor[ID] = true
                table.insert( affected_plys, v )
            end
        end
        if next_round == "detective" then
            if PlysMarkedForTraitor[ID] == true or PlysMarkedForDetective[ID] == true then
                ULib.tsayError( calling_ply, "that player is already marked for the next round!", true )
            else
                PlysMarkedForDetective[ID] = true
                table.insert( affected_plys, v )
            end
        end
        if next_round == "unmark" then
            if PlysMarkedForTraitor[ID] == true then
                PlysMarkedForTraitor[ID] = false
                table.insert( affected_plys, v )
            end
            if PlysMarkedForDetective[ID] == true then
                PlysMarkedForDetective[ID] = false
                table.insert( affected_plys, v )
            end
        end
    end   
       
    if next_round == "unmark" then
        ulx.fancyLogAdmin( calling_ply, true, "#A has unmarked #T ", affected_plys )
    else
        ulx.fancyLogAdmin( calling_ply, true, "#A marked #T to be #s next round.", affected_plys, next_round )
    end
end       
local nxtr= ulx.command( CATEGORY_NAME, "ulx forcenr", ulx.nextround, "!nr" )
nxtr:addParam{ type=ULib.cmds.PlayersArg }
nxtr:addParam{ type=ULib.cmds.StringArg, completes=ulx.next_round, hint="Next Round", error="invalid role \"%s\" specified", ULib.cmds.restrictToCompletes }
nxtr:defaultAccess( ULib.ACCESS_SUPERADMIN )
nxtr:help( "Forces the target to be a detective/traitor in the following round." )

local function TraitorMarkedPlayers()
for k, v in pairs(PlysMarkedForTraitor) do
if v then
ply = player.GetByUniqueID(k)
ply:SetRole(ROLE_TRAITOR)
            ply:AddCredits(GetConVarNumber("ttt_credits_starting"))
ply:ChatPrint("You have been made a traitor by an admin this round.")
PlysMarkedForTraitor[k] = false
end
end
end
hook.Add("TTTBeginRound", "Admin_Round_Traitor", TraitorMarkedPlayers)

local function DetectiveMarkedPlayers()
for k, v in pairs(PlysMarkedForDetective) do
if v then
ply = player.GetByUniqueID(k)
ply:SetRole(ROLE_DETECTIVE)
            ply:AddCredits(GetConVarNumber("ttt_credits_starting"))
            ply:Give("weapon_ttt_wtester")
ply:ChatPrint("You have been made a detective by an admin this round.")
PlysMarkedForDetective[k] = false
end
end
end
hook.Add("TTTBeginRound", "Admin_Round_Detective", DetectiveMarkedPlayers)

if SERVER then
local banmins = 2440
local culumativeban = true

hook.Add( "PlayerDisconnected", "BanThemSlayEvaders", function( ply )

slays = tonumber( ply:GetPData( "slaynr_slays" ) ) or 0

if slays > 0 then
local reason, mins = "Attempting to evade "..slays.." autoslays.", ( culumativeban and slays*banmins or banmins )
ULib.kickban( ply, mins, reason )
ulx.fancyLogAdmin( nil, false, "Automatically banned #T for #i minutes (#s) ", ply, mins, reason )
end

end )
end
Title: Re: Murder ULX commands
Post by: bender180 on February 26, 2014, 04:36:47 PM
remove the a at the very start of the file before the commented block starts and it should fix it

Quote
a--[=[-------------------------------------------------------------------------------------------
?                              Trouble in Terrorist Town Commands                              ?
?                                   By: Skillz and Bender180                                   ?
?                              ?????????????????????????????????                               ?
?                              ? ??? ??? ?? ??? ??? ?? ??? ??? ?                               ?
?                              ??? ? ? ?????? ? ? ?????? ? ? ???                               ?
???????????????????????????????????? ?????????? ?????????? ?????????????????????????????????????
???????????????????????????????????? ?????????? ?????????? ?????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????????????????????
?                  All code included is completely original or extracted                       ?
?            from the base ttt files that are provided with the ttt gamemode.                  ?
?                                                                                              ?
---------------------------------------------------------------------------------------------]=]
Title: Re: Murder ULX commands
Post by: pants on February 26, 2014, 09:25:24 PM
oh wow, derp lol
Title: Re: Murder ULX commands
Post by: nogger on April 11, 2014, 12:59:55 AM
Code: [Select]
if SERVER then
local banmins = 200
local culumativeban = true

hook.Add( "PlayerDisconnected", "BanThemSlayEvaders", function( ply )

local slays = tonumber( ply:GetPData( "slaynr_slays" ) ) or 0

if slays > 0 then
local reason, mins = "Attempting to evade "..slays.." autoslays.", ( culumativeban and slays*banmins or banmins )
ULib.kickban( ply, mins, reason )
ulx.fancyLogAdmin( nil, false, "Automatically banned #T for #i minutes (#s) ", ply, mins, reason )
end

end )
end
Drop this at the bottom of addons/Trouble In Terrorist Town ULX Commands/lua/ulx/modules/sh/ttt_admin.lua
Assuming you're using Bender180's ULX TTT commands.


Is there a way i can make this only if the disconnect reason is Disconnected by user?
Because what if they get that silly timed out error, or steam auth ticket has been canceled
Title: Re: Murder ULX commands
Post by: MrPresident on April 11, 2014, 05:22:38 PM
Nogger, I'm not sure if the PlayerDisconnected hook is comprehensive enough to determine how a player disconnected.
Title: Re: Murder ULX commands
Post by: Cobalt on April 11, 2014, 06:29:19 PM
Nogger, I'm not sure if the PlayerDisconnected hook is comprehensive enough to determine how a player disconnected.
You have to use gameevents for that.

gameevent.Listen( "player_disconnect" )
hook.Add( "player_disconnect", "asdf", function( data )
   local reason = data.reason
   print( reason ) --> "player timed out" or something
end )
Title: Re: Murder ULX commands
Post by: MrPresident on April 11, 2014, 08:09:42 PM
I didn't know you could do that. Good to know.
Title: Re: Murder ULX commands
Post by: Cobalt on April 13, 2014, 02:49:17 PM
(http://puu.sh/87yTb.png)
(http://puu.sh/87yVy.png)
rofl
Title: Re: Murder ULX commands
Post by: Neku on April 13, 2014, 04:08:53 PM
(http://puu.sh/87yTb.png)
(http://puu.sh/87yVy.png)
rofl

Was it the exact same commands?
Title: Re: Murder ULX commands
Post by: Cobalt on April 13, 2014, 05:10:45 PM
Was it the exact same commands?
Seeing as he was banned for copying others' work, it probably was.
Title: Re: Murder ULX commands
Post by: Bytewave on April 13, 2014, 05:27:34 PM
(http://puu.sh/87yTb.png)
(http://puu.sh/87yVy.png)
rofl
Everyone loves a good ol' idiotic thief once in a while.
Title: Re: Murder ULX commands
Post by: Bob Dylan on January 06, 2015, 07:06:31 PM
can you please consider making the slaynr, unslaynr and respawn work for chessnuts version of jailbreak please!