Raised This Month: $ Target: $400
 0% 

Using the plugin with variables


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bibu
Veteran Member
Join Date: Sep 2010
Old 06-12-2011 , 11:31   Using the plugin with variables
Reply With Quote #1

I am trying to change this plugin with variables individual for each player. So it doesn't have to use any cvars at all. I created a menu for it and now I need to check the variables. But as the original plugin is with enums, I don't have any idea how I can here check for example for the variable of the player:

PHP Code:
public Event_ResetHUD(id)
{
    if 
//which variable
    
{
           
//do what?
    
}
    if 
//which variable
    
{
           
//do what else?
    
}

The same for "Event_HideWeapon".

Here is the list of the variables and the whole plugin:

PHP Code:
new bool:hud_money[33]
new 
bool:hud_timer[33]
new 
bool:hud_flashlight[33]
new 
bool:hud_radar_hp_ap[33]
new 
bool:hud_crosshair[33]
new 
bool:hud_wpnlist[33
PHP Code:
#include <amxmodx> 
#include <fakemeta>
#include <hamsandwich>

#define VERSION "0.6" 

const HUD_HIDE_CAL 1<<0
const HUD_HIDE_FLASH 1<<1
const HUD_HIDE_ALL 1<<2    
const HUD_HIDE_RHA 1<<3
const HUD_HIDE_TIMER 1<<4
const HUD_HIDE_MONEY 1<<5
const HUD_HIDE_CROSS 1<<6
const HUD_DRAW_CROSS 1<<7

const HIDE_GENERATE_CROSSHAIR HUD_HIDE_FLASH|HUD_HIDE_RHA|HUD_HIDE_TIMER|HUD_HIDE_MONEY|HUD_DRAW_CROSS

#define    m_iHideHUD            361
#define    m_iClientHideHUD        362
#define    m_pClientActiveItem        374

enum _:Hide_Hud {
    
Hide_Cal,
    
Hide_Flash,
    
Hide_All,
    
Hide_Rha,
    
Hide_Timer,
    
Hide_Money,
    
Hide_Cross,
    
Draw_Cross
}

new 
g_bitHudFlags

new g_pCvars[Hide_Hud]

public 
plugin_init() 

    
register_plugin("HUD Customizer"VERSION"Igoreso/ConnorMcLeod"
    
    
g_pCvars[Hide_Cal] = register_cvar("amx_hud_hide_cross_ammo_weaponlist""0")
    
g_pCvars[Hide_Flash] = register_cvar("amx_hud_hide_flashlight""1")
    
g_pCvars[Hide_All] = register_cvar("amx_hud_hide_all""1")
    
g_pCvars[Hide_Rha] = register_cvar("amx_hud_hide_radar_health_armor""1")
    
g_pCvars[Hide_Timer] = register_cvar("amx_hud_hide_timer""1")
    
g_pCvars[Hide_Money] = register_cvar("amx_hud_hide_money""0")
    
g_pCvars[Hide_Cross] = register_cvar("amx_hud_hide_crosshair""0")
    
g_pCvars[Draw_Cross] = register_cvar("amx_hud_draw_crosshair""0")

    
register_event("HLTV""Event_HLTV_New_Round""a""1=0""2=0")

    
register_event("ResetHUD""Event_ResetHUD""b")
    
register_event("HideWeapon""Event_HideWeapon""b")

    
Event_HLTV_New_Round()
}

public 
Event_HLTV_New_Round()
{
    for(new 
ii<Hide_Hudi++)
    {
        if( 
get_pcvar_numg_pCvars[i] ) )
        {
            
g_bitHudFlags |= 1<<i
        
}
    }
}

public 
Event_ResetHUD(id)
{
    if( 
g_bitHudFlags )
    {
        
set_pdata_int(idm_iClientHideHUD0)
        
set_pdata_int(idm_iHideHUDg_bitHudFlags)
    }    
}

public 
Event_HideWeaponid )
{
    new 
iFlags read_data(1)
    if( 
g_bitHudFlags && (iFlags g_bitHudFlags != g_bitHudFlags) )
    {
        
set_pdata_int(idm_iClientHideHUD0)
        
set_pdata_int(idm_iHideHUDiFlags|g_bitHudFlags)
    }

    if( 
iFlags HIDE_GENERATE_CROSSHAIR && !(g_bitHudFlags HUD_DRAW_CROSS) && is_user_alive(id) )
    {
        
set_pdata_cbase(idm_pClientActiveItemFM_NULLENT)
    }

__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-12-2011 , 12:29   Re: Using the plugin with variables
Reply With Quote #2

To make this per-player specific settings you only need one array with a dimension of 33 (each player would have their own g_bitHudFlags)

Something like this:

PHP Code:
#include <amxmodx> 
#include <fakemeta>
#include <hamsandwich>

#define VERSION "0.6" 

const HUD_HIDE_CAL 1<<0
const HUD_HIDE_FLASH 1<<1
const HUD_HIDE_ALL 1<<2    
const HUD_HIDE_RHA 1<<3
const HUD_HIDE_TIMER 1<<4
const HUD_HIDE_MONEY 1<<5
const HUD_HIDE_CROSS 1<<6
const HUD_DRAW_CROSS 1<<7

const HIDE_GENERATE_CROSSHAIR HUD_HIDE_FLASH|HUD_HIDE_RHA|HUD_HIDE_TIMER|HUD_HIDE_MONEY|HUD_DRAW_CROSS

#define    m_iHideHUD            361
#define    m_iClientHideHUD        362
#define    m_pClientActiveItem        374

new g_bitHudFlags[33]

public 
plugin_init() 

    
register_plugin("HUD Customizer"VERSION"Igoreso/ConnorMcLeod"
    
    
register_event("ResetHUD""Event_ResetHUD""b")
    
register_event("HideWeapon""Event_HideWeapon""b")
}

public 
Event_ResetHUD(id)
{
    if( 
g_bitHudFlags[id] )
    {
        
set_pdata_int(idm_iClientHideHUD0)
        
set_pdata_int(idm_iHideHUDg_bitHudFlags[id])
    }    
}

public 
Event_HideWeaponid )
{
    new 
iFlags read_data(1)
    if( 
g_bitHudFlags[id] && (iFlags g_bitHudFlags[id] != g_bitHudFlags[id]) )
    {
        
set_pdata_int(idm_iClientHideHUD0)
        
set_pdata_int(idm_iHideHUDiFlags|g_bitHudFlags[id])
    }

    if( 
iFlags HIDE_GENERATE_CROSSHAIR && !(g_bitHudFlags[id] & HUD_DRAW_CROSS) && is_user_alive(id) )
    {
        
set_pdata_cbase(idm_pClientActiveItemFM_NULLENT)
    }

__________________
fysiks is online now
bibu
Veteran Member
Join Date: Sep 2010
Old 06-12-2011 , 12:31   Re: Using the plugin with variables
Reply With Quote #3

But I want all of these functions seperetely activated/deactivated.
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-12-2011 , 12:37   Re: Using the plugin with variables
Reply With Quote #4

Quote:
Originally Posted by bibu View Post
But I want all of these functions seperetely activated/deactivated.
You can set/remove them individually but you need the bit flags either way when using set_pdata_int(). You will just need to write those functions to do it. Bugsy's bitwise functions tutorial will help you set and unset bits in for g_bitHudFlags[id].
__________________
fysiks is online now
bibu
Veteran Member
Join Date: Sep 2010
Old 06-12-2011 , 16:47   Re: Using the plugin with variables
Reply With Quote #5

You didn't understand what I am asking for, look I only need to check the variable, so it would be like this:

PHP Code:
public Event_ResetHUD(id)
{
    if(
hud_money[id])
    {
           
//do or set what?
    
}
    if(
hud_timer[id])
    {
           
//do or set what else?
    
}
     
/*still continue the check of the other variables */

__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-12-2011 , 16:55   Re: Using the plugin with variables
Reply With Quote #6

Ok . . . you're correct, I don't understand the quesiton. In fact, now, I have no clue what the question is, lol.

Though, I did honestly think that my first suggestion would provide a solution to your original intent (making the HUD settings per-player).
__________________
fysiks is online now
bibu
Veteran Member
Join Date: Sep 2010
Old 06-12-2011 , 17:04   Re: Using the plugin with variables
Reply With Quote #7

You were talking about this, only one variable:

PHP Code:
    if( g_bitHudFlags[id] ) 
    { 
And I am talking about the others, you're using just one.
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-12-2011 , 17:08   Re: Using the plugin with variables
Reply With Quote #8

Quote:
Originally Posted by bibu View Post
You were talking about this, only one variable:

PHP Code:
    if( g_bitHudFlags[id] ) 
    { 
And I am talking about the others, you're using just one.
Correct. The one variable that I'm using uses bit flags so it is effectively 32 variables in one integer.

Was I correct in assuming that your overall goal is to make it so each individual player can choose which of the features are enabled or disabled?
__________________
fysiks is online now
bibu
Veteran Member
Join Date: Sep 2010
Old 06-13-2011 , 06:28   Re: Using the plugin with variables
Reply With Quote #9

Quote:
Originally Posted by fysiks View Post
Was I correct in assuming that your overall goal is to make it so each individual player can choose which of the features are enabled or disabled?
Exactly yes. But still I would like to check them separately.
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 06-13-2011 , 07:09   Re: Using the plugin with variables
Reply With Quote #10

Then use bitsums combined with a array like fysiks explained in his post.

You can set/unset/check them individually for each player:
Code:
if(g_bitHudFlags[id] & HUD_HIDE_MONEY)
{
    // money are hidden
}
else
{
    // money are not hidden
}
Code:
g_bitHudFlags[id] |= HUD_HIDE_MONEY // hide money

g_bitHudFlags[id] &= ~(HUD_HIDE_MONEY) // unhide money
The same goes with all bitsum flags defined in fysiks' code.
__________________
Hunter-Digital is offline
Reply


Thread Tools
Display Modes

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 23:27.


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