AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   2 questions (https://forums.alliedmods.net/showthread.php?t=241509)

daniel46 06-04-2014 15:08

2 questions
 
i have a spray high code but some times it will just show 000000000000

Code:

public EventSpray ( ) 

        new iPlayer = read_data( 2 );
        if( !SprayContest || AlreadySprayed[ iPlayer ] )
        {
                return;
        }
        new iOrigin[ 3 ]; 
        iOrigin[ 0 ] = read_data( 3 ); 
        iOrigin[ 1 ] = read_data( 4 ); 
        iOrigin[ 2 ] = read_data( 5 ); 
       
        new Float:vecOrigin[ 3 ]; 
        IVecFVec( iOrigin, vecOrigin ); 
       
        new Float:vecDirection[ 3 ]; 
        velocity_by_aim( iPlayer, 5, vecDirection ); 
       
        new Float:vecStop[ 3 ]; 
        xs_vec_add( vecOrigin, vecDirection, vecStop ); 
       
        xs_vec_mul_scalar( vecDirection, -1.0, vecDirection ); 
       
        new Float:vecStart[ 3 ]; 
        xs_vec_add( vecOrigin, vecDirection, vecStart ); 
       
        engfunc( EngFunc_TraceLine, vecStart, vecStop, IGNORE_MONSTERS, -1, 0 ); 
       
        get_tr2( 0, TR_vecPlaneNormal, vecDirection ); 
       
        vecDirection[ 2 ] = 0.0; 
       
        xs_vec_normalize( vecDirection, vecDirection ); 
       
        xs_vec_mul_scalar( vecDirection, 5.0, vecDirection ); 
       
        xs_vec_add( vecOrigin, vecDirection, vecStart ); 
       
        xs_vec_copy( vecStart, vecStop ); 
        vecStop[ 2 ] -= 9999.0; 
       
        engfunc( EngFunc_TraceLine, vecStart, vecStop, IGNORE_MONSTERS, -1, 0 ); 
       
        get_tr2( 0, TR_vecEndPos, vecStop ); 
       
        new Float:FinalMeters;
       
        FinalMeters = (vecStart[ 2 ] - vecStop[ 2 ]) * 0.0254;
       
        SprayContestMeters[ iPlayer] = FinalMeters;
       
        AlreadySprayed[ iPlayer ] = true;
       
        ColorChat( 0 , "^3%s ^1Sprayed ^4%f ^1Meters from the ground" , UserName( iPlayer ) , FinalMeters )
}

and also how can i check if player using any button and if he is what button

Fuck For Fun 06-04-2014 16:48

Re: 2 questions
 
I do not know if that's what you wanted, but see if works and add what you want.

PHP Code:

public EventSpray()
{    
    new 
iOrigin];
    
iOrigin] = read_data);
    
iOrigin] = read_data);
    
iOrigin] = read_data);
        
    new 
Float:fSprayOrigin];
    
IVecFVeciOriginfSprayOrigin );
    
    new 
client read_data);
    
    new 
Float:fPlayerOrigin];
    
get_user_originclientiOrigin);
    
IVecFVeciOriginfPlayerOrigin );
        
    new 
Float:fDirection];
    
xs_vec_subfSprayOriginfPlayerOriginfDirection );
    
xs_vec_mul_scalarfDirection10.0 vector_lengthfDirection ), fDirection );

    new 
Float:fStop];
    
xs_vec_addfSprayOriginfDirectionfStop );
    
xs_vec_mul_scalarfDirection, -1.0fDirection );
    
    new 
Float:fStart];
    
xs_vec_addfSprayOriginfDirectionfStart );
    
engfuncEngFunc_TraceLinefStartfStopIGNORE_MONSTERS, -1);
    
get_tr20TR_vecPlaneNormalfDirection );
    
fDirection] = 0.0;
    
    
xs_vec_mul_scalarfDirection5.0 vector_lengthfDirection ), fDirection );
    
xs_vec_addfSprayOriginfDirectionfStart );
    
xs_vec_copyfStartfStop );
    
fStop] -= 9999.0;
    
    
engfuncEngFunc_TraceLinefStartfStopIGNORE_MONSTERS, -1)
    
get_tr20TR_vecEndPosfStop )

    new 
Float:fSprayDistance fStart] - fStop];
    
    
ColorChat0RED"^3%s ^1Sprayed ^x04 %.3f ^1Meters from the ground."UserNameiPlayer ), fSprayDistance );
    
    return 
PLUGIN_CONTINUE;



fysiks 06-04-2014 16:59

Re: 2 questions
 
It is not possible to determine which keyboard button a player is pressing. You can only know the commands sent to the server.

Also, the forum rule require that your topic title be descriptive. Please update your title to describe your question or issue. If you fail to do so, you risk your threads being trashed.

Also, only one topic per thread.

daniel46 06-04-2014 17:02

Re: 2 questions
 
sorry i ment all the IN_ how can i check what button of does he is pressing

fysiks 06-04-2014 17:05

Re: 2 questions
 
Search for get_user_button().

Also:

Quote:

Originally Posted by fysiks (Post 2146897)
Also, the forum rule require that your topic title be descriptive. Please update your title to describe your question or issue. If you fail to do so, you risk your threads being trashed.

Also, only one topic per thread.


daniel46 06-04-2014 17:12

Re: 2 questions
 
so can i do like this?

static Button;
Button = fm_get_user_button( client );

and then

if( Button != IN_MOVE )

cause i know you can do like this

if( Button & IN_MOVE )

for if yes but i want if no

Flick3rR 06-04-2014 17:18

Re: 2 questions
 
PHP Code:

if(!(Button IN_MOVE)) 

or
PHP Code:

if(PressedButton &= ~IN_MOVE

Idk if the syntax of the second way should be like this, probably some sign is wrong, but I think that's it.

daniel46 06-04-2014 17:19

Re: 2 questions
 
what i want if negative like you do normaly !=

fysiks 06-04-2014 17:20

Re: 2 questions
 
I told you to search. All the information you need is available. Write your code based on the information you found. Test it. If you can't get it to work, start a new thread with an appropriate topic title with the full code that you were testing.

This is also the last warning before I lock this thread for fixing your topic title:

Quote:

Originally Posted by fysiks (Post 2146897)
Also, the forum rules require that your topic title be descriptive. Please update your title to describe your question or issue. If you fail to do so, you risk your threads being trashed.


daniel46 06-04-2014 17:26

Re: 2 questions
 
ok you can lock it if you say evrything is in there


All times are GMT -4. The time now is 09:43.

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