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

How to make HUD permanent?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 05-15-2012 , 03:59   How to make HUD permanent?
Reply With Quote #1

Code:
/* Plugin generated by AMXX-Studio */
//Special thanks to Connor McLeod
//Crosshair by DavidJr

/*
    a     p228
    b     hegrenade
    c     xm1014    
    d     c4
    e     mac10
    f     aug
    g     smokegrenade
    h     elite
    i     fiveseven
    j     ump45
    k     galil
    l     famas
    m     usp
    n     glock18
    o     mp5navy
    p     m249
    q     m3
    r     m4a1
    s     tmp
    t     flashbang
    u     deagle
    v     sg552
    w    ak47
    x     knife
    y     p90
*/

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define PLUGIN "Dot Crosshair"
#define VERSION "1.0"
#define AUTHOR "DavidJr"

#define MAX_PLAYERS    32

#define HIDEHUD_CROSSHAIR    (1<<6)

#define m_iHideHUD                361

#define HideWeaponCrosshair(%1)    ( g_iFlags & (1<<%1) )

new g_iOldWeapon[MAX_PLAYERS+1]

new g_iFlags

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    //Register Concmd
    register_concmd("dot_crosshair","ShowCH")
    register_concmd("weapon_no_crosshair", "AdminCommand_Crosshair", ADMIN_CFG, " - <flags>")
    
    //Register Event
    register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
    register_event("ResetHUD", "Event_ResetHUD", "be")
}
public ShowCH(id)
{
    set_hudmessage(0, 255, 0, -1.0, -1.0, 0, 6.0, 999.0)
    show_hudmessage(id, ".")
}
public Event_ResetHUD(id)
{
    g_iOldWeapon[id] = 0
}

public Event_CurWeapon(id)
{
    new iCurWeapon = read_data(2)
    new iOldWeapon = g_iOldWeapon[id]

    if( iCurWeapon != iOldWeapon )
    {
        g_iOldWeapon[id] = iCurWeapon

        if( HideWeaponCrosshair(iCurWeapon) )
        {
            set_pdata_int(id, m_iHideHUD, get_pdata_int(id, m_iHideHUD) | HIDEHUD_CROSSHAIR)
        }
        else if( HideWeaponCrosshair( iOldWeapon ) )
        {
            set_pdata_int(id, m_iHideHUD, get_pdata_int(id, m_iHideHUD) & ~HIDEHUD_CROSSHAIR)
        }
    }
}

public AdminCommand_Crosshair(id, level, cid)
{
    if( cmd_access(id, level, cid, 2) )
    {
        new szFlags[26]
        read_argv(1, szFlags, charsmax(szFlags))

        static const iWeaponsIds[] = {CSW_P228, CSW_HEGRENADE, CSW_XM1014, CSW_C4, CSW_MAC10, CSW_AUG, CSW_SMOKEGRENADE, 
                                CSW_ELITE, CSW_FIVESEVEN, CSW_UMP45, CSW_GALIL, CSW_FAMAS, CSW_USP, CSW_GLOCK18, 
                                CSW_MP5NAVY, CSW_M249, CSW_M3, CSW_M4A1, CSW_TMP, CSW_FLASHBANG, CSW_DEAGLE, CSW_SG552, 
                                CSW_AK47, CSW_KNIFE, CSW_P90}  

        new i, cLetter, iVal
        g_iFlags = 0

        while( (cLetter = szFlags[i++]) )
        {
            iVal = cLetter - 'a'
            if( 0 <= iVal < sizeof(iWeaponsIds) )
            {
                g_iFlags |= (1<<iWeaponsIds[iVal])
            }
        }
    }
    return PLUGIN_HANDLED
}
I'm trying to make new crosshair using HUD, here is the screenshot:
[IMG]http://img29.**************/img29/6169/39420139.jpg[/IMG]

Also how to remove the hud when player using Sniper? And I want use this symbol "•" But in game it doesn't appeared

Last edited by Randomize; 05-15-2012 at 04:03.
Randomize is offline
bazhenov93
Veteran Member
Join Date: Oct 2010
Old 05-15-2012 , 04:44   Re: How to make HUD permanent?
Reply With Quote #2

Quote:
Originally Posted by Randomize View Post
Also how to remove the hud when player using Sniper?
Don't know what sniper you talking about, but.;

Anyway, check if the player has weapon name

PHP Code:
if(user_has_weapon(idCSW_AWP))
// your code from hud..
 


Last edited by bazhenov93; 05-15-2012 at 04:44.
bazhenov93 is offline
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 05-15-2012 , 04:50   Re: How to make HUD permanent?
Reply With Quote #3

I want the structure code ;D
Randomize is offline
Old 05-15-2012, 05:28
Hellrock
This message has been deleted by Hellrock. Reason: nevermind
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 05-15-2012 , 05:30   Re: How to make HUD permanent?
Reply With Quote #4

Quote:
Originally Posted by Hellrock View Post
Maybe get_user_weapon(id, clip, ammo) instead of user_has_weapon(id, CSW_AWP)), uhh?

Example:
PHP Code:
if(get_user_weapon(id) == CSW_AWP)
{
     
// code

Sir, I just want to remove the hud when player bought Sniper, and show the hud again when players using other weapons..
Randomize is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 05-15-2012 , 06:30   Re: How to make HUD permanent?
Reply With Quote #5

Code:
// In your plugin_init new iEnt = create_entity( "info_target" ); set_pev( iEnt, pev_classname, "permanent_hud" ); register_think( "permanent_hud", "thinkPermanentHud" ); set_pev( iEnt, pev_nextthink, 30.0 ); // A new function public thinkPermanentHud( iEnt ) {     set_pev( iEnt, pev_nextthink, 30.0 );     // your Hud message }
__________________
Pawn ? Useless

Last edited by Aooka; 05-15-2012 at 06:30.
Aooka is offline
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 05-15-2012 , 06:39   Re: How to make HUD permanent?
Reply With Quote #6

i don't want to use cilent prethink @_@
Randomize is offline
bazhenov93
Veteran Member
Join Date: Oct 2010
Old 05-15-2012 , 06:42   Re: How to make HUD permanent?
Reply With Quote #7

Quote:
Originally Posted by Hellrock
Maybe get_user_weapon(id, clip, ammo) instead of user_has_weapon(id, CSW_AWP)), uhh?
LEARN before post.
bazhenov93 is offline
Hellrock
Junior Member
Join Date: Sep 2010
Location: Ukraine
Old 05-15-2012 , 06:58   Re: How to make HUD permanent?
Reply With Quote #8

Quote:
Originally Posted by bazhenov93 View Post
LEARN before post.
Learn you are. Why u post user_has_weapon(id, CSW_AWP), if this is not need to him!?
This is check only, if is user have AWP in inventory, but not current weapon in hands!

OFFTOP!
Hellrock is offline
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 05-15-2012 , 07:00   Re: How to make HUD permanent?
Reply With Quote #9

Dont fight here.. Moderator will banned you
Randomize is offline
bazhenov93
Veteran Member
Join Date: Oct 2010
Old 05-15-2012 , 07:01   Re: How to make HUD permanent?
Reply With Quote #10

Not sure about this, atm I can't test it, also I dont remember the working code, but test it and tell if is working..

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
 
#define PLUGIN "Dot Crosshair"
#define VERSION "1.0"
#define AUTHOR "DavidJr"
 
 
#define TASKID 210
#define UPDATE 0.50
 
 
#define MAX_PLAYERS    32
 
#define HIDEHUD_CROSSHAIR    (1<<6)
 
#define m_iHideHUD                361
 
#define HideWeaponCrosshair(%1)    ( g_iFlags & (1<<%1) )
 
new SyncObj[4]
 
new 
g_iOldWeapon[MAX_PLAYERS+1]
 
new 
g_iFlags
 
public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
 
    
//Register Concmd
    
register_concmd("dot_crosshair","ShowCH")
    
register_concmd("weapon_no_crosshair""AdminCommand_Crosshair"ADMIN_CFG" - <flags>")
 
    
//Register Event
    
register_event("CurWeapon""Event_CurWeapon""be""1=1")
    
register_event("ResetHUD""Event_ResetHUD""be")
    
set_task(UPDATE "ShowCH"TASKID__"b")
 
new 
i
for(04i++)
SyncObj[i] = CreateHudSyncObj(1)
 
}
 
public 
ShowCH(id)
{
set_hudmessage(02550, -1.0, -1.00UPDATE+0.10.51.01.0, -1)
ShowSyncHudMsg(idSyncObj[0], ".")
 
}
 
if(
user_has_weapon(idCSW_AWP))
 
new 
i
for(04i++)
ClearSyncHud(idSyncObj[i])
remove_task(TASKID)
 
else if(!
user_has_weapon(idCSW_AWP))
set_task(UPDATE "ShowCH"TASKID__"b")
 
}  
 
 
public 
Event_ResetHUD(id)
{
    
g_iOldWeapon[id] = 0
}
 
public 
Event_CurWeapon(id)
{
    new 
iCurWeapon read_data(2)
    new 
iOldWeapon g_iOldWeapon[id]
 
    if( 
iCurWeapon != iOldWeapon )
    {
        
g_iOldWeapon[id] = iCurWeapon
 
        
if( HideWeaponCrosshair(iCurWeapon) )
        {
            
set_pdata_int(idm_iHideHUDget_pdata_int(idm_iHideHUD) | HIDEHUD_CROSSHAIR)
        }
        else if( 
HideWeaponCrosshairiOldWeapon ) )
        {
            
set_pdata_int(idm_iHideHUDget_pdata_int(idm_iHideHUD) & ~HIDEHUD_CROSSHAIR)
        }
    }
}
 
public 
AdminCommand_Crosshair(idlevelcid)
{
    if( 
cmd_access(idlevelcid2) )
    {
        new 
szFlags[26]
        
read_argv(1szFlagscharsmax(szFlags))
 
        static const 
iWeaponsIds[] = {CSW_P228CSW_HEGRENADECSW_XM1014CSW_C4CSW_MAC10CSW_AUGCSW_SMOKEGRENADE
                                
CSW_ELITECSW_FIVESEVENCSW_UMP45CSW_GALILCSW_FAMASCSW_USPCSW_GLOCK18
                                
CSW_MP5NAVYCSW_M249CSW_M3CSW_M4A1CSW_TMPCSW_FLASHBANGCSW_DEAGLECSW_SG552
                                
CSW_AK47CSW_KNIFECSW_P90}  
 
        new 
icLetteriVal
        g_iFlags 
0
 
        
while( (cLetter szFlags[i++]) )
        {
            
iVal cLetter 'a'
            
if( <= iVal sizeof(iWeaponsIds) )
            {
                
g_iFlags |= (1<<iWeaponsIds[iVal])
            }
        }
    }
    return 
PLUGIN_HANDLED

It may be wrong, so you can trie use code from this plugin.
bazhenov93 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 03:43.


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