AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   some keypress detecting (https://forums.alliedmods.net/showthread.php?t=306181)

man_s_our 03-19-2018 20:30

some keypress detecting
 
I'm trying to make some weapon switch related functions.
so I used this
Code:

        register_clcmd("slot1","s1",ADMIN_USER)
        register_clcmd("slot2","s2",ADMIN_USER)
        register_clcmd("slot3","s3",ADMIN_USER)
        register_clcmd("slot4","s4",ADMIN_USER)
        register_clcmd("slot5","s5",ADMIN_USER)

but it seems that none of the functions worked.
what's wrong here?

DjSoftero 03-20-2018 01:26

Re: some keypress detecting
 
what is s1 and how can it trigger slot1?

man_s_our 03-20-2018 04:45

Re: some keypress detecting
 
Quote:

Originally Posted by DjSoftero (Post 2583751)
what is s1 and how can it trigger slot1?

sn are the functions that must be done when player choose slotn

DjSoftero 03-20-2018 05:00

Re: some keypress detecting
 
yeah, sorry I forgot how the function works. thought I might have been onto something

Natsheh 03-20-2018 06:26

Re: some keypress detecting
 
Show the full code

man_s_our 03-20-2018 07:52

Re: some keypress detecting
 
Quote:

Originally Posted by Natsheh (Post 2583779)
Show the full code

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] = 0
    g_pCvars
[Hide_Flash] = 0
    g_pCvars
[Hide_All] = 1
    g_pCvars
[Hide_Rha] = 0
    g_pCvars
[Hide_Timer] = 0
    g_pCvars
[Hide_Money] = 0
    g_pCvars
[Hide_Cross] = 0
    g_pCvars
[Draw_Cross] = 0

    register_clcmd
("slot1","s1")
    
register_clcmd("slot2","s2")
    
register_clcmd("slot3","s3")
    
register_clcmd("slot4","s4")
    
register_clcmd("slot5","s5")

    
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 
s1(id,level,cid){
    
client_cmd(id"weapon_p228");
    
client_cmd(id"weapon_scout");
    
client_cmd(id"weapon_xm1014");
    
client_cmd(id"weapon_mac10");
    
client_cmd(id"weapon_aug");
    
client_cmd(id"weapon_ump45");
    
client_cmd(id"weapon_sg550");
    
client_cmd(id"weapon_galil");
    
client_cmd(id"weapon_famas");
    
client_cmd(id"weapon_awp");
    
client_cmd(id"weapon_mp5navy");
    
client_cmd(id"weapon_m249");
    
client_cmd(id"weapon_m3");
    
client_cmd(id"weapon_m4a1");
    
client_cmd(id"weapon_tmp");
    
client_cmd(id"weapon_g3sg1");
    
client_cmd(id"weapon_sg552");
    
client_cmd(id"weapon_ak47");
    
client_cmd(id"weapon_p90");
}
public 
s2(id,level,cid){
    
client_cmd(id"weapon_elite");
    
client_cmd(id"weapon_fiveseven");
    
client_cmd(id"weapon_usp");
    
client_cmd(id"weapon_glock18");
    
client_cmd(id"weapon_deagle");
}
public 
s3(id,level,cid){
    
client_cmd(id"weapon_knife");
}
public 
s4(id,level,cid){
    
client_cmd(id"weapon_hegrenade");
    
client_cmd(id"weapon_smokegrenade");
    
client_cmd(id"weapon_flashbang");
}
public 
s5(id,level,cid){
    
client_cmd(id"weapon_c4");
}
public 
Event_HLTV_New_Round()
{
    for(new 
ii<Hide_Hudi++)
    {
        if(
g_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)
    }
}
public 
show_huds(){
    
g_pCvars[Hide_Cal] = 1
    g_pCvars
[Hide_Flash] = 1
    g_pCvars
[Hide_All] = 0
    g_pCvars
[Hide_Rha] = 1
    g_pCvars
[Hide_Timer] = 1
    g_pCvars
[Hide_Money] = 1
    g_pCvars
[Hide_Cross] = 1
    g_pCvars
[Draw_Cross] = 0
}
public 
hide_huds(){
    
g_pCvars[Hide_Cal] = 0
    g_pCvars
[Hide_Flash] = 0
    g_pCvars
[Hide_All] = 1
    g_pCvars
[Hide_Rha] = 0
    g_pCvars
[Hide_Timer] = 0
    g_pCvars
[Hide_Money] = 0
    g_pCvars
[Hide_Cross] = 0
    g_pCvars
[Draw_Cross] = 0


the last 2 functions are made to be APIs so that the choosing menus can apear.

OciXCrom 03-20-2018 10:15

Re: some keypress detecting
 
You can't hook the slot commands like that.

man_s_our 03-20-2018 10:26

Re: some keypress detecting
 
Quote:

Originally Posted by OciXCrom (Post 2583814)
You can't hook the slot commands like that.

how to do this?

man_s_our 03-20-2018 20:46

Re: some keypress detecting
 
I've founde the way to do that.
by hooking othe console cmds and asking users to bind keys for it.
but I found a problem in setting API so I'll let it for other time.


All times are GMT -4. The time now is 20:16.

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