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

Some Times Hud Message doesnot appear


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
RockyRock123
Junior Member
Join Date: Jan 2018
Old 01-17-2018 , 06:28   Some Times Hud Message doesnot appear
Reply With Quote #1

I having problem that some Times Hud message does not appear

PHP Code:
/*

Plugin by Priski

Usage :
Put admrules in admrules.txt file in cstrike folder
and set admrules_speed and admrules_interval whatever you like

Commands :
admrules_show     - shows admrules listed in admrules.txt
admrules_enable     - set this to 0 to disable automatic admrules display
say /admrules     - displays admrules to normal user

CVARS :
admrules_interval        - interval between automatic admrules display
admrules_admin_only    - disables say /admrules command from regular users
admrules_join        - if set 1 displays admrules after player have joined server
admrules_hudmessage_time    - time how long hudmessage is displayed
admrules_join_timeout    - delay to show admrules when joining to the server

Changelog :

1.20 / 2005-08-18
- removed client chat admrules
- fixed major bugs

1.11 / 2005-08-15
- fixed some bugs

1.10 / 2005-08-14
- new CVARs : admrules_hudmessage, admrules_hudmessage_time
admrules_join_timeout
- admrules in hudmessage mode also

1.03 / 2005-08-12
- admrules_enable command fix.
- new CVAR "admrules_join" set 1 to show admrules
to players when they join server

1.02 / 2005-08-11
- optimized code
- admrules_enable is now a command    
- default interval is now 10 minutes

1.01 / 2005-08-11
- added admrules_admin_only & say /admrules command
- variables are global now

1.0 / 2005-08-11
- first release

*/

#include <amxmodx>
#include <amxmisc>

new base[] = "admrules.txt"

new inumtext[127], hudmsg[440//max hudmessage length was 439 chars (?)

public plugin_init()
{
    
    
register_plugin("AMXX Public server admrules""1.20""Priski")
    
    
// register command
    
    
register_concmd("admrules_show""admrules"ADMIN_KICK"- show admrules to everybody")
    
register_concmd("admrules_enable""r_enable"ADMIN_KICK"- <1|0> set automessagin on/off")
    
register_cvar("admrules_admin_only""0")
    
register_cvar("admrules_join""0")
    
register_cvar("admrules_join_timeout""5")
    
register_cvar("admrules_hudmessage_time""10")
    
register_cvar("admrules_interval""600")
    
register_clcmd("say /admrules""clientadmrules"ADMIN_ALL"- show admrules")


public 
plugin_cfg() {
    
    if (!
file_exists(base)) {
        
write_file(base"; This is the public admrules file, put your admrules below")
        
write_file(base"; Remember, max amount of characters is 439")
        
console_print(0"%s file not found. creating new ..."base)
    }
    
}

public 
client_authorized id ) {
    
// on join display admrules
    
    
if (get_cvar_num("admrules_join")) {
        new 
tmp[1]
        
tmp[0] = id
        set_task
(1.0"showadmrules",id,tmp,1)
        
console_print(0"[user %d] client auth!"tmp[0])
    }
    
    return 
PLUGIN_HANDLED
}


public 
showadmrules (pid[]) {
    new 
id pid[0]
    
    if ( 
get_user_team(id) != && get_user_team(id) != ) {
        if (
id) {
            new 
tmp[1]
            
tmp[0] = id
            set_task
(2.0"showadmrules",id,tmp,1)  // not yet in server
            
console_print(0"[user %d] wait for joining team ..."id)
        }
        return 
PLUGIN_HANDLED
    
}
    
    new 
tmp[1]
    
tmp[0] = id
    
    console_print
(0"[user %d] joined team : %d"idget_user_team(id))
    
console_print(0"[user %d] printing admrules after %d seconds"idget_cvar_num("admrules_join_timeout"))
    
    
set_task(get_cvar_float("admrules_join_timeout"), "printadmrules"idtmp1)  // not yet in server
    
    
return PLUGIN_HANDLED
}

public 
printadmrules(pid[])
{
    new 
id pid[0]
    if (
file_exists(base))
        {
        
        
console_print(0"[user] printing admrules for user %d"id)
        
        
set_hudmessage 20015000.020.2520.1get_cvar_float("admrules_hudmessage_time"), 0.051.01)
        
format(hudmsg439"")
        
        
// read all the admrules
        
for(i=0read_file(baseitext127num); i++) {
            if (
num && text[0] != ';') {
                
// display with predefined delay
                
add(hudmsg,439,text)
                
add(hudmsg,439,"^n")
            }
        }
        
        
// show hudmessages
        
show_hudmessage(idhudmsg)
        
    }
    
    return 
PLUGIN_HANDLED
}


public 
r_enable(idlevelcid)
{
    if (!
cmd_access(idlevelcid0)) {  // NOT ADMIN
        
return PLUGIN_HANDLED
    
}
    
    new 
arg[3]
    
    
read_argv(1arg2)
    new 
value str_to_num(arg)
    
    if (!
isalnum(arg[0]))
        
value = -1
    
    
if (value == 0) {
        
        if (
task_exists(2)) // close task
            
remove_task(2)    
        
        
console_print(id"You have disabled automatic messages")
        return 
PLUGIN_HANDLED
        
    
}
    if (
value == 1) {
        
// activate task, reload if already exist
        
if (task_exists(2)) {
            
change_task(2get_cvar_float("admrules_interval"))
            } else {
            
set_task(get_cvar_float("admrules_interval"), "admrules"2""0"b")
        }    
        
console_print(id"You have enabled automatic messages")
        return 
PLUGIN_HANDLED        
    
}
    if (
task_exists(2)) {
        
console_print(id"automessages is ON.")
        } else {
        
console_print(id"automessages is OFF.")
    }
    
console_print(id"admrules_enable <1|0> (1 = ON, 0 = OFF)")
    return 
PLUGIN_HANDLED        
    
}

public 
clientadmrules(idlevelcid) {
    new 
pID[1]
    
pID[0] = id
    
    console_print
(0,"[user %d]Print admrules for me only",pID[0])
    
printadmrules(pID[0])
}

public 
admrules(idlevelcid)
{
    new 
pID[1]
    
pID[0] = id
            
    
if (!cmd_access(idlevelcid0)) {  // NOT ADMIN
        
return PLUGIN_HANDLED
    
}
    
    
// read file to all users
    
pID[0] = 0
    console_print
(0,"[user %d]Print admrules for all",id)
    
printadmrules(pID[0])
    
    
// Reset scheduled task after display
    
if (get_cvar_float("admrules_interval") > 0) {
        if (
task_exists(2)) {
            
change_task(2get_cvar_float("admrules_interval"))
            } else {
            
set_task(get_cvar_float("admrules_interval"), "admrules"200""0"b")
        }
    }
    
    return 
PLUGIN_HANDLED

RockyRock123 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-17-2018 , 21:12   Re: Some Times Hud Message doesnot appear
Reply With Quote #2

HUD messages are not guaranteed to be shown for any amount of definite time because the client program might update the screen and clear out all HUD messages. On such example is when you spawn it will clear all HUD messages.

  • Don't use HUD messages for important info.
  • Send the HUD message multiple times during the time you want it to be shown. So, if you want it shown for 10 seconds, show it ever 1 second until 10 seconds has elapsed.

Note that I didn't look at the code.
__________________

Last edited by fysiks; 01-17-2018 at 21:13.
fysiks 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 12:54.


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