Raised This Month: $51 Target: $400
 12% 

Solved Zombie Plugin Hud Problems


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ZombieTheMan01
Senior Member
Join Date: Aug 2015
Location: Turkey
Old 06-07-2020 , 13:34   Zombie Plugin Hud Problems
Reply With Quote #1

Hello my friends. I was working on a mod (zombie plague 5.0 based). But there is a problem like this. Whenever I try to add hud from client_PreThink, the hud of the bottom zp 5.0 disappears. This time does not come out if I add it elsewhere. So, my friends, what do we have to do about this? So you have an idea?

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <fun>
#include <cs_ham_bots_api>
#include <zombieplague>
#include <zp50_core>
#define LIBRARY_NEMESIS "zp50_class_nemesis"
#include <zp50_class_nemesis>

#define PLUGIN "NST Zombie Class Tank"
#define VERSION "1.1 (2020)"
#define AUTHOR "NST (Based)/Me(fixed and modified)"

new const zclass_name[] = "Berserker"
new const zclass_info[] = "[G] > Berserk"
new const zclass_model[] = "tank_zombi_host"
new const zclass_clawmodel[] = "v_knife_tank_zombi.mdl"
const zclass_health 7000
const zclass_speed 280
const Float:zclass_gravity 0.8
const Float:zclass_knockback 1.5

new idclass
const Float:fastrun_time 10.0
const Float:fastrun_timewait 5.0
const Float:fastrun_speed 340.0
new const sound_fastrun_start[] = "zombie_plague/zombi_pressure.wav"
new const sound_fastrun_heartbeat[][] = {"zombie_plague/zombi_pre_idle_1.wav""zombie_plague/zombi_pre_idle_2.wav"}
const 
fastrun_fov 105
const glow_red 255
const glow_green 3
const glow_blue 0

new g_fastrun[33], g_fastrun_wait[33], g_had[33]

new 
g_msgSetFOV
new g_maxplayers
new g_roundend
new g_current_time[33]

#define g_time_fastrun 10
#define g_time_fastrunwait 5


enum (+= 100)
{
    
TASK_FASTRUN 2000,
    
TASK_FASTRUN_HEARTBEAT,
    
TASK_FASTRUN_WAIT,
    
TASK_BOT_USE_SKILL
}

#define ID_FASTRUN (taskid - TASK_FASTRUN)
#define ID_FASTRUN_HEARTBEAT (taskid - TASK_FASTRUN_HEARTBEAT)
#define ID_FASTRUN_WAIT (taskid - TASK_FASTRUN_WAIT)
#define ID_BOT_USE_SKILL (taskid - TASK_BOT_USE_SKILL)

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
//register_event("CurWeapon","show_hud","be", "1=1")

    
register_event("HLTV""event_round_start""a""1=0""2=0")
    
register_event("DeathMsg""Death""a")
    
register_event("CurWeapon","EventCurWeapon","be","1=1")
    
register_logevent("logevent_round_end"2"1=Round_End")
    
    
register_clcmd("drop""cmd_fastrun")
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage")
    
RegisterHamBots(Ham_TakeDamage"fw_TakeDamage")
    
//register_forward(FM_CmdStart , "CmdStart")

    //g_msgSayText = get_user_msgid("SayText")
    
g_msgSetFOV get_user_msgid("SetFOV")
    
g_maxplayers get_maxplayers()
}

public 
plugin_precache()
{
    new 
i
    
for(0sizeof sound_fastrun_heartbeati++ )
    {
        
precache_sound(sound_fastrun_heartbeat[i]);
    }
    
    
precache_sound(sound_fastrun_start)
    
    
idclass zp_register_zombie_class(zclass_namezclass_infozclass_modelzclass_clawmodelzclass_healthzclass_speedzclass_gravityzclass_knockback)
}

public 
client_putinserver(id)
{
    
g_had[id] = 0
    reset_value_player
(id)
}

public 
client_disconnect(id)
{
    
g_had[id] = 0
    reset_value_player
(id)
}

public 
event_round_start()
{
    
g_roundend 0
    
    
for (new id=1id<=g_maxplayersid++)
    {
        if (!
is_user_connected(id)) continue;
        
g_had[id] = 0
        reset_value_player
(id)
    }
}

public 
logevent_round_end()
{
    
g_roundend 1
}

public 
Death()
{
    new 
victim read_data(2
    
reset_value_player(victim)
}

public 
EventCurWeapon(id)
{
    if(!
is_user_alive(id)) return PLUGIN_CONTINUE;
    
    if(
g_fastrun[id]) set_user_maxspeed(idfastrun_speed);
    
    return 
PLUGIN_CONTINUE;
}

public 
zp_user_infected_post(id)
{
    
reset_value_player(id)
    
    if(
zp_get_user_nemesis(id)) return;
    
    if(
zp_get_user_zombie_class(id) == idclass)
    {
        if(
is_user_bot(id))
        {
            
g_current_time[id] = 100
            g_had
[id] = 1
            set_task
(random_float(15.0,20.0), "bot_use_skill"id+TASK_BOT_USE_SKILL)
            return
        }
        
        
//zp_colored_print(id, "^x04[ZP]^x01 Your skill is^x04 Sprint^x01. Cooldown^x04 %.1f ^x01seconds.", fastrun_timewait)
    
}
}

public 
zp_user_humanized_post(id)
{
    if(
g_fastrun[id]) EffectFastrun(id);
    
    
reset_value_player(id)
}

public 
zp_user_unfrozen(id)
{
    if(
g_fastrun[id]) set_user_rendering(idkRenderFxGlowShellglow_redglow_greenglow_bluekRenderNormal0)
}

public 
cmd_fastrun(id)
{
    if (
g_roundend && !g_had[id]) return PLUGIN_CONTINUE
    
    
if (!is_user_alive(id) || !zp_get_user_zombie(id) || zp_get_user_nemesis(id)) return PLUGIN_CONTINUE

    
//new health = get_user_health(id) - fastrun_dmg
    
if (zp_get_user_zombie_class(id) == idclass && !g_fastrun[id] && !g_fastrun_wait[id])
    {
        
g_current_time[id] = 0
        g_fastrun
[id] = 1
        
        set_user_maxspeed
(idfastrun_speed)
        
set_user_rendering(idkRenderFxGlowShellglow_redglow_greenglow_bluekRenderNormal0)
        
EffectFastrun(idfastrun_fov)
        
PlayEmitSound(idsound_fastrun_start)
        
        
set_task(fastrun_time"RemoveFastRun"id+TASK_FASTRUN)
        
set_task(2.0"FastRunHeartBeat"id+TASK_FASTRUN_HEARTBEAT__"b")

        return 
PLUGIN_HANDLED
    
}
    
    return 
PLUGIN_CONTINUE
}

public 
bot_use_skill(taskid)
{
    new 
id ID_BOT_USE_SKILL
    
    
if (!is_user_alive(id)) return;

    
cmd_fastrun(id)
    
    
set_task(random_float(5.0,15.0), "bot_use_skill"id+TASK_BOT_USE_SKILL)
}

public 
RemoveFastRun(taskid)
{
    new 
id ID_FASTRUN

    g_fastrun
[id] = 0
    g_fastrun_wait
[id] = 1
    set_user_maxspeed
(idfloat(zclass_speed))
    
set_user_rendering(id)
    
EffectFastrun(id)
    
    
set_task(fastrun_timewait"RemoveWaitFastRun"id+TASK_FASTRUN_WAIT)
}

public 
RemoveWaitFastRun(taskid)
{
    new 
id ID_FASTRUN_WAIT
    
    g_fastrun_wait
[id] = 0
    
    
//zp_colored_print(id, "^x04[ZP]^x01 Your skill^x04 Sprint^x01 is ready.")
}

public 
FastRunHeartBeat(taskid)
{
    new 
id ID_FASTRUN_HEARTBEAT
    
    
if (g_fastrun[id]) PlayEmitSound(idsound_fastrun_heartbeat[random_num(0sizeof sound_fastrun_heartbeat 1)]);
    else 
remove_task(taskid)
}

public 
client_PreThink(id)
{
    if(!
is_user_alive(id) || !g_had[id] && !zp_get_user_zombie(id))
        return

    
    if(
g_fastrun_wait[id])
    {
        
set_dhudmessage(2501600, -1.00.2502.010.00.11.5)
        
//set_dhudmessage(200, 200, 0, -1.0, 0.25, 0, 0.0, 0.0, 0.0, 0.0)
        //set_hudmessage(200, 200, 0, -1.0 , 0.25, 0, 0.1, 0.1,0.1)
        
show_dhudmessage(id"[G] -> Berserk (Waiting for %i seconds...)"g_time_fastrunwait)
    }
    else if(
g_fastrun[id]) {
        
set_dhudmessage(25000, -1.00.2502.010.00.11.5)
        
//set_dhudmessage(200, 0, 0, -1.0, 0.25, 0, 0.0, 0.0, 0.0, 0.0)
        //set_hudmessage(200, 0, 0, -1.0, 0.25, 0, 0.1, 0.1, 0.1)
        
show_dhudmessage(id"[G] -> Berserk (Active)")
    }
    else {
        
set_dhudmessage(01600, -1.00.2502.010.00.11.5)
        
//set_dhudmessage(0, 200, 0, -1.0, 0.25, 0, 0.0, 0.0, 0.0, 0.0)
        //set_hudmessage(0, 200, 0, -1.0, 0.25, 0, 0.1, 0.1, 0.1)
        
show_dhudmessage(id"[G] -> Berserk (Ready)")
    }
}

/*public CmdStart(id, UC_Handle, seed)
{
    if(!is_user_alive(id))
        return
    if(!zp_get_user_zombie(id) || !g_had[id])
        return
    
    static Float:CurrentTime, Float:g_hud_delay[33]
    CurrentTime = get_gametime()
    
    if(CurrentTime - 1.0 > g_hud_delay[id])
    {
        show_hud(id)
        if(pev(id, pev_solid) == SOLID_NOT)
            set_pev(id, pev_solid, SOLID_BBOX)
        
        g_hud_delay[id] = CurrentTime
    }
}*/

PlayEmitSound(id, const sound[])
{
    
emit_sound(idCHAN_VOICEsound1.0ATTN_NORM0PITCH_NORM)
}

EffectFastrun(idnum 90)
{
    
message_begin(MSG_ONEg_msgSetFOV, {0,0,0}, id)
    
write_byte(num)
    
message_end()
}

reset_value_player(id)
{
    
g_current_time[id] = 0
    g_had
[id] = 0
    g_fastrun
[id] = 0
    g_fastrun_wait
[id] = 0
    set_user_rendering
(idkRenderFxGlowShell000kRenderNormal0)
    
remove_task(id+TASK_FASTRUN)
    
remove_task(id+TASK_FASTRUN_HEARTBEAT)
    
remove_task(id+TASK_FASTRUN_WAIT)
    
remove_task(id+TASK_BOT_USE_SKILL)
}

public 
fw_TakeDamage(victiminflictorattackerFloat:damagedamage_type)
{
    
// Non-player damage or self damage
    
if (victim == attacker || !is_user_alive(attacker))
        return 
HAM_IGNORED;
    
    
// Human attacking zombie...
    
if (!zp_core_is_zombie(attacker) && zp_core_is_zombie(victim) && g_had[victim])
    {
        
// Ignore for Nemesis
        
if (LibraryExists(LIBRARY_NEMESISLibType_Library) && zp_class_nemesis_get(attacker))
            return 
HAM_IGNORED;
        
        
// Armor multiplier for the final damage
        
SetHamParamFloat(4g_fastrun[victim] ? damage 2.27 damage 1.45)
        return 
HAM_HANDLED;
    }
    
    return 
HAM_IGNORED;

This Video. (For friends who don't understand.)
__________________
FREE PLUGINS:

2021 and before -> ALL PLUGIN LINK IS HERE <-

2022:
Zombie: The Original [%70 Completed]

Last edited by ZombieTheMan01; 07-15-2020 at 10:11. Reason: I wrote PostThink instead of PreThink.
ZombieTheMan01 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 06-07-2020 , 14:05   Re: Zombie Plugin Hud Problems
Reply With Quote #2

Displaying a HUD message in client_PostThink is a very bad idea. This will display the message 100 times each second. Since there can be only 4 HUD messages on the screen at a time, this will of course overwrite every other message from any other plugin, especially if you're not using ShowSyncHudMsg. I doubt you need to display the message that often. The least you could do is use a repeating task of 1 second (or 0.1 if you need it more often). Also make sure the messages are displayed on the same channel. Bear in mind that this isn't possible with DHUD.
__________________

Last edited by OciXCrom; 06-07-2020 at 14:05.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
ZombieTheMan01
Senior Member
Join Date: Aug 2015
Location: Turkey
Old 06-07-2020 , 14:34   Re: Zombie Plugin Hud Problems
Reply With Quote #3

Quote:
Originally Posted by OciXCrom View Post
Displaying a HUD message in client_PostThink is a very bad idea. This will display the message 100 times each second. Since there can be only 4 HUD messages on the screen at a time, this will of course overwrite every other message from any other plugin, especially if you're not using ShowSyncHudMsg. I doubt you need to display the message that often. The least you could do is use a repeating task of 1 second (or 0.1 if you need it more often). Also make sure the messages are displayed on the same channel. Bear in mind that this isn't possible with DHUD.
Well, would we be able to handle this from "event_curweapon"? Or is there any other "public, stock etc." you can recommend?
__________________
FREE PLUGINS:

2021 and before -> ALL PLUGIN LINK IS HERE <-

2022:
Zombie: The Original [%70 Completed]
ZombieTheMan01 is offline
mahbodsr
Member
Join Date: Jun 2016
Old 06-07-2020 , 15:10   Re: Zombie Plugin Hud Problems
Reply With Quote #4

Quote:
Originally Posted by ZombieTheMan01 View Post
Well, would we be able to handle this from "event_curweapon"? Or is there any other "public, stock etc." you can recommend?
use set_task()
mahbodsr is offline
ZombieTheMan01
Senior Member
Join Date: Aug 2015
Location: Turkey
Old 06-07-2020 , 17:03   Re: Zombie Plugin Hud Problems
Reply With Quote #5

Quote:
Originally Posted by mahbodsr View Post
use set_task()
This time I did as you said and fixed it. I also used my own hud system instead of "client_prethink" where the friend was talking about. the result is the same. If you want I can throw the codes for the last time
__________________
FREE PLUGINS:

2021 and before -> ALL PLUGIN LINK IS HERE <-

2022:
Zombie: The Original [%70 Completed]
ZombieTheMan01 is offline
ZombieTheMan01
Senior Member
Join Date: Aug 2015
Location: Turkey
Old 06-08-2020 , 14:57   Re: Zombie Plugin Hud Problems
Reply With Quote #6

I changed it from client_prethink to show_hud. I made some corrections by adding it to cmdstart specifically. The result is still the same. So if we add the publics one by one and then add the borders there? Or should we handle it from the zombie plague core scripting file?
__________________
FREE PLUGINS:

2021 and before -> ALL PLUGIN LINK IS HERE <-

2022:
Zombie: The Original [%70 Completed]
ZombieTheMan01 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 07:55.


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