AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   hud help? (https://forums.alliedmods.net/showthread.php?t=184691)

Sum 05-07-2012 18:28

hud help?
 
heyo could u make that plugin will show this hud mess. every X seconds please?

Code:

#include <amxmodx>

new const PLUGIN[] = "Hud Messege with Hostname, Current & TimeLeft";
new const VERSION[] = "1.0";
new const AUTHOR[] = "MercedeS";
new const HOTNAME[] = "Hostname";

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
}

public client_putinserver()
{
new map[33];
get_mapname(map,32);
new timeleft = get_timeleft();
set_hudmessage(255, 250, 205, -1.0, 0.0, 1, 6.0, 1.0) ;
show_hudmessage(0, "%s - CURRENT MAP:^n%s^nTIMELEFT: %s", HOTNAME, map, timeleft);
set_task(0.9, "client_putinserver");
}


Liverwiz 05-07-2012 22:17

Re: hud help?
 
Code:

new Float:repTime = 1.0    // this sets how many seconds you want between each show
set_task(repTime, "showMsg", 0, .flags="b")

PHP Code:

public client_putinserver() 
{
    
showMsg()
}
public 
showMsg()
{
    new 
map[33], timeleft[9]
    
get_mapname(map,32)
    new 
seconds get_timeleft()%60
    
new minutes floatround( (get_timeleft() - seconds) / 60 )
    
format(timeleft8"%d:%d"minutesseconds)
    
set_hudmessage(255250205, -1.00.016.01.0
    
show_hudmessage(0"%s - CURRENT MAP:^n%s^nTIMELEFT: %s"HOTNAMEmaptimeleft)
    return 
1


if my math for determining minutes and seconds is correct.

corrections: -set_task function needs args in order to repeat the task :rtfm:
-you shouldn't put set_task in the client_putinserver function; it'll set the task as many times as people join
-%s signifies you're showing a string. while your variable was defined as an int
-timeleft returns the time left in seconds: not very user friendly, so i put it to a string w/ the min:sec for you (assuming my math is correct)

NOTE: put the first code block into your plugin_init, that will initialize it properly.
ALSO: someone check his set_hudmessage i'm too tired to deal with that bloody function call right now. too man god damn periods and commas. it hurts my eyes

deadman909 07-31-2012 08:42

Re: hud help?
 
Why dont you just used amxx.cfg
You can make new Huds there already and you can set every amount of seconds you want a new one to appear.


All times are GMT -4. The time now is 00:25.

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