AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   JB Shot4Shot (https://forums.alliedmods.net/showthread.php?t=233824)

Fuck For Fun 01-20-2014 17:08

JB Shot4Shot
 
on my server when i choose Shot4Shot im get Deagle with 7 Bullet.

How can I set to me receives one Bullet and the other 0?
Shot4Shot
Every Shot 1 Bullet


If someone would explain to me, appreciate it very much and will explain where to put it in the Case or stock ..

hornet 01-20-2014 18:31

Re: JB Shot4Shot
 
I'm glad to see your trying to learn.

When you give the player a weapon use cs_set_weapon_ammo() to set the clip ammo back to 1 or 0.
For a shot4shot system, the next step is to block a player's weapon from firing so he can't cheat - using m_flNextPrimaryAttack.
You should then register FM_CmdStart and use the UC Handle to detect a shot, in which you would give the player 1 backpack ammo ( so he will reload ), block his weapon from firing with the above method, and then allow the other player to fire.
When the shot4shot is over, you should unregister FM_CmdStart and allow both players to fire again.

Have a go at that.

Fuck For Fun 01-21-2014 03:06

Re: JB Shot4Shot
 
Wow thanks for the help, the problem is how do I set 1-0, it did not understand
I will try to read again and again


That my case of > EventCurWeapon
PHP Code:

        case LR_S4S_DEAGLE:
        {
            if ( 
get_user_weaponclient ) != CSW_DEAGLE )
            {
                
fm_strip_user_weaponsclient );
                
                
fm_give_itemclient"weapon_deagle" );
                
                
cs_set_user_bpammoclientCSW_DEAGLE9999 );
            }
        } 

That my case of > CmdStartGame
PHP Code:

        // Shot4Shot Duels
        //////////////////
        
case LR_S4S_DEAGLE:
        {
            
fm_give_itemiPrisoner"weapon_deagle" );
            
            
fm_give_itemiGuard"weapon_deagle" );
            
            
cs_set_user_bpammoiPrisonerCSW_DEAGLE9999 );
            
            
cs_set_user_bpammoiGuardCSW_DEAGLE9999 );
        } 


hornet 01-21-2014 06:05

Re: JB Shot4Shot
 
For starters, you really need to use a better method than CurWeapon to restrict the player's weapons, such as stripping them upon game start.

When you give the player a deagle you can do something like this:
Code:
cs_set_weapon_ammo( give_item( iGuard, "weapon_deagle" ), 1 );

And if you wanted to restrict the Guard from shooting ( and allow the Prisoner to shoot first ), you could extend this to:
Code:
const XO_WEAPON         =   4; const m_flNextPrimaryAttack =   46; // new iEnt; cs_set_weapon_ammo( iEnt = give_item( iGuard, "weapon_deagle" ), 1 ); set_pdata_float( iEnt, m_flNextPrimaryAttack, 9999.0, XO_WEAPON );
Also, not sure what's made you want to use FM Utility, but I assure you that it would be more efficient to use the natives from the Fun module. I would only recommend FM Utility for learning purposes.

Fuck For Fun 01-21-2014 12:04

Re: JB Shot4Shot
 
Quote:

Originally Posted by hornet (Post 2088944)
For starters, you really need to use a better method than CurWeapon to restrict the player's weapons, such as stripping them upon game start.

When you give the player a deagle you can do something like this:
Code:
cs_set_weapon_ammo( give_item( iGuard, "weapon_deagle" ), 1 );


And if you wanted to restrict the Guard from shooting ( and allow the Prisoner to shoot first ), you could extend this to:
Code:
const XO_WEAPON             = &n bsp;  4; const m_flNextPrimaryAttack     =    46; // new iEnt; cs_set_weapon_ammo( iEnt = give_item( iGuard, "weapon_deagle" ), 1 ); set_pdata_float( iEnt, m_flNextPrimaryAttack, 9999.0, XO_WEAPON );

Also, not sure what's made you want to use FM Utility, but I assure you that it would be more efficient to use the natives from the Fun module. I would only recommend FM Utility for learning purposes.

i read your Posts and did everything but still dont working
that give 7 bullet to Prisoner and Guard = but 0 ammo


that code just part from my code..for test
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

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

new const XO_WEAPON   =    4;
new const 
m_flNextPrimaryAttack =    46;

new 
iEnt;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Add your code here...
}

......
CmdStartGameiPrisoneriGuardiGame )
{
            
// Shot4Shot Duels
        //////////////////
        
case LR_S4S_DEAGLE:
        {
            
fm_give_itemiPrisoner"weapon_deagle" );
            
            
fm_give_itemiGuard"weapon_deagle" );
            
            
cs_set_weapon_ammoiEnt give_itemiPrisoner"weapon_deagle" ), );
            
            
cs_set_weapon_ammoiEnt give_itemiGuard"weapon_deagle" ), );
            
            
set_pdata_floatiEntm_flNextPrimaryAttack9999.0XO_WEAPON );
        }
    }



Battousai-sama 01-21-2014 23:39

Re: JB Shot4Shot
 
PHP Code:

public WeaponChange(id)
{
    new 
weapon read_data(2);
    if( 
is_user_alive(id) && (iGuard==id || iPrisoner==id) && weapon ){
        new 
clip read_data(3);
        if( 
gLRType == LR_PISTOL && weapon == CSW_DEAGLE ){
            if( 
clip ){
                new 
wpn[32], iWPNidx = -1;
                
get_weaponname(weaponwpn31);
                while( (
iWPNidx fm_find_ent_by_class(iWPNidxwpn)) != ){
                    if( 
pev(iWPNidxpev_owner) == id ){
                        
cs_set_weapon_ammo(iWPNidx1);
                    }
                }
            }
            
cs_set_user_bpammo(idweapon1);
        }if( 
gLRType == LR_PISTOL && weapon != CSW_DEAGLE ){
            new 
wpn[32];
            
get_weaponname(weaponwpn31);
            
engclient_cmd(id"drop"wpn);
            
client_cmd(id"weapon_deagle");
        }
    }


something like that?

add it to the s4s pistol fight part

hornet 01-22-2014 04:32

Re: JB Shot4Shot
 
@FFF remember I said to scrap the FM Utility.

@Battousai-sama there is no point in registering CurWeapon since player's weapons can simply be removed at the start of the game. I see that you also use it to replace the player's bullet, but clip ammo on the hud will not be updated - therefore always show 0, the gun will look as if it has no bullets in it, and there will be no reload sequence. Not to mention that you would register the event to only be called on deagle and when clip ammo is 0 in this case to be efficient.

Battousai-sama 01-22-2014 12:43

Re: JB Shot4Shot
 
Quote:

Originally Posted by hornet (Post 2089370)
@FFF remember I said to scrap the FM Utility.

@Battousai-sama there is no point in registering CurWeapon since player's weapons can simply be removed at the start of the game. I see that you also use it to replace the player's bullet, but clip ammo on the hud will not be updated - therefore always show 0, the gun will look as if it has no bullets in it, and there will be no reload sequence. Not to mention that you would register the event to only be called on deagle and when clip ammo is 0 in this case to be efficient.

actually im using that code it works fine on my end o.o

oh and thats only part of event code took the deagle part only frm it O.o

Fuck For Fun 01-22-2014 13:05

Re: JB Shot4Shot
 
Quote:

Originally Posted by hornet (Post 2089370)
@FFF remember I said to scrap the FM Utility.

@Battousai-sama there is no point in registering CurWeapon since player's weapons can simply be removed at the start of the game. I see that you also use it to replace the player's bullet, but clip ammo on the hud will not be updated - therefore always show 0, the gun will look as if it has no bullets in it, and there will be no reload sequence. Not to mention that you would register the event to only be called on deagle and when clip ammo is 0 in this case to be efficient.

I understand but I try and it fails me ..

hornet 01-22-2014 16:45

Re: JB Shot4Shot
 
Quote:

Originally Posted by Battousai-sama (Post 2089535)
actually im using that code it works fine on my end o.o

oh and thats only part of event code took the deagle part only frm it O.o

Ah yes I missed that you set backpack ammo. But it still doesn't seem reliable. Have you tried holding down fire during reload until your next shot is fired?


All times are GMT -4. The time now is 10:15.

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