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

informations hud help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tedaimlocks
Member
Join Date: Jan 2024
Old 01-23-2024 , 15:32   informations hud help
Reply With Quote #1

I need help with this following script , so i want to display roundsleft instead of timeleft because i dont use it anymore , and also remove the time from the code . I got the roundsleft plugin from here
https://forums.alliedmods.net/showthread.php?p=67909

PHP Code:
#include <amxmodx>
 
public plugin_init()
{
        
register_plugin("Informations in hud""1.0""Luci.");
       
        
set_task(1.0"info_hud",_,_,_,"b");
}
 
public 
info_hud()
{
        new 
hostname[62], map[32], timeleft get_timeleft(), ora[10];
       
        
get_cvar_string("hostname"hostnamecharsmax(hostname))
        
get_mapname(mapcharsmax(map))
        
get_time("%H:%M:%S"oracharsmax(ora))
 
 
        
set_hudmessage(random_num(050), random_num(050), random_num(050), -1.00.02)
        
show_hudmessage(0"%s^n Map: %s | Roundsleft: %d:%02d | Time: %s"hostnamemaptimeleft 60timeleft 60ora)


Last edited by DarkDeviL; 01-23-2024 at 22:18. Reason: Added CODE tag
tedaimlocks is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 01-23-2024 , 17:06   Re: informations hud help
Reply With Quote #2

use BB code [php]here...[/php] highlights the sma
__________________
mlibre is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-23-2024 , 22:55   Re: informations hud help
Reply With Quote #3

Ok, so what is your issue? In Scripting Help, you should describe your issue so that we have a better idea of what to look for and how to help you. If you have compiler errors, copy the text and put it in a post with [code][/code] tags. If you have run-time errors, grab the text from the log file and include that in your post with the code tags.
__________________

Last edited by fysiks; 01-23-2024 at 22:57.
fysiks is offline
tedaimlocks
Member
Join Date: Jan 2024
Old 01-24-2024 , 03:05   Re: informations hud help
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
Ok, so what is your issue? In Scripting Help, you should describe your issue so that we have a better idea of what to look for and how to help you. If you have compiler errors, copy the text and put it in a post with [code][/code] tags. If you have run-time errors, grab the text from the log file and include that in your post with the code tags.


well i tried to display the rounds left instead of timeleft but i couldnt do it
tedaimlocks is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 01-24-2024 , 08:21   Re: informations hud help
Reply With Quote #5

first of all hostname and get_mapname no need to check it every second, make it global by saving it in memory or cache whatever you want to call it...
__________________
mlibre is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-24-2024 , 21:30   Re: informations hud help
Reply With Quote #6

Quote:
Originally Posted by tedaimlocks View Post
well i tried to display the rounds left instead of timeleft but i couldnt do it
Do you get any errors in the error logs when you run the plugin? Is the plugin even running? Make sure that the plugin shows up in the output of "amxx list" and shows that it's in a good state. You should also consider adding "debug" after the .amxx file name in plugins.ini so that you get useful debug logs for errors.

If all of that shows no issues, you should add your own debug messaging to the function to make sure that the function is getting called properly and you can add various pieces of data into that debug message to determine what might be wrong. I use server_print() for my debug messages and then look at the server console to see what data it contains. One thing I would probably do is to simply use server_print() for the exact message you're trying to use with show_hudmessage() and make sure that works.

EDIT: I just tested it and it works exactly as you coded it. I would recommend that you fix the "holdtime" parameter so that you don't have a bunch of old versions of the message overlapping.
__________________

Last edited by fysiks; 01-24-2024 at 21:47.
fysiks is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 01-24-2024 , 22:53   Re: informations hud help
Reply With Quote #7

recompile roundsleft.sma
PHP Code:
new const PLUGINNAME[] = "Roundsleft"
new const VERSION[] = "2.4"
new const AUTHOR[] = "MisterJ"
/*

THANKS
========
Johnny got his gun : He created the concept and made the first version.


ROUNDSLEFT
==========
Allows the users to "say roundsleft" and remaining rounds will be displayed.
This is useful if you are using default hlds cvar mp_maxrounds set to some value.
There is also a command "amx_roundsleft" to view remaining rounds in console.


HOW TO INSTALL
==============
1. Name this file roundsleft.sma.
2. Compile it into roundsleft.amxx.
3. Put roundsleft.amxx into amxmodx/plugins directory.
4. Open up amxmodx/configs/plugins.ini and add a line to the end saying: roundsleft.amx
5. Done. Type reload in your server.


HOW TO USE
==========
say roundsleft, say rounds, say roundleft, say round
- all these will respond with remaining rounds if mp_maxrounds is set to anything higher than 0.

amx_roundsleft
- displays remaining rounds in console. Works also from server console.


VERSION
========
2.4

*/

#include <amxmodx>
#include <amxmisc>
#include <engine>

// Globals below
new g_teamScore[2]
// Globals above

public sayRoundsLeft(id) {
    new 
maxRounds get_cvar_num("mp_maxrounds")
    if (
id) {
        if (
maxRounds == 0) {
            
client_print(0print_chat"No rounds limit.")
        }
        else {
            new 
roundsleft maxRounds - (g_teamScore[0] + g_teamScore[1])
            
client_print(0print_chat"Remaining rounds: %d"roundsleft)
            
speakroundsleft(idroundsleft)
        }
    }

    return 
PLUGIN_CONTINUE
}

speakroundsleft(idroundsleft) {
    new 
numbers[256]
    
getnumbers(roundsleftnumbers255)
    
client_cmd(id"spk ^"%s round remaining^""numbers)
    
//client_print(0, print_chat, "%s round%s remain", numbers, roundsleft > 1 ? "s" : "")
}

public 
conRoundsLeft(id) {
    new 
maxRounds get_cvar_num("mp_maxrounds")
    if (
id)    console_print(id,"Remaining rounds: %d",maxRounds - (g_teamScore[0] + g_teamScore[1]))
    else 
server_print("Remaining rounds: %d",maxRounds - (g_teamScore[0] + g_teamScore[1]))

    return 
PLUGIN_HANDLED
}

public 
teamScore(id) {
    new 
team[2]
    
read_data(1,team,1)
    
g_teamScore[(team[0]=='C')? 1] = read_data(2)

    return 
PLUGIN_CONTINUE
}

/*
public newround_event(id) {
    if (is_user_bot(id))
        return PLUGIN_CONTINUE

    new maxRounds = get_cvar_num("mp_maxrounds")
    if (maxRounds) {
        set_hudmessage(0, 100, 0, -1.0, 0.65, 2, 0.02, 10.0, 0.01, 0.1, 2)
        show_hudmessage(id, "%d rounds remaining", maxRounds - (g_teamScore[0] + g_teamScore[1]))
        client_print(id, print_chat, "%d rounds remaining", maxRounds - (g_teamScore[0] + g_teamScore[1]))
    }

    return PLUGIN_CONTINUE
}
*/

public endround_event() {
    
server_print("endround_event, %d entities in game"entity_count())
    
set_task(2.0"endofroundspk")

    return 
PLUGIN_CONTINUE
}

public 
endofroundspk() {
    
//server_print("endofroundspk")
    
new maxRounds get_cvar_num("mp_maxrounds")
    new 
roundsleft maxRounds - (g_teamScore[0] + g_teamScore[1])
    new 
nextmap[64]
    
get_cvar_string("amx_nextmap"nextmap63)
    if (
maxRounds) {
        
set_hudmessage(255255255, -1.00.8500.03.00.00.5, -1)

        if (
roundsleft == 100)
        
show_hudmessage(0"100 rounds remaining"roundsleft)

        if (
roundsleft == 80)
        
show_hudmessage(0"80 rounds remaining"roundsleft)

        if (
roundsleft == 60)
        
show_hudmessage(0"60 rounds remaining"roundsleft)        

        if (
roundsleft == 50)
        
show_hudmessage(0"50 rounds remaining"roundsleft)

        if (
roundsleft == 40)
        
show_hudmessage(0"40 rounds remaining"roundsleft)    

        if (
roundsleft == 30)
        
show_hudmessage(0"30 rounds remaining"roundsleft)        

        if (
roundsleft == 20)
        
show_hudmessage(0"20 rounds remaining"roundsleft)

        if (
roundsleft == 10)
        
show_hudmessage(0"10 rounds remaining"roundsleft)

        if (
roundsleft == 5)
        
show_hudmessage(0"5 rounds remaining"roundsleft)
        
        if (
roundsleft == 1)
        
show_hudmessage(0"The last round"roundsleft)

        if (
roundsleft == 0)
        
show_hudmessage(0"Nextmap is %s..."nextmap)
            
        }


    if (
roundsleft 0) {

        if (
roundsleft == 90)
        
client_cmd(0"spk ^"ninety round remaining^"")

        if (
roundsleft == 80)
        
client_cmd(0"spk ^"eighty round remaining^"")

        if (
roundsleft == 70)
        
client_cmd(0"spk ^"seventy round remaining^"")

        if (
roundsleft == 60)
        
client_cmd(0"spk ^"sixty round remaining^"")        

        if (
roundsleft == 50)
        
client_cmd(0"spk ^"fifty round remaining^"")
    
        if (
roundsleft == 40)
        
client_cmd(0"spk ^"fourty round remaining^"")

        if (
roundsleft == 30)
        
client_cmd(0"spk ^"thirty round remaining^"")

        if (
roundsleft == 20)
        
client_cmd(0"spk ^"twenty round remaining^"")

        if (
roundsleft == 10)
        
client_cmd(0"spk ^"ten round remaining^"")

        if (
roundsleft == 5)
        
client_cmd(0"spk ^"five round remaining^"")

        if (
roundsleft == 1)
        
client_cmd(0"spk ^"the last round^"")

        }
    

    }



stock getnumbers(numberwordnumbers[], length) {
    if (
number 0) {
        
format(wordnumberslength"error")
        return
    }

    new 
numberstr[20]
    
num_to_str(numbernumberstr19)
    new 
stlen strlen(numberstr), bool:getzero falsebool:jumpnext false
    
if (stlen == 1)
        
getzero true

    
do {
        if (
jumpnext)
            
jumpnext false
        
else if (numberstr[0] != '0') {
            switch (
stlen) {
                case 
9: {
                    if (
getsingledigit(numberstr[0], wordnumberslength))
                        
format(wordnumberslength"%s hundred%s"wordnumbersnumberstr[1] == '0' && numberstr[2] == '0' " million" "")
                }
                case 
8: {
                    
jumpnext gettens(wordnumberslengthnumberstr)
                    if (
jumpnext)
                        
format(wordnumberslength"%s million"wordnumbers)
                }
                case 
7: {
                    
getsingledigit(numberstr[0], wordnumberslength)
                    
format(wordnumberslength"%s million"wordnumbers)
                }
                case 
6: {
                    if (
getsingledigit(numberstr[0], wordnumberslength))
                        
format(wordnumberslength"%s hundred%s"wordnumbersnumberstr[1] == '0' && numberstr[2] == '0' " thousand" "")
                }
                case 
5: {
                    
jumpnext gettens(wordnumberslengthnumberstr)
                    if (
numberstr[0] == '1' || numberstr[1] == '0')
                        
format(wordnumberslength"%s thousand"wordnumbers)
                }
                case 
4: {
                    
getsingledigit(numberstr[0], wordnumberslength)
                    
format(wordnumberslength"%s thousand"wordnumbers)
                }
                case 
3: {
                    
getsingledigit(numberstr[0], wordnumberslength)
                    
format(wordnumberslength"%s hundred"wordnumbers)
                }
                case 
2jumpnext gettens(wordnumberslengthnumberstr)
                case 
1: {
                    
getsingledigit(numberstr[0], wordnumberslengthgetzero)
                    break 
// could've trimmed, but of no use here
                
}
                default: {
                    
format(wordnumberslength"%s TOO LONG"wordnumbers)
                    break
                }
            }
        }

        
jghg_trim(numberstrlength1)
        
stlen strlen(numberstr)
    }
    while (
stlen 0)

    
// Trim a char from left if first char is a space (very likely)
    
if (wordnumbers[0] == ' ')
        
jghg_trim(wordnumberslength1)
}

// Returns true if next char should be jumped
stock bool:gettens(wordnumbers[], lengthnumberstr[]) {
    new 
digitstr[11], bool:dont falsebool:jumpnext false
    
switch (numberstr[0]) {
        case 
'1': {
            
jumpnext true
            
switch (numberstr[1]) {
                case 
'0'digitstr "ten"
                
case '1'digitstr "eleven"
                
case '2'digitstr "twelve"
                
case '3'digitstr "thirteen"
                
case '4'digitstr "fourteen"
                
case '5'digitstr "fifteen"
                
case '6'digitstr "sixteen"
                
case '7'digitstr "seventeen"
                
case '8'digitstr "eighteen"
                
case '9'digitstr "nineteen"
                
default: digitstr "TEENSERROR"
            
}
        }
        case 
'2'digitstr "twenty"
        
case '3'digitstr "thirty"
        
case '4'digitstr "fourty"
        
case '5'digitstr "fifty"
        
case '6'digitstr "sixty"
        
case '7'digitstr "seventy"
        
case '8'digitstr "eighty"
        
case '9'digitstr "ninety"
        
case '0'dont true // do nothing
        
default : digitstr "TENSERROR"
    
}
    if (!
dont)
        
format(wordnumberslength"%s %s"wordnumbersdigitstr)

    return 
jumpnext
}

// Returns true when sets, else false
stock getsingledigit(digit[], numbers[], lengthbool:getzero false) {
    new 
digitstr[11]
    switch (
digit[0]) {
        case 
'1'digitstr "one"
        
case '2'digitstr "two"
        
case '3'digitstr "three"
        
case '4'digitstr "four"
        
case '5'digitstr "five"
        
case '6'digitstr "six"
        
case '7'digitstr "seven"
        
case '8'digitstr "eight"
        
case '9'digitstr "nine"
        
case '0': {
            if (
getzero)
                
digitstr "zero"
            
else
                return 
false
        
}
        default : 
digitstr "digiterror"
    
}
    
format(numberslength"%s %s"numbersdigitstr)

    return 
true
}

stock jghg_trim(stringtotrim[], lencharstotrimbool:fromleft true) {
    if (
charstotrim <= 0)
        return

    if (
fromleft) {
        new 
maxlen strlen(stringtotrim)
        if (
charstotrim maxlen)
            
charstotrim maxlen

        format
(stringtotrimlen"%s"stringtotrim[charstotrim])
    }
    else {
        new 
maxlen strlen(stringtotrim) - charstotrim
        
if (maxlen 0)
            
maxlen 0

        format
(stringtotrimmaxlen"%s"stringtotrim)
    }
}

public 
addrounds(idlevelcid) {
    if (!
cmd_access(idlevelcid2))
        return 
PLUGIN_HANDLED

    
new arg[32]
    
read_argv(1arg31)
    new 
arglength strlen(arg)
    for (new 
0arglengthi++) {
        if (!
isdigit(arg[i])) {
            if (
!= || arg[0] != '-') {
                
console_print(id"Error: Enter only numbers, ie ^"amx_addrounds 10^"")
                return 
PLUGIN_HANDLED
            
}
        }
    }

    new 
roundstoadd str_to_num(arg)

    if (
roundstoadd == 0) {
        
console_print(id"Error: Well duuuh. Enter a positive or negative value, ie ^"amx_addrounds 10^"")
        return 
PLUGIN_HANDLED
    
}

    new 
originalmaxrounds get_cvar_num("mp_maxrounds")

    new 
newmaxrounds originalmaxrounds roundstoadd

    
if (newmaxrounds 1)
        
newmaxrounds 1

    
new roundschanged newmaxrounds originalmaxrounds

    
new Float:displayrounds float(roundschanged)
    
displayrounds *= displayrounds
    displayrounds 
floatsqroot(displayrounds)

    
console_print(id"%sing %d rounds..."roundschanged "Add" "Remov"floatround(displayrounds))

    
set_cvar_num("mp_maxrounds"newmaxrounds)

    
conRoundsLeft(id)

    return 
PLUGIN_HANDLED
}

public 
_get_roundsleft()
    return 
get_cvar_num("mp_maxrounds") - (g_teamScore[0] + g_teamScore[1])

public 
plugin_natives()
{
    
register_native("get_roundsleft""_get_roundsleft")
}

public 
plugin_init() {
    
register_plugin(PLUGINNAMEVERSIONAUTHOR)
    
register_clcmd("say round""sayRoundsLeft")
    
register_clcmd("say rounds""sayRoundsLeft")
     
register_clcmd("say roundleft""sayRoundsLeft")
     
register_clcmd("say roundsleft""sayRoundsLeft"0"- displays remaining rounds")
     
register_concmd("amx_roundsleft""conRoundsLeft"0"- displays remaining rounds")
     
register_concmd("amx_addrounds""addrounds"ADMIN_CFG"<rounds> - add/remove remaining rounds")
    
register_event("TeamScore""teamScore""ab")
    
//register_event("ResetHUD", "newround_event", "b")
    /*
    register_event("SendAudio","endround_event","a","2&%!MRAD_terwin","2&%!MRAD_ctwin","2&%!MRAD_rounddraw")
    register_event("TextMsg","endround_event","a","2&#Game_C","2&#Game_w")
    register_event("TextMsg","endround_event","a","2&#Game_will_restart_in")
    */
    /*
    register_logevent("death_event",5,"1=killed","3=with")
    // L 03/08/2004 - 13:32:34: "xian<2><BOT><CT>" killed "SuperKaka<1><BOT><TERRORIST>" with "usp"
    // L 03/08/2004 - 13:32:34: World triggered "Round_End"
    */
    // L 03/08/2004 - 13:32:34: World triggered "Round_End"
    /*register_logevent("endround_event", 3, "2=Round_End")
    register_logevent("endround_event", 3, "1=Round_End")
    register_logevent("endround_event", 3, "0=Round_End")
    register_logevent("endround_event", 3, "3=Round_End")*/
    
register_logevent("endround_event"2"0=World triggered""1=Round_End")

PHP Code:
#include <amxmodx>
 
native get_roundsleft()

public 
plugin_init()
{
        
register_plugin("Informations in hud""1.0""Luci.");
       
        
set_task(1.0"info_hud", .flags="b");
}
 
public 
info_hud()
{
        new 
hostname[62], map[32], ora[10];
       
        
get_cvar_string("hostname"hostnamecharsmax(hostname))
        
get_mapname(mapcharsmax(map))
        
get_time("%H:%M:%S"oracharsmax(ora))
 
 
        
set_hudmessage(random_num(050), random_num(050), random_num(050), -1.00.02, .holdtime=1.0, .channel=4)
        
show_hudmessage(0"%s^n Map: %s | Roundsleft: %d | Time: %s"hostnamemapget_roundsleft(), ora)

__________________
bigdaddy424 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-24-2024 , 23:25   Re: informations hud help
Reply With Quote #8

If you were just having issues getting the value of "rounds left", you should have said exactly that. I would probably just edit that plugin to add your message and then you have direct access to the values that plugin generates. No need to deal with natives as the person above has done.

This is why saying "I couldn't do it" or "it doesn't work" is very unhelpful for being able to help you reliably.
__________________

Last edited by fysiks; 01-24-2024 at 23:26.
fysiks is offline
tedaimlocks
Member
Join Date: Jan 2024
Old 01-26-2024 , 09:51   Re: informations hud help
Reply With Quote #10

Quote:
Originally Posted by mlibre View Post
what did you try
i got it to work now , dont need help anymore
tedaimlocks 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 19:59.


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