• Ulx Custom command for setting Hud Text and color? SWRP
    1 replies, posted
Hello, i have been tinkering with this hud called BarHud, I have been working on adding a Defcon Section to it... The problem is we dont have a location to file it so it says Defcon: Citizen atm... Which is not correct i know. Where trying to find a way to use a ulx command such as, "!defcon 1" to set the text of the defcon to; Defcon: 1 - Evacuate Ship Were trying to get six of them "!defcon 1" 1 - Evacuate ship "!defcon 2" 2 - Protect ERL and 3rd Floor "!defcon 3" 3 - Man Your Battlestations "!defcon 4" 4 - Sweep for Tangos "!defcon 5" 5 - High Alert "!defcon 6" 6 - Natural State We dont need them to add "Defcon:" as the tab says it already. Also setting a color as it changes defcons such as defcon 6 being green to defcon 1 being red.
You could have the ULX command set a global string via SetGlobalString("indentifier,"Evacuate Ship!") and have the hud call for it via GetGlobalString("indentifier") for color, you could try using SetGlobalInt and have it set a value ex: function ulx.defcon( calling_ply, defconlevel ) if defconlevel == nil then ULib.tsayError( calling_ply, "That defcon level is not valid!", true ) return  end if defconlevel == 6 then SetGlobalString("defcon","6 - Natural State") SetGlobalInt("defconcolor",6) elseif defconlevel == 5 then SetGlobalString("defcon","5 - High Alert") SetGlobalInt("defconcolor",5) elseif defconlevel == 4 then SetGlobalString("defcon","4 - Sweep for Tangos") SetGlobalInt("defconcolor",4) elseif defconlevel == 3 then SetGlobalString("defcon","3 - Man Your Battlestations") SetGlobalInt("defconcolor",3) elseif defconlevel == 2 then SetGlobalString("defcon","2 - Protect ERL and 3rd Floor") SetGlobalInt("defconcolor",2) elseif defconlevel == 1 then SetGlobalString("defcon","1 - Evacuate ship") SetGlobalInt("defconcolor",1) else ULib.tsayError( calling_ply, "That defcon level does not exist!", true ) end ulx.fancyLogAdmin( calling_ply, "#A set Ships Status to #s", name ) end local defcon = ulx.command( CATEGORY_NAME, "ulx defcon", ulx.defcon, "!defcon" ) defcon:addParam{ type=ULib.cmds.StringArg, hint="defcon level", ULib.cmds.takeRestOfLine } defcon:defaultAccess( ULib.ACCESS_SUPERADMIN ) defcon:help( "Sets defcon level." ) hook.Add("HUDPaint","hudstuff",function() local DefconString = GetGlobalString("defcon") local DefconColor = {} DefconColor[1] = Color(255,55,55) DefconColor[2] = Color(255,165,0) DefconColor[3] = Color(122,255,0) DefconColor[4] = Color(255,255,0) DefconColor[5] = Color(0,255,0) DefconColor[6] = Color(0,170,0) surface.SetDrawColor(DefconColor[GetGlobalInt("defconcolor",6)]) surface.DrawText(DefconString or "Natural State") end)
Sorry, you need to Log In to post a reply to this thread.