AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Single shot deagle (https://forums.alliedmods.net/showthread.php?t=295324)

Airkish 03-22-2017 13:47

Single shot deagle
 
Need help with deagle ammo.

How do u make so u have 1 ammo on deagle and make it reload every time you shoot?

Depresie 03-22-2017 15:31

Re: Single shot deagle
 
Hook the shooting event in post, then just set the user's clip to 0

Airkish 03-22-2017 16:23

Re: Single shot deagle
 
Quote:

Originally Posted by Depresie (Post 2505790)
Hook the shooting event in post, then just set the user's clip to 0

EFFx's code, problem is I shoot infinite times without reloading

PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#include <fakemeta>
#include <fun>

#define PLUGIN                "New Plug-In"
#define VERSION                "1.0"
#define AUTHOR                "author"

#define set_deagle_single_clip(%1)    set_pdata_int(%1, OFFSET_CLIPAMMO, DEAGLE_CLIP, OFFSET_LINUX_WEAPONS)

const CHANCE_REQUIRED =            5
const DEAGLE_CLIP =            1
const OFFSET_CLIPAMMO =            51
const OFFSET_LINUX_WEAPONS =        4
const m_pPlayer =            41
const m_pActiveItem =            373

new bool:g_bIsDeagleRound

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHam(Ham_TakeDamage"player""HamPlayerTakeDamage_Post"0)
    
RegisterHam(Ham_Spawn"player""HamPlayerSpawn_Post"1)
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_deagle""HamDeaglePrimaryAttackPre"0)  

    
register_event("SendAudio""event_CTWin""a""1=0""2=%!MRAD_ctwin")
    
register_event("SendAudio""event_TWin""a""1=0""2=%!MRAD_terwin")
    
register_event("HLTV""event_round_start""a""1=0""2=0")
}

public 
Dgl(id) {
    
g_bIsDeagleRound true

}

public 
event_CTWin()
{
    if(
g_bIsDeagleRound)
    {
        
g_bIsDeagleRound false
        
        client_print
(0print_chat"[Deagle Round]: Counter-Terrorists has won the Deagle round. Finishing the event...")
    }
}

public 
event_TWin()
{
    if(
g_bIsDeagleRound)
    {
        
g_bIsDeagleRound false
        
        client_print
(0print_chat"[Deagle Round]: Terrorists has won the Deagle round. Finishing the event...")
    }
}

public 
HamPlayerTakeDamage_Post(iAttackeriInflictoriVictim)
{
    if(!
g_bIsDeagleRound)
        return 
HAM_IGNORED
    
    
if(!is_user_connected(iAttacker) || !is_user_connected(iVictim))    
        return 
HAM_IGNORED
    
    SetHamParamFloat
(4999.9)
    return 
HAM_IGNORED
}

public 
HamPlayerSpawn_Post(id)
{
    if(
g_bIsDeagleRound)
    {
        if(
is_user_alive(id))
        {
            
cs_set_user_money(id0)
            
            
strip_user_weapons(id)
            
give_item(id"weapon_deagle")
            
cs_set_user_bpammo(idCSW_DEAGLE0)
            
set_deagle_single_clip(get_pdata_cbase(idm_pActiveItem))    
        }
    }
}

public 
HamDeaglePrimaryAttackPre(iWeapon)
{
    new 
id get_pdata_cbase(iWeaponm_pPlayerOFFSET_LINUX_WEAPONS)
    
    if(!
is_user_connected(id))
        return 
HAM_IGNORED
    
    set_deagle_single_clip
(get_pdata_cbase(idm_pActiveItem))
    return 
HAM_IGNORED
}

public 
event_round_start()
{
    if(!
g_bIsDeagleRound)
    {
        if(
IsNecessaryChance(CHANCE_REQUIRED))
        {
            
g_bIsDeagleRound true
            
            client_print
(0print_chat"[Deagle Round]: Deagle round percent (%d%) was hit. Starting the Deagle Round..."CHANCE_REQUIRED)
            
server_cmd("sv_restart 3")
        }
    }
}

IsNecessaryChance(const Chance)
{
    new 
iRandom random_num(0100)
    return (
iRandom Chance) ? true false



Depresie 03-22-2017 16:45

Re: Single shot deagle
 
PHP Code:

RegisterHam(Ham_Weapon_PrimaryAttack"weapon_deagle""HamDeaglePrimaryAttackPre"0

-->>

RegisterHam(Ham_Weapon_PrimaryAttack"weapon_deagle""HamDeaglePrimaryAttackPre"1


Airkish 03-22-2017 17:26

Re: Single shot deagle
 
Quote:

Originally Posted by Depresie (Post 2505818)
PHP Code:

RegisterHam(Ham_Weapon_PrimaryAttack"weapon_deagle""HamDeaglePrimaryAttackPre"0

-->>

RegisterHam(Ham_Weapon_PrimaryAttack"weapon_deagle""HamDeaglePrimaryAttackPre"1


Same. Still can shoot infinite times without reloading

Natsheh 03-24-2017 14:14

Re: Single shot deagle
 
Check out this, this is a sample & not tested...

but the deagle should have in the clip 1, and in the bpammo 1

PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <cstrike>

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHam(Ham_Weapon_Reload"weapon_deagle""fw_deagle_reload_post"1)
}

public 
fw_deagle_reload_post(const wEnt)
{
    if(!
pev_valid(wEnt)) return;
    
    new 
id pev(wEntpev_owner);
    
    if(!
is_user_alive(id)) return;
    
    
cs_set_user_bpammo(idCSW_DEAGLE1);



Or

PHP Code:

public HamDeaglePrimaryAttackPre(iWeapon

    new 
id get_pdata_cbase(iWeaponm_pPlayerOFFSET_LINUX_WEAPONS
     
    if(!
is_user_alive(id)) 
        return 
HAM_IGNORED 
     
    cs_set_user_bpammo
(idCSW_DEAGLE1);
    
    return 
HAM_IGNORED 



Airkish 03-24-2017 14:56

Re: Single shot deagle
 
Quote:

Originally Posted by Natsheh (Post 2506399)
PHP Code:

public HamDeaglePrimaryAttackPre(iWeapon

    new 
id get_pdata_cbase(iWeaponm_pPlayerOFFSET_LINUX_WEAPONS
     
    if(!
is_user_alive(id)) 
        return 
HAM_IGNORED 
     
    cs_set_user_bpammo
(idcs_get_weapon_id(get_pdata_cbase(idm_pActiveItem)), 1);
    
    return 
HAM_IGNORED 



This one is close to what I want. Some fixes needed.

When I shoot it doesn't automaticly reload, I have to switch weapons in order to reload deagle clip.

Natsheh 03-24-2017 16:37

Re: Single shot deagle
 
PHP Code:

public HamDeaglePrimaryAttackPre(iWeapon

    new 
id get_pdata_cbase(iWeaponm_pPlayerOFFSET_LINUX_WEAPONS
     
    if(!
is_user_alive(id)) 
        return 
HAM_IGNORED 
     
    cs_set_user_bpammo
(idCSW_DEAGLE1);
    
    return 
HAM_IGNORED 


how stupid i am...

Airkish 03-24-2017 16:45

Re: Single shot deagle
 
Quote:

Originally Posted by Natsheh (Post 2506468)
PHP Code:

public HamDeaglePrimaryAttackPre(iWeapon

    new 
id get_pdata_cbase(iWeaponm_pPlayerOFFSET_LINUX_WEAPONS
     
    if(!
is_user_alive(id)) 
        return 
HAM_IGNORED 
     
    cs_set_user_bpammo
(idCSW_DEAGLE1);
    
    return 
HAM_IGNORED 


how stupid i am...

Nope, doesn't work

Airkish 03-27-2017 03:42

Re: Single shot deagle
 
Quote:

Originally Posted by Airkish (Post 2506433)
When I shoot it doesn't automaticly reload, I have to switch weapons in order to reload deagle clip.

This left unsolved, need help asap, thanks.


All times are GMT -4. The time now is 19:37.

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