AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Do spray from any weapon (CS) (https://forums.alliedmods.net/showthread.php?t=232269)

Phant 12-28-2013 06:55

Do spray from any weapon (CS)
 
Hello.
I want to do spray from any weapon.

If weapon == automatic (AK47, AWP, etc.), then I can do:
PHP Code:

client_cmd(id"+attack"

And player shot out all magazine (do spray). It's okay.

But, how I can do same for Pistols? How I can make player shot very fast as far as it possible from Pistol?

Bos93 12-28-2013 07:00

Re: Do spray from any weapon (CS)
 
client_cmd(id, "+attack") -> ExecuteHam( Ham_Weapon_PrimaryAttack , pEntity );

https://forums.alliedmods.net/showthread.php?t=138972

ConnorMcLeod 12-28-2013 07:05

Re: Do spray from any weapon (CS)
 
PHP Code:

#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >

#pragma semicolon 1

#define PLUGIN "Automatic Usp"
#define VERSION "0.0.1"

#define cm(%0)    ( sizeof(%0) - 1 )

const XO_CBASEPLAYERWEAPON 4;
const 
m_iShotFired 64;

public 
plugin_init()
{
    
register_pluginPLUGINVERSION"ConnorMcLeod" );

    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_usp""OnCUSP_PrimaryAttack_P"true);
}

public 
OnCUSP_PrimaryAttack_PiUSP )
{
    
set_pdata_int(iUSPm_iShotFired0XO_CBASEPLAYERWEAPON);



Phant 12-28-2013 07:08

Re: Do spray from any weapon (CS)
 
Thanks. And now I need to hook moment, when player can shot from current weapon.
For execute this command (Ham_Weapon_PrimaryAttack) in this moment.

UPD:
Oh, ConnorMcLeod, thanks you. I will test it.

ConnorMcLeod 12-28-2013 07:13

Re: Do spray from any weapon (CS)
 
You can use arkshine's plugin that is handling all pistols, but take care he forgot to set the correct linux offset difference.

Phant 12-28-2013 07:55

Re: Do spray from any weapon (CS)
 
Quote:

Originally Posted by ConnorMcLeod (Post 2077430)
You can use arkshine's plugin that is handling all pistols, but take care he forgot to set the correct linux offset difference.

I just register all pistols on this function. Work perfect.

Another question:
In function "OnCUSP_PrimaryAttack_P" can I check ammo (in magazine) of current weapon?
I want check If ammo == 0, then I send "-attack", for reloading, and after reloading, send +attack for continue spraying (new magazine).
Or better do it in CurWeapon?

ConnorMcLeod 12-28-2013 09:19

Re: Do spray from any weapon (CS)
 
I don't know, try it.
Also, client_cmd is usually a poor way for that kind of stuff, would be better to force IN_ATTACK button in CmdStart , or in PostThink.

Phant 12-28-2013 09:30

Re: Do spray from any weapon (CS)
 
Quote:

Originally Posted by ConnorMcLeod (Post 2077482)
I don't know, try it.
Also, client_cmd is usually a poor way for that kind of stuff, would be better to force IN_ATTACK button in CmdStart , or in PostThink.

The problem is that I don't know how to get ammo number in this function.
I think need to use get_pdata_int() or something like that, but question in offsets...

UPD, DONE:
PHP Code:

    new amm get_pdata_int(iPISTOL51);    
    if(
amm == 10)
    {
        
set_pdata_int(iPISTOL5120);
    } 


ConnorMcLeod 12-28-2013 15:13

Re: Do spray from any weapon (CS)
 
Example.

PHP Code:

public OnCUSP_PrimaryAttack_PiUSP 
{
    if( 
cs_get_weapon_ammo(iUSP) > )
    {
        
set_pdata_int(iUSPm_iShotFired0XO_CBASEPLAYERWEAPON); 
    }


If you use fakemeta and pdatas, don't forget to add the correct linux offset difference.


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

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