Raised This Month: $ Target: $400
 0% 

informations hud help


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 00:33.


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