AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Thunder lenght (https://forums.alliedmods.net/showthread.php?t=294979)

EFFx 03-12-2017 15:17

Thunder lenght
 
I'm trying to create a thunder between attacker and his enemy. Thats the code i'm using:

PHP Code:


new const gBeamSprite[] = "sprites/lgtning.spr"
new gBoltSprite 

PHP Code:

public plugin_precache()
{
    
gBoltSprite precache_model(gBeamSprite)


PHP Code:

new iTargetiBody
get_user_aiming
(idiTargetiBody170)

if(
pev_valid(iTarget))
{
    new 
iOrigin[3], iTargetOrigin[3]
    
get_user_origin(idiOrigin0)
    
get_user_origin(iTargetiTargetOrigin0)

    
CreateThunder(iOriginiTargetOrigin)


PHP Code:

CreateThunder(iStart[3], iEnd[3])
{
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
    
write_byte(TE_BEAMPOINTS)
    
write_coord(iStart[0]) 
    
write_coord(iStart[1])
    
write_coord(iStart[2])
    
write_coord(iEnd[0]) 
    
write_coord(iEnd[1]) 
    
write_coord(iEnd[2]) 
    
write_short(gBoltSprite
    
write_byte(1)
    
write_byte(1)
    
write_byte(4)
    
write_byte(30)
    
write_byte(30)
    
write_byte(120
    
write_byte(40)
    
write_byte(255)
    
write_byte(255)
    
write_byte(25)
    
message_end()


The problem is: When I miss the shot the thunder doesn't appear, cause the pev_valid. I want to know if is possible to show the thunder even if I miss with X lenght.

klippy 03-12-2017 15:22

Re: Thunder lenght
 
Quote:

I'm trying to create a thunder between attacker and the victim.
What exactly are "attacker" and "target" here? It looks like you are polling to see if a player is aiming at an entity. Please elaborate more on what you are trying to achieve.

EFFx 03-12-2017 15:24

Re: Thunder lenght
 
If he's aiming at an enemy, not an entity. Read all the post, I've explained more.

klippy 03-12-2017 15:33

Re: Thunder lenght
 
Then you better do a trace line instead get_user_aiming.

EFFx 03-12-2017 15:35

Re: Thunder lenght
 
I'm using knife for show that thunder, so it cannot be possible I guess.

klippy 03-12-2017 15:43

Re: Thunder lenght
 
What? Just post your whole code, I can't figure out when you actually want it to appear.

EFFx 03-12-2017 15:52

Re: Thunder lenght
 
PHP Code:

register_forward(FM_CmdStart"forward_FM_CmdStart"

PHP Code:

public forward_FM_CmdStart(iduc_handleseed)
{
    if(
get_user_weapon(id) & CSW_KNIFE)
    {
        new 
iButtons get_uc(uc_handleUC_Buttons)
        new 
iOldButtons pev(idpev_oldbuttons)
    
        if(
iButtons IN_ATTACK && !(iOldButtons IN_ATTACK))
        {
            new 
iTargetiBody
            get_user_aiming
(idiTargetiBody170)
            
            new 
iOrigin[3]
            
get_user_origin(idiOrigin0)
            
            if(
pev_valid(iTarget))
            {    
                new 
iTargetOrigin[3]
                
get_user_origin(iTargetiTargetOrigin0)
                
                
CreateThunder(iOriginiTargetOrigin)
            }    
            else
            {
                
// Thats what I was trying, but doesn't worked
                
new iEntOrigin[3]
                
get_tr2(iTargetTR_vecEndPosiEntOrigin)
                
                
CreateThunder(iOriginiEntOrigin)
            }
            
iButtons &= ~IN_ATTACK
            set_uc
(uc_handleUC_ButtonsiButtons)
        }
    }



abdobiskra 03-12-2017 15:55

Re: Thunder lenght
 
myb as a simple u can do it like this ?

PHP Code:

        new origin[3], position[3];
    
get_user_origin(id,origin3)
    
get_user_origin(id,position0)
    
    if(
get_distance(originposition) < 60)
    { 


EFFx 03-12-2017 16:04

Re: Thunder lenght
 
I want not a X distance for show the thunder, if I hit the shot, will show it between me and my enemy. If I miss, it show a small thunder.


All times are GMT -4. The time now is 17:48.

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