Raised This Month: $115 Target: $400
 28% 

[L4D2] HUD Server Logo


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Aceleracion
Member
Join Date: Jul 2017
Location: Ecuador
Old 11-09-2017 , 01:42   [L4D2] HUD Server Logo
Reply With Quote #1

Note:
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: https://developer.valvesoftware.com/.../Appendix:_HUD

Info

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

Images
Name:  server_text2.jpg
Views: 2693
Size:  43.3 KB

VScript File
Code:
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
Settings
- 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:
Code:
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.

Installation:
  • 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.
Attached Files
File Type: zip l4d2_Hud_Server_Logo.zip (1.3 KB, 346 views)
__________________
by Aceleración
To succeed in your goals, use your true potential

Last edited by Aceleracion; 11-28-2017 at 03:01. Reason: incorporate HUDPlace
Aceleracion is offline
Vit_amin
Senior Member
Join Date: Dec 2015
Location: Russian Federation
Old 11-13-2017 , 18:40   Re: [L4D2] HUD Server Logo
Reply With Quote #2

Good Job
Vit_amin is offline
eziosid
Senior Member
Join Date: Sep 2017
Old 11-30-2017 , 11:09   Re: [L4D2] HUD Server Logo
Reply With Quote #3

good job ....

Last edited by eziosid; 12-30-2017 at 03:00. Reason: fixed
eziosid is offline
Silvers
AlliedModders Donor
Join Date: Aug 2010
Location: SpaceX
Old 12-03-2017 , 19:12   Re: [L4D2] HUD Server Logo
Reply With Quote #4

(in-before-valve-patch) nice work
__________________
Silvers is offline
midnight9
Senior Member
Join Date: Nov 2012
Old 06-03-2018 , 06:36   Re: [L4D2] HUD Server Logo
Reply With Quote #5

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:

Code:
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" }
    }
}
HUDSetLayout(ModeHUD)
g_ModeScript
Code:
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);
        DispatchSpawn(entity);
        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?
midnight9 is offline
KoMiKoZa
Member
Join Date: Dec 2017
Location: Russia
Old 12-28-2018 , 08:09   Re: [L4D2] HUD Server Logo
Reply With Quote #6

Can't seem to get it to work at all, is the method still relevant?
KoMiKoZa is offline
zaviier
Member
Join Date: Aug 2017
Old 07-02-2019 , 18:20   Re: [L4D2] HUD Server Logo
Reply With Quote #7

not work l4d2
zaviier is offline
Marttt
Senior Member
Join Date: Jan 2019
Old 07-04-2019 , 13:29   Re: [L4D2] HUD Server Logo
Reply With Quote #8

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.
__________________

Last edited by Marttt; 07-04-2019 at 13:30.
Marttt is offline
zaviier
Member
Join Date: Aug 2017
Old 07-04-2019 , 16:49   Re: [L4D2] HUD Server Logo
Reply With Quote #9

Quote:
Originally Posted by Marttt View Post
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
zaviier is offline
Marttt
Senior Member
Join Date: Jan 2019
Old 07-18-2019 , 06:13   Re: [L4D2] HUD Server Logo
Reply With Quote #10

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.
__________________
Marttt is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:04.


Powered by vBulletin®
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Theme made by Freecode