AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to remove HUD (https://forums.alliedmods.net/showthread.php?t=185379)

Randomize 05-16-2012 13:00

How to remove HUD
 
How to Remove Hud Message using /say command?

<VeCo> 05-16-2012 13:01

Re: How to remove HUD
 
What hudmessage?

Randomize 05-16-2012 13:04

Re: How to remove HUD
 
PHP Code:

//Crosshair Type
//Special thanks to <VeCo>

#include <amxmodx>
#include <engine>

#define PLUGIN "Crosshair Type"
#define VERSION "1.1"
#define AUTHOR "DavidJr"

// *restricted* sniper weapons
#define SNIPER_WEAPONS (1 << CSW_AWP | 1 << CSW_SCOUT | 1 << CSW_G3SG1 | 1 << CSW_SG550)
 
new sync
public plugin_init() {
    
register_plugin("PLUGIN","VERSION","DavidJr")
    
sync CreateHudSyncObj() // HUD sync object
 
    
new ent create_entity("info_target")
    
entity_set_string(ent,EV_SZ_classname,"dot_crosshair"// classname
    
entity_set_float(ent,EV_FL_nextthink,get_gametime() + 1.0// think every second
    
    //console command
    
register_concmd("show_menu_ch","cmd_show_menu_ch")
    
    
//thinking entity
    
register_think("cross_crosshair","cross_crosshair_think"// call "cross_crosshair_think" function on think
    
register_think("dot_crosshair","dot_crosshair_think"// call "dot_crosshair_think" function on think
    
register_think("round_crosshair","round_crosshair_think"// call "round_crosshair_think" function on think
}
 
public 
cross_crosshair_think(ent// entity thinks...
{
    
entity_set_float(ent,EV_FL_nextthink,get_gametime() + 1.0// continue thinking every second
 
    
if(!get_playersnum()) return // server is empty, there's no need to show HUD messages...
 
    
static players[32],numi,id
    get_players
(players,num,"a"// get all alive players in the server
 
    
for(i=0;i<num;i++) // loop trough them...
    
{
        
id players[i// store player index in a more convenient variable
 
        
if(<< get_user_weapon(id) & SNIPER_WEAPONS) continue // if this player is holding a sniper - continue with the next player
 
        // else, show the HUD message...
 
        
set_hudmessage(02550, -1.0, -1.0,  .holdtime 1.0// skip default values
        
ShowSyncHudMsg(id,sync"+"// show crosshair HUD
    
}
}  
public 
dot_crosshair_think(ent// entity thinks...
{
    
entity_set_float(ent,EV_FL_nextthink,get_gametime() + 1.0// continue thinking every second
 
    
if(!get_playersnum()) return // server is empty, there's no need to show HUD messages...
 
    
static players[32],numi,id
    get_players
(players,num,"a"// get all alive players in the server
 
    
for(i=0;i<num;i++) // loop trough them...
    
{
        
id players[i// store player index in a more convenient variable
 
        
if(<< get_user_weapon(id) & SNIPER_WEAPONS) continue // if this player is holding a sniper - continue with the next player
 
        // else, show the HUD message...
 
        
set_hudmessage(02550, -1.0, -1.0,  .holdtime 1.0// skip default values
        
ShowSyncHudMsg(id,sync"*"// show crosshair HUD
    
}
}  
public 
round_crosshair_think(ent// entity thinks...
{
    
entity_set_float(ent,EV_FL_nextthink,get_gametime() + 1.0// continue thinking every second
 
    
if(!get_playersnum()) return // server is empty, there's no need to show HUD messages...
 
    
static players[32],numi,id
    get_players
(players,num,"a"// get all alive players in the server
 
    
for(i=0;i<num;i++) // loop trough them...
    
{
        
id players[i// store player index in a more convenient variable
 
        
if(<< get_user_weapon(id) & SNIPER_WEAPONS) continue // if this player is holding a sniper - continue with the next player
 
        // else, show the HUD message...
 
        
set_hudmessage(02550, -1.0, -1.0,  .holdtime 1.0// skip default values
        
ShowSyncHudMsg(id,sync"o"// show crosshair HUD
    
}
}  
// Show Menu CH
public cmd_show_menu_ch(id)
{
    new 
menu menu_create("\yChoose Crosshair Type""menu_crosshair")
    
menu_additem(menu"Cross +""1"0)
    
menu_additem(menu"Dot *""2"0)
    
menu_additem(menu"Round o""3"0)
    
// Add more Options if you wish
    
    
menu_display(idmenu0)
}
// Menu CH
public menu_crosshair(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
data[6], iName[64], accesscallback
    menu_item_getinfo
(menuitemaccessdata5iName63callback)
    
    switch(
str_to_num(data))
    {
        case 
1register_concmd(cross,"cross_crosshair")
        case 
2register_concmd(cross,"dot_crosshair")
        case 
3register_concmd(cross,"round_crosshair")
        
// Add more Options if you wish
    
}
    
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED


I have give the menu :D but when i select it, the hud doesn't want to change

forget this:
case 1: register_concmd(cross,"cross_crosshair")
case 2: register_concmd(cross,"dot_crosshair")
case 3: register_concmd(cross,"round_crosshair")

it's slow hack part

<VeCo> 05-16-2012 13:06

Re: How to remove HUD
 
Don't use "bind", that's slowhacking.

Use only 1 entity with only 1 think and make a variable for the crosshair symbol...

Randomize 05-16-2012 13:09

Re: How to remove HUD
 
okay.. how? can i hook it like this? http://forums.alliedmods.net/showthr...ght=remove+hud

<VeCo> 05-16-2012 13:45

Re: How to remove HUD
 
1 Attachment(s)
Make a global variable like:

PHP Code:

new user_crosshair_type[33

Then change this:

PHP Code:

 menu_additem(menu"Cross +""1"0)
menu_additem(menu"Dot *""2"0)
menu_additem(menu"Round o""3"0

To this:

PHP Code:

 menu_additem(menu"Cross +""43"0// actually this 0 is set by default, you don't need to write it
menu_additem(menu"Dot *""42"0)
menu_additem(menu"Round o""111"0

Then change this:

PHP Code:

 switch(str_to_num(data))
{
case 
1register_concmd(cross,"cross_crosshair")
case 
2register_concmd(cross,"dot_crosshair")
case 
3register_concmd(cross,"round_crosshair")
// Add more Options if you wish


To this:

PHP Code:

user_crosshair_type[id] = str_to_num(data

Then change this:

PHP Code:

 set_hudmessage(02550, -1.0, -1.0, .holdtime 1.0// skip default values
ShowSyncHudMsg(id,sync"o"// show crosshair HUD 

To this

PHP Code:

 set_hudmessage(02550, -1.0, -1.0, .holdtime 1.0// skip default values
ShowSyncHudMsg(id,sync"%c",user_crosshair_type[id]) // show crosshair HUD 

And add:

PHP Code:

public client_connect(iduser_crosshair_type[id] = 111 // default crosshair is "o" 


So here is how does it works:

We set the "info" of the crosshair menu options as numbers 43, 42, 111. These numbers are actually character indexes that represent a character. In our case these are the indexes of the crosshair HUD characters - "+", "*" and "o".
When we select an option, the menu passes the "info" parameter of menu_additem to the "data" string in the menu handler. So, now we can set the selected character to the "user_crosshair_type" variable to store the user HUD crosshair character.
Then when we display the HUD message, we use "%c", which gets a character index and transfers it to a character. We get that index from our user_crosshair_type variable, so every player will see his own selected HUD crosshair.
On client connect we set the default HUD character for the player - that's 111 or the "o" character.

Here I made a simple program that displays the character ID by given character.
I also attached the source code (compiled with DEV C++), ready to use .exe file is in the bin folder. (That's not a virus, lol)

Randomize 05-16-2012 13:50

Re: How to remove HUD
 
wew.. thank you so much dude :D btw, what is cid? I'll try the code tomorrow, :)

Randomize 05-16-2012 19:55

Re: How to remove HUD
 
I got 2 Warnings notice when compiled it

Liverwiz 05-16-2012 20:14

Re: How to remove HUD
 
Quote:

Originally Posted by Randomize (Post 1710094)
wew.. thank you so much dude :D btw, what is cid? I'll try the code tomorrow, :)

cid is your command ID. I odn't really know what its for.....i just do what i'm told.

Randomize 05-16-2012 20:29

Re: How to remove HUD
 
Quote:

Originally Posted by Liverwiz (Post 1710343)
cid is your command ID. I odn't really know what its for.....i just do what i'm told.

I know it :D it's for user_crosshair_type[id]


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

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