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

Solved Single shot deagle


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 03-22-2017 , 13:47   Single shot deagle
Reply With Quote #1

Need help with deagle ammo.

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

Last edited by Airkish; 03-27-2017 at 09:42.
Airkish is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 03-22-2017 , 15:31   Re: Single shot deagle
Reply With Quote #2

Hook the shooting event in post, then just set the user's clip to 0
__________________

Last edited by Depresie; 03-22-2017 at 15:31.
Depresie is offline
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 03-22-2017 , 16:23   Re: Single shot deagle
Reply With Quote #3

Quote:
Originally Posted by Depresie View Post
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

__________________
Airkish is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 03-22-2017 , 16:45   Re: Single shot deagle
Reply With Quote #4

PHP Code:
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_deagle""HamDeaglePrimaryAttackPre"0

-->>

RegisterHam(Ham_Weapon_PrimaryAttack"weapon_deagle""HamDeaglePrimaryAttackPre"1
__________________
Depresie is offline
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 03-22-2017 , 17:26   Re: Single shot deagle
Reply With Quote #5

Quote:
Originally Posted by Depresie View Post
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
__________________
Airkish is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-24-2017 , 14:14   Re: Single shot deagle
Reply With Quote #6

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 

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 03-24-2017 at 16:37.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 03-24-2017 , 14:56   Re: Single shot deagle
Reply With Quote #7

Quote:
Originally Posted by Natsheh View Post
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.
__________________

Last edited by Airkish; 03-24-2017 at 15:37.
Airkish is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-24-2017 , 16:37   Re: Single shot deagle
Reply With Quote #8

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...
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 03-24-2017 , 16:45   Re: Single shot deagle
Reply With Quote #9

Quote:
Originally Posted by Natsheh View Post
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
__________________

Last edited by Airkish; 03-24-2017 at 16:45.
Airkish is offline
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 03-27-2017 , 03:42   Re: Single shot deagle
Reply With Quote #10

Quote:
Originally Posted by Airkish View Post
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.
__________________
Airkish 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 04:37.


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