Raised This Month: $32 Target: $400
 8% 

[Any] Simple HealthBars


Post New Thread Reply   
 
Thread Tools Display Modes
Author
lugui
Senior Member
Join Date: Feb 2016
Location: GetClientAbsOrigin();
Plugin ID:
7485
Plugin Version:
Plugin Category:
All
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Old 02-04-2021 , 10:21   [Any] Simple HealthBars
    Reply With Quote #1

    This plugin is an example.
    It is not configurable since the objective is simply to make a proof of concept.
    It is easy to reprogram so you can easily use it as a base or simply copypaste the parts you want into your plugin.

    It will display a helth bar above every player's head (except yourself).

    Since the Beams can only be displayed for a minimun of 0.1 second, the bar will only update on a 0.1 second timer.
    This results in a laggy movement of the bar.
    There are a few solutions:
    1 - Render the bar once per freme. This will look great if the bar is not moving, but will create a ghosting effect since the bar still takes 0.1 seconds to disapear.
    2 - use laser beam attached to another entity. It gives the best looking results, but the objective of this plugin is just to showcase the maths.

    Feel free to ask for help about the plugin and to make your own better version of it.
    Attached Files
    File Type: sp Get Plugin or Get Source (simpleHealthbarTimer.sp - 604 views - 3.7 KB)
    __________________
    Add me for commissions!
    Steam: [U:1:88621772]
    Discord: lugui#0889
    My Plugins

    Last edited by lugui; 02-14-2021 at 10:24.
    lugui is offline
    ScoobyDev77
    Junior Member
    Join Date: Jul 2020
    Old 02-04-2021 , 10:32   Re: [Any] Simple HealthBars
    Reply With Quote #2

    Nice!!
    ScoobyDev77 is offline
    foxhound27
    AlliedModders Donor
    Join Date: Sep 2019
    Location: Argentina
    Old 02-04-2021 , 17:37   Re: [Any] Simple HealthBars
    Reply With Quote #3

    Thank You <3
    foxhound27 is offline
    Franc1sco
    Veteran Member
    Join Date: Oct 2010
    Location: Spain (Madrid)
    Old 02-05-2021 , 06:02   Re: [Any] Simple HealthBars
    Reply With Quote #4

    You should change this
    PHP Code:
    public OnMapStart() {
        
    beamSprite PrecacheModel("materials/sprites/laserbeam.vmt");
        
    glowsprite PrecacheModel("sprites/redglow3.vmt");
        
    CreateTimer(0.1Timer_Render_TIMER_REPEAT);

    to this
    PHP Code:
    public OnMapStart() {
        
    beamSprite PrecacheModel("materials/sprites/laserbeam.vmt");
        
    glowsprite PrecacheModel("sprites/redglow3.vmt");
        
    CreateTimer(0.1Timer_Render_TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);

    in order to prevent creating duplicated timers on each mapchange.

    Code:
    TIMER_FLAG_NO_MAPCHANGE 
    The timer will automatically stop if the map changes
    Source: https://wiki.alliedmods.net/SourcePa...rs#Timer_Flags
    __________________
    Veteran Coder -> Activity channel
    Coding on CS2 and taking paid and free jobs.

    Contact: Steam, Telegram or discord ( franug ).

    You like my work? +Rep in my steam profile comments or donate.


    Last edited by Franc1sco; 02-05-2021 at 06:03.
    Franc1sco is offline
    Send a message via MSN to Franc1sco
    lugui
    Senior Member
    Join Date: Feb 2016
    Location: GetClientAbsOrigin();
    Old 02-05-2021 , 11:40   Re: [Any] Simple HealthBars
    Reply With Quote #5

    Thanks Franc1sco, I've updated it.
    __________________
    Add me for commissions!
    Steam: [U:1:88621772]
    Discord: lugui#0889
    My Plugins
    lugui is offline
    kimonl
    Junior Member
    Join Date: Nov 2022
    Old 11-08-2022 , 22:24   Re: [Any] Simple HealthBars
    Reply With Quote #6

    Worked for NMRIH
    Thanks so much ♥️
    kimonl is offline
    Grey83
    Veteran Member
    Join Date: Dec 2014
    Location: Ukraine
    Old 11-09-2022 , 12:50   Re: [Any] Simple HealthBars
    Reply With Quote #7

    Slightly optimized the plugin code (moved all variable creations out of the loop) and made it compatible with SM1.11+
    PHP Code:
    //// simple_healthbar 1.0.1.sp
    //
    // Code size:         8336 bytes
    // Data size:         2896 bytes
    // Stack/heap size:      16528 bytes
    // Total requirements:   27760 bytes
    //
    // Compilation Time: 0,28 sec
    // ----------------------------------------

    //// simpleHealthbarTimer.sp
    //
    // Z:\simpleHealthbarTimer.sp(25) : warning 242: function "Timer_Render" should return an explicit value
    // Code size:         8952 bytes
    // Data size:         2892 bytes
    // Stack/heap size:      16620 bytes
    // Total requirements:   28464 bytes
    //
    // 1 Warning.
    //
    // Compilation Time: 0,27 sec
    // ---------------------------------------- 
    Attached Files
    File Type: sp Get Plugin or Get Source (simple_healthbar 1.0.1.sp - 176 views - 2.6 KB)
    __________________

    Last edited by Grey83; 11-09-2022 at 12:51.
    Grey83 is offline
    Reply



    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 14:30.


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