AlliedModders (
-   Snippets and Tutorials (
-   -   [L4D2] HUD Server Logo (

Aceleracion 11-09-2017 01:42

[L4D2] HUD Server Logo
2 Attachment(s)
The included script is not an .sp file, but a .nut. That's because left 4 dead 2 does not support the HUD synchronization object created by sourcemod and the user messages through the StartMessage function. Valve launched the L4D2 EMS (Left 4 Dead 2 Expanded Mutation System) which now includes methods to make a controllable "HUD" scripted to make simple text-based UIs for your game modes.
More information in:


This VScript allows a text on the screen (HUD) to be displayed with some settings.

Attachment 166565

VScript File

HUDTable <-
        Fields =
                logo = { slot = HUD_FAR_RIGHT, dataval = "Your Text/Logo", flags = HUD_FLAG_ALIGN_CENTER | HUD_FLAG_NOBG, name = "logo" }

HUDSetLayout(HUDTable) //Applies a HUD to the screen
//HUDPlace( HUD_FAR_RIGHT, 0.8 , 0.04 , 0.5 , 0.1) //Uncomment this line if you want to configure the text box: make it larger or change it on the screen
g_ModeScript // Global reference to the Mode Script scope

- HUDTable: Table that defines your in-game HUD
- Fields: This contains whichever of these you want - though you _need_ a slot and at least one data element!
  • slot: which HUD_ slot on screen you want this to use - NECESSARY, w/o a slot nothing makes sense.
  • dataval: The value static (Your server logo).
  • flags: Custom flags for background, time, alignment, which team, pre or postfix, etc.
  • name: Cosmetic name for debugging, not used by code at the moment.
- HUDSetLayout(HUDTable): Applies a HUD to the screen. Do not erase this line of code.
- g_ModeScript: Global reference to the Mode Script scope. Does load the script when set/change the game mode.
- HUDPlace (slot, x, y, w, h) (Optional): If you want to configure the text box: make it larger because the text is not complete or change its position on the screen.
* Note: x,y,w,h are all 0.0-1.0 screen relative coordinates (actually, a bit smaller than the screen, but anyway).
  • x: coordinate x of the hud
  • y: coordinate y of the hud
  • w: width of the hud
  • h: height of the hud

Flags Values:

HUD_FLAG_PRESTR/POSTST: do you want a string/value pair to start(pre) or end(post) with the static string (default is PRE)
HUD_FLAG_BEEP: Makes a countdown timer blink
HUD_FLAG_BLINK: do you want this field to be blinking
HUD_FLAG_COUNTDOWN_WARN: auto blink when the timer gets under 10 seconds
HUD_FLAG_NOBG: dont draw the background box for this UI element
HUD_FLAG_ALLOWNEGTIMER: by default Timers stop on 0:00 to avoid briefly going negative over network, this keeps that from happening.
HUD_FLAG_SHOW_TIME: treat this float value as a Time (i.e. 00:00) instead of a floating value
HUD_FLAG_NOTVISIBLE: if you want to keep the slot data but keep it from displaying
HUD_FLAG_ALIGN_LEFT: Left justify this text
HUD_FLAG_ALIGN_CENTER: Center justify this text
HUD_FLAG_ALIGN_RIGHT: Right justify this text
HUD_FLAG_TEAM_SURVIVORS: only show to the survivor team
HUD_FLAG_TEAM_INFECTED: only show to the special infected team

Slot Positions:

* The name of the file has to be the name of its game mode. If your server is coop, the file should be called coop.nut, if it is versus: versus.nut, and so on for other game modes.

  • Download the file and extract in left4dead2\scripts\vscripts
  • Rename the file by the name of its game mode. (The value of cvar mp_gamemode)
  • You can settings it to your liking.

Vit_amin 11-13-2017 18:40

Re: [L4D2] HUD Server Logo
Good Job

eziosid 11-30-2017 11:09

Re: [L4D2] HUD Server Logo
good job ....

Silvers 12-03-2017 19:12

Re: [L4D2] HUD Server Logo
(in-before-valve-patch) nice work :)

midnight9 06-03-2018 06:36

Re: [L4D2] HUD Server Logo
Hello, im trying execute this script but it doesnt work. The hud does work when i put it in the versus.nut, just doesnt work when i put it in myscript.nut and then try to execute it via command.

The script:


ModeHUD <-
    Fields =
            myname = { slot = g_ModeScript.HUD_FAR_RIGHT, dataval = "My Text", flags = g_ModeScript.HUD_FLAG_ALIGN_CENTER | g_ModeScript.HUD_FLAG_NOBG, name = "myname" }


RegAdminCmd("sm_runvscript", Command_RunVscript, ADMFLAG_ROOT);

public Action Command_RunVscript(int client, int args)
    if(args < 1)
        return Plugin_Handled;

    char vscriptFile[40];
    GetCmdArg(1, vscriptFile, sizeof(vscriptFile));

    int entity = CreateEntityByName("logic_script");
    if( entity != -1 )
        DispatchKeyValue(entity, "vscripts", vscriptFile);
        SetVariantString("OnUser1 !self:RunScriptCode::0:-1");
        AcceptEntityInput(entity, "AddOutput");
        SetVariantString("OnUser1 !self:Kill::1:-1");
        AcceptEntityInput(entity, "AddOutput");
        AcceptEntityInput(entity, "FireUser1");
    return Plugin_Handled;

I've tried script_execute myscript.nut as well.

Any ideas?

KoMiKoZa 12-28-2018 08:09

Re: [L4D2] HUD Server Logo
Can't seem to get it to work at all, is the method still relevant?

zaviier 07-02-2019 18:20

Re: [L4D2] HUD Server Logo
not work l4d2

zaviier 07-04-2019 16:49

Re: [L4D2] HUD Server Logo

Originally Posted by Marttt (Post 2657746)
It works but you need to create the ".nut" file based on the gamemode, like...

coop.nut or versus.nut

And do some tests on a localhost if possible.

To show it on a dedicated with another filename (e.g myscript.nut), you need to make a script that runs the script after a while.

I know that because I have a server running with this script.

nvm. it's work..
just deleted admin command addons from steam workshop :D

Marttt 07-18-2019 06:13

Re: [L4D2] HUD Server Logo
zaviier you're right,

I remember having this kind of problem when I had some SteamWorkshop addons installed, and actually it was the "Admin Command" that caused that wrong behavior.

This is because this addon modifies/creates some ".nut" files and the "coop.nut" file is one of them,
so even if you create one by hand, it will be replaced by the addon,
in other words, your text logo will never show.

KoMiKoZa 07-21-2021 14:41

Re: [L4D2] HUD Server Logo
The method indeed still works as described by zaviier and Marttt.

I was actually wondering if anyone could tell me how possible it is to make a "Rounds restarted:" counter? Is there a variable that would be responsible for that? Simply just to count how many rounds are restarted.

All times are GMT -4. The time now is 18:16.

Powered by vBulletin®
Copyright ©2000 - 2021, vBulletin Solutions, Inc.