AlliedModders

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

Randomize 05-15-2012 03:59

How to make HUD permanent?
 
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

bazhenov93 05-15-2012 04:44

Re: How to make HUD permanent?
 
Quote:

Originally Posted by Randomize (Post 1709218)
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..
 



Randomize 05-15-2012 04:50

Re: How to make HUD permanent?
 
I want the structure code ;D

Randomize 05-15-2012 05:30

Re: How to make HUD permanent?
 
Quote:

Originally Posted by Hellrock (Post 1709253)
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..

Aooka 05-15-2012 06:30

Re: How to make HUD permanent?
 
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 }

Randomize 05-15-2012 06:39

Re: How to make HUD permanent?
 
i don't want to use cilent prethink @_@

bazhenov93 05-15-2012 06:42

Re: How to make HUD permanent?
 
Quote:

Originally Posted by Hellrock http://forums.alliedmods.net/images/...s/viewpost.gif
Maybe get_user_weapon(id, clip, ammo) instead of user_has_weapon(id, CSW_AWP)), uhh?
LEARN before post.

Hellrock 05-15-2012 06:58

Re: How to make HUD permanent?
 
Quote:

Originally Posted by bazhenov93 (Post 1709280)
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!

Randomize 05-15-2012 07:00

Re: How to make HUD permanent?
 
Dont fight here.. Moderator will banned you

bazhenov93 05-15-2012 07:01

Re: How to make HUD permanent?
 
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.


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

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