Page 1 of 1

Game: [HL2:DM] HUD

Posted: Thu Jun 04, 2020 7:57 pm
by daren adler
Could i get this made for SP please. I use it in sourcemod but it makes my other overlay and game text show for a sec or not even show my game text for ads.


Code: Select all

#include <sourcemod>

#define HUDTICK      1.2

public Plugin:myinfo =
{
   name = "Hud",
   author = "EXILE",
   description = "Hud for Half Life 2 Deathmatch",
   version = "1.0",
}

//Initation:
public OnClientPostAdminCheck (Client)
{
   CreateTimer(HUDTICK, DisplayHud, Client, TIMER_REPEAT);
}

//Hud:
public Action:DisplayHud(Handle:Timer, any:Client)
{
   //Connected:
   if(IsClientConnected(Client) && IsClientInGame(Client))
   {
      decl String:ClientName[MAX_NAME_LENGTH];
      GetClientName(Client, ClientName, sizeof(ClientName));

      SetHudTextParams(0.015, 0.015, HUDTICK, 255, 255, 255, 255, 0, 6.0, 0.1, 0.2);
      ShowHudText(Client, -1, "|WELCOME|\n|%s|", ClientName);       
   }
}




What this does is in the upper left top corner it says WELCOME (playername).
Thank you for your help!! :)

Re: Game: [HL2:DM] HUD

Posted: Sat Jun 06, 2020 8:40 am
by cssbestrpg
Hi Daren try use this code

Syntax: Select all

from events import Event
from listeners.tick import Delay
from messages import HintText
from players.helpers import index_from_userid
from players.entity import Player


@Event('player_activate')
def player_activate(args):
userid = args.get_int('userid')
Delay(2.0, welcome, (userid,))

def welcome(userid):
hudhint(userid, 'Welcome %s' % (get_name(userid)))

def get_name(userid):
name = Player(index_from_userid(userid)).name
for i in ['#', "'", '"', '\\']:
name = name.replace(i, '')
return name

def hudhint(userid, text):
HintText(message=text).send(index_from_userid(userid))

Re: Game: [HL2:DM] HUD

Posted: Sat Jun 06, 2020 11:20 pm
by daren adler

Code: Select all

2020-06-06 18:03:32 - sp   -   MESSAGE   [SP] Loading plugin 'hud'...
2020-06-06 18:03:32 - sp   -   EXCEPTION   
[SP] Caught an Exception:
Traceback (most recent call last):
  File "..\addons\source-python\packages\source-python\plugins\command.py", line 164, in load_plugin
    plugin = self.manager.load(plugin_name)
  File "..\addons\source-python\packages\source-python\plugins\manager.py", line 194, in load
    plugin._load()
  File "..\addons\source-python\packages\source-python\plugins\instance.py", line 74, in _load
    self.module = import_module(self.import_name)
  File "..\addons\source-python\plugins\hud\hud.py", line 4
    from players.helpers index_from_userid
                                         ^

SyntaxError: invalid syntax


2020-06-06 18:03:32 - sp   -   MESSAGE   [SP] Plugin 'hud' was unable to be loaded.

Re: Game: [HL2:DM] HUD

Posted: Sat Jun 06, 2020 11:21 pm
by daren adler
cssbestrpg wrote:Hi Daren try use this code

Syntax: Select all

from events import Event
from listeners.tick import Delay
from messages import HintText
from players.helpers index_from_userid
from players.entity import Player


@Event('player_activate')
def player_activate(args):
userid = args.get_int('userid')
Delay(2.0, welcome, (userid,))

def welcome(userid):
hudhint(userid, 'Welcome %s' % (get_name(userid)))

def get_name(userid):
name = Player(index_from_userid(userid)).name
for i in ['#', "'", '"', '\\']:
name = name.replace(i, '')
return name

def hudhint(userid, text):
HintText(message=text).send(index_from_userid(userid))


sorry got a error and thank you for helping me. its above.

Re: Game: [HL2:DM] HUD

Posted: Sun Jun 07, 2020 12:58 am
by ReQ220
daren adler wrote:

Code: Select all

2020-06-06 18:03:32 - sp   -   MESSAGE   [SP] Loading plugin 'hud'...
2020-06-06 18:03:32 - sp   -   EXCEPTION   
[SP] Caught an Exception:
Traceback (most recent call last):
  File "..\addons\source-python\packages\source-python\plugins\command.py", line 164, in load_plugin
    plugin = self.manager.load(plugin_name)
  File "..\addons\source-python\packages\source-python\plugins\manager.py", line 194, in load
    plugin._load()
  File "..\addons\source-python\packages\source-python\plugins\instance.py", line 74, in _load
    self.module = import_module(self.import_name)
  File "..\addons\source-python\plugins\hud\hud.py", line 4
    from players.helpers index_from_userid
                                         ^

SyntaxError: invalid syntax


2020-06-06 18:03:32 - sp   -   MESSAGE   [SP] Plugin 'hud' was unable to be loaded.


Add "import" in line 4

Code: Select all

from players.helpers import index_from_userid

Re: Game: [HL2:DM] HUD

Posted: Sun Jun 07, 2020 5:07 am
by daren adler
ReQ220 wrote:
daren adler wrote:

Code: Select all

2020-06-06 18:03:32 - sp   -   MESSAGE   [SP] Loading plugin 'hud'...
2020-06-06 18:03:32 - sp   -   EXCEPTION   
[SP] Caught an Exception:
Traceback (most recent call last):
  File "..\addons\source-python\packages\source-python\plugins\command.py", line 164, in load_plugin
    plugin = self.manager.load(plugin_name)
  File "..\addons\source-python\packages\source-python\plugins\manager.py", line 194, in load
    plugin._load()
  File "..\addons\source-python\packages\source-python\plugins\instance.py", line 74, in _load
    self.module = import_module(self.import_name)
  File "..\addons\source-python\plugins\hud\hud.py", line 4
    from players.helpers index_from_userid
                                         ^

SyntaxError: invalid syntax


2020-06-06 18:03:32 - sp   -   MESSAGE   [SP] Plugin 'hud' was unable to be loaded.


Add "import" in line 4

Code: Select all

from players.helpers import index_from_userid


Works great now, thanks alot. good and fast job,ty :)