AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [DONE]How to make permanent HUD message? (https://forums.alliedmods.net/showthread.php?t=170891)

Evaldas.Grigas 10-30-2011 05:08

[DONE]How to make permanent HUD message?
 
Title.

plowed 10-30-2011 05:30

Re: How to make permanent HUD message?
 
search

datka888 10-30-2011 05:52

Re: How to make permanent HUD message?
 
Try This.
CVARS Copy To amxx.cfg
amx_permanent_message "Your advertisement here"
amx_permanent_message_color "255 255 255"
amx_permanent_message_location 3

Quote:

/*
*
*
* * * ***** ***** * ***** * * ***** * * * *
* * * * * * * * * * ** * * ** * * * *
* ****** ****** ****** * * ****** * * * * * * * * * * *
* * * * * ******* * * * * * * * * * * * *
* * * ***** ***** * * ***** * * ***** * * * *
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* AMX MOD X script. *
* Plugin made by He3aBuCuM(a.k.a. independent). *
* Important! You can modify the code, but DO NOT modify the author! *
* Contacts with me: *
* E-mail: [email protected] *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Special thanks to: *
* [email protected] - for the optimization on my first version *
* [email protected] - tell me for the clamp native *
* [email protected] - tell me how to use ShowSyncHudMsg and some ideas *
* [email protected] - for the idea amx_permanent_message_show *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
*
*/

#include <amxmodx>
#include <amxmisc>

new cvar_message, cvar_color, cvar_location, cvar_effects, cvar_show, cvar_cmd, hudsync

public plugin_init() {
register_plugin("Permanent message", "1.1", "He3aBuCuM")
cvar_message = register_cvar("amx_permanent_message", "Your/nadvertisement%new%here")
cvar_color = register_cvar("amx_permanent_message_color", "255 255 255")
cvar_location = register_cvar("amx_permanent_message_location ", "3")
cvar_effects = register_cvar("amx_permanent_message_effects" , "0")
cvar_show = register_cvar("amx_permanent_message_show", "0")
cvar_cmd = register_cvar("amx_permanent_message_cmd", "1")
register_concmd("amx_perm_msg", "cmdChangeMsg", ADMIN_LEVEL_A)
hudsync = CreateHudSyncObj()
set_task(1.0, "show_hud", 0, "", 0, "b")
}

public show_hud() {
new message[200], location, eff, show, players[32], inum
static red, green, blue
get_pcvar_string(cvar_message, message, charsmax(message))
get_hud_color(red, green, blue)
location = get_pcvar_num(cvar_location)
eff = clamp(get_pcvar_num(cvar_effects), 0, 2)
show = get_pcvar_num(cvar_show)
get_players(players, inum)

replace_all(message, charsmax(message), "%new%", "^n")
replace_all(message, charsmax(message), "/n", "^n")

switch(location) {
case 1: set_hudmessage(red, green, blue, 0.01, 0.15, eff, 1.0, 1.0, 0.1, 0.2, -1)
case 2: set_hudmessage(red, green, blue, -1.0, 0.15, eff, 1.0, 1.0, 0.1, 0.2, -1)
case 3: set_hudmessage(red, green, blue, 0.99, 0.15, eff, 1.0, 1.0, 0.1, 0.2, -1)
case 4: set_hudmessage(red, green, blue, 0.01, -1.0, eff, 1.0, 1.0, 0.1, 0.2, -1)
case 5: set_hudmessage(red, green, blue, -1.0, -1.0, eff, 1.0, 1.0, 0.1, 0.2, -1)
case 6: set_hudmessage(red, green, blue, 0.99, -1.0, eff, 1.0, 1.0, 0.1, 0.2, -1)
case 7: set_hudmessage(red, green, blue, 0.01, 0.75, eff, 1.0, 1.0, 0.1, 0.2, -1)
case 8: set_hudmessage(red, green, blue, -1.0, 0.75, eff, 1.0, 1.0, 0.1, 0.2, -1)
case 9: set_hudmessage(red, green, blue, 0.99, 0.70, eff, 1.0, 1.0, 0.1, 0.2, -1)
}

for(new i=0; i<inum; ++i) {
switch(show) {
case 0: ShowSyncHudMsg(0, hudsync, message)
case 1: {
if(!is_user_alive(players[i]))
ShowSyncHudMsg(players[i], hudsync, message)
}
case 2: {
if(is_user_alive(players[i]))
ShowSyncHudMsg(players[i], hudsync, message)
}
case 3: {
if(is_user_admin(players[i]))
ShowSyncHudMsg(players[i], hudsync, message)
}
case 4: {
if(!is_user_admin(players[i]))
ShowSyncHudMsg(players[i], hudsync, message)
}
case 5: {
if(is_user_admin(players[i]) && is_user_alive(players[i]))
ShowSyncHudMsg(players[i], hudsync, message)
}
case 6: {
if(is_user_admin(players[i]) && !is_user_alive(players[i]))
ShowSyncHudMsg(players[i], hudsync, message)
}
case 7: {
if(!is_user_admin(players[i]) && is_user_alive(players[i]))
ShowSyncHudMsg(players[i], hudsync, message)
}
case 8: {
if(!is_user_admin(players[i]) && !is_user_alive(players[i]))
ShowSyncHudMsg(players[i], hudsync, message)
}
default: ShowSyncHudMsg(0, hudsync, message)
}
}
return PLUGIN_CONTINUE
}

public cmdChangeMsg(id, level, cid) {
if(!get_pcvar_num(cvar_cmd) || !cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED

new args[200], name[32]
read_args(args, charsmax(args))
remove_quotes(args)
get_user_name(id, name, charsmax(name))

set_pcvar_string(cvar_message, args)
log_amx("The admin ^"%s^" change the permanent message to ^"%s^"", name, args)

return PLUGIN_CONTINUE
}

get_hud_color(&r, &g, &b) {
new color[20]
static red[5], green[5], blue[5]
get_pcvar_string(cvar_color, color, charsmax(color))
parse(color, red, charsmax(red), green, charsmax(green), blue, charsmax(blue))

r = str_to_num(red)
g = str_to_num(green)
b = str_to_num(blue)
}

.Dare Devil. 10-30-2011 05:57

Re: How to make permanent HUD message?
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
new g_msgScreenFade_bh
public plugin_init()
{
 
register_plugin"PermHud""1.0""PermHud" )
 
set_task0.5 "perm_hud")
 
g_MsgSync_bh CreateHudSyncObj()
}

public 
perm_hud()
{
   
 
set_hudmessage(250000.75, -1.010.50.51.01.0, -1)
 
ShowSyncHudMsg(idg_MsgSync_bh"Perm Hud!"
 
set_task0.5 "perm_hud")



Backstabnoob 10-30-2011 06:15

Re: How to make permanent HUD message?
 
Quote:

Originally Posted by .Dare Devil. (Post 1586245)
PHP Code:

#include <amxmodx>
#include <amxmisc>
new g_msgScreenFade_bh
public plugin_init()
{
 
register_plugin"PermHud""1.0""PermHud" )
 
set_task0.5 "perm_hud")
 
g_MsgSync_bh CreateHudSyncObj()
}

public 
perm_hud()
{
   
 
set_hudmessage(250000.75, -1.010.50.51.01.0, -1)
 
ShowSyncHudMsg(idg_MsgSync_bh"Perm Hud!"
 
set_task0.5 "perm_hud")



this method will greatly consume server resources

Evaldas.Grigas 10-30-2011 06:16

Re: How to make permanent HUD message?
 
Why this doesn't work then?
PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "HUD Message"
#define VERSION "1.0"
#define AUTHOR "Evaldas.Grigas"


public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
set_task0.5 "PermanentHUD")
}

public 
PermanentHUD()
{
    new 
CurrentDate[32]
    new 
CurrentTime[9]
    new 
CurrentMap[33]
    
    
get_mapname (CurrentMap32
    
get_time("%Y:%m:%d"CurrentDate31)
    
get_time("%H:%M:%S"CurrentTime8)
    
    
set_hudmessage(000, -0.850.0100.50.51.01.0, -1)
    
show_hudmessage(0"Date: %s"CurrentDate)
    
set_hudmessage(000, -0.850.0401.01.00.10.2, -1)
    
show_hudmessage(0"Time: %s"CurrentTime)
    
set_hudmessage(000, -0.850.0701.01.00.10.2, -1)
    
show_hudmessage(0"Map: %s"CurrentMap)



Backstabnoob 10-30-2011 06:18

Re: How to make permanent HUD message?
 
If you want to know why it doesn't work, it's because the task is not looped infinitely. Look for set_task() on funcwiki.

If you want to know why that code sucks and will lag your server, use search, I already explained somewhere what is a better solution.

Evaldas.Grigas 10-30-2011 06:21

Re: How to make permanent HUD message?
 
Maybe there is a perm message plugin already made? I need that it would show date, time, map and timeleft.

.Dare Devil. 10-30-2011 08:49

Re: How to make permanent HUD message?
 
Quote:

Originally Posted by Evaldas.Grigas (Post 1586256)
Maybe there is a perm message plugin already made? I need that it would show date, time, map and timeleft.

PHP Code:

#include <amxmodx>
#include <amxmisc>
 
#define PLUGIN "HUD Message"
#define VERSION "1.0"
#define AUTHOR "Evaldas.Grigas"
 
 
public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
set_task0.5 "PermanentHUD")
}
 
public 
PermanentHUD()
{
    new 
CurrentDate[32]
    new 
CurrentTime[9]
    new 
CurrentMap[33]
 
    
get_mapname (CurrentMap32
    
get_time("%Y:%m:%d"CurrentDate31)
    
get_time("%H:%M:%S"CurrentTime8)
 
    
set_hudmessage(000, -0.850.0100.50.51.01.0, -1)
    
show_hudmessage(0"Date: %s"CurrentDate)
    
set_hudmessage(000, -0.850.0401.01.00.10.2, -1)
    
show_hudmessage(0"Time: %s"CurrentTime)
    
set_hudmessage(000, -0.850.0701.01.00.10.2, -1)
    
show_hudmessage(0"Map: %s"CurrentMap)
 
    
set_task0.5 "PermanentHUD")


Its dont take more res. its a hud message like zp.

Evaldas.Grigas 10-30-2011 09:01

Re: How to make permanent HUD message?
 
Already done everything I wanted. Thanks for answers.


All times are GMT -4. The time now is 14:26.

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