AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get user aim angle and change it (htfiwdt??) (https://forums.alliedmods.net/showthread.php?t=54300)

Voi 04-22-2007 08:22

get user aim angle and change it (htfiwdt??)
 
does anyone know how to get players aim angle and then set it with a slight modification ?

so i could change the angle of players aim for recoil things, hand shaking etc.(CS Reality mod :>)

thx

regalis 04-22-2007 08:40

Re: get user aim angle and change it (htfiwdt??)
 
I found that snippet to get the user aiming-angle:
Code:

#include <amxmodx>
 #include <engine>

 new Float:oldAngles[33][3];

 public client_PreThink(id)
 {
    static Float:angles[3];
    entity_get_vector(id,EV_VEC_v_angle,angles);

    if(angles[0] < oldAngles[id][0])
    {
        client_print(id,print_chat,"UP");
    }
    else if(angles[0] > oldAngles[id][0])
    {
        client_print(id,print_chat,"DOWN");
    }

    if(angles[1] < oldAngles[id][1])
    {
        client_print(id,print_chat,"RIGHT");
    }
    else if(angles[1] > oldAngles[id][1])
    {
        client_print(id,print_chat,"LEFT");
    }

    oldAngles[id] = angles;
 }

I think with entity_set_vector()
(http://www.amxmodx.org/doc/source/fu...set_vector.htm)
you can set an angle :)

Hope that helps!?

greetz regalis

Voi 04-22-2007 10:41

Re: get user aim angle and change it (htfiwdt??)
 
1 Attachment(s)
thx, but what i am doing wrong here ?
Code:

public moving(id, mode)
{
    if(mode == 1)
    {
       
    new Float:anglesnew[3], Float:angles[3]
    entity_get_vector(id,EV_VEC_v_angle,angles)   
    anglesnew[0] = angles[0] + random_float(-10.5,10.5)
    anglesnew[1] = angles[1] + random_float(-11.0,11.0)
    anglesnew[2] = angles[2] + random_float(-10.5,10.5)
    entity_set_vector ( id, 0, anglesnew)
   
   
    }
    if(mode == 2)
    {
       
    new Float:anglesnew[3], Float:angles[3]
    entity_get_vector(id,EV_VEC_v_angle,angles)   
    anglesnew[0] = angles[0] + random_float(-20.5,20.5)
    anglesnew[1] = angles[1] + random_float(-21.0,21.0)
    anglesnew[2] = angles[2] + random_float(-20.5,20.5)
    entity_set_vector ( id, 0, anglesnew)
   
   
    }
}

instead changing aim the entity_set_vector is moving player to some location :o pls help

regalis 04-22-2007 11:15

Re: get user aim angle and change it (htfiwdt??)
 
If i'm not wrong i thing you are changing one angle that shouldn't be changed...
Code:

      if(mode == 1)
    {
       
    new Float:anglesnew[3], Float:angles[3]
    entity_get_vector(id,EV_VEC_v_angle,angles)   
    anglesnew[0] = angles[0] + random_float(-10.5,10.5)
    anglesnew[1] = angles[1] + random_float(-11.0,11.0)
    //anglesnew[2] = angles[2] + random_float(-10.5,10.5)
    entity_set_vector ( id, 0, anglesnew)
   
   
    }
    if(mode == 2)
    {
       
    new Float:anglesnew[3], Float:angles[3]
    entity_get_vector(id,EV_VEC_v_angle,angles)   
    anglesnew[0] = angles[0] + random_float(-20.5,20.5)
    anglesnew[1] = angles[1] + random_float(-21.0,21.0)
    //anglesnew[2] = angles[2] + random_float(-20.5,20.5)
    entity_set_vector ( id, 0, anglesnew)
   
   
    }

I have no experience with that stuff but please try that :)

greetz regalis

Voi 04-22-2007 11:34

Re: get user aim angle and change it (htfiwdt??)
 
nope, its almost the same thing

Nican 04-22-2007 11:38

Re: get user aim angle and change it (htfiwdt??)
 
You did not specify what vector to change:
Vector 0 is EV_VEC_origin, so i think you are trowing the player of the map

change:
entity_set_vector ( id, 0, anglesnew)
to:
entity_set_vector ( id, EV_VEC_v_angle, anglesnew)

For list of all vectors and others:
http://www.amxmodx.org/funcwiki.php?go=module&id=3


and, you can use instead of:
anglesnew[0] = angles[0] + random_float(-20.5,20.5)
anglesnew[1] = angles[1] + random_float(-21.0,21.0)
anglesnew[2] = angles[2] + random_float(-20.5,20.5)
to:
angles[0] += random_float(-20.5,20.5)
angles[1] += random_float(-21.0,21.0)
angles[2] += random_float(-20.5,20.5)
entity_set_vector ( id, EV_VEC_v_angle, angles)

Voi 04-22-2007 11:53

Re: get user aim angle and change it (htfiwdt??)
 
thx! im trying it!

edit:
doesnt work:
Code:

public moving(id, mode)
{
    new Float:angles[3]
    entity_get_vector(id,EV_VEC_v_angle,angles)
    if(mode == 1)
    {
    angles[0] += random_float(-20.5,20.5)
    angles[1] += random_float(-21.0,21.0)
    angles[2] += random_float(-20.5,20.5)
    entity_set_vector ( id, EV_VEC_v_angle, angles)
    }
    if(mode == 2)
    {
       
    angles[0] += random_float(-20.5,20.5)
    angles[1] += random_float(-21.0,21.0)
    angles[2] += random_float(-20.5,20.5)
    entity_set_vector ( id, EV_VEC_v_angle, angles)   
 
  }
}

but i have read somewhere that if i want to change aim vector i must set pev_fixaim 1 or something

Nican 04-22-2007 12:03

Re: get user aim angle and change it (htfiwdt??)
 
Hmm... hold on, let me try


EDIT:
Ok this works:
PHP Code:

public testtt(id){
    
    if (!(
get_user_flags(id)&ADMIN_MAP))
        return 
PLUGIN_HANDLED
    
    
new Float:angles[3]
    
entity_get_vector(id,EV_VEC_v_angle,angles)

    
angles[0] += random_float(-20.5,20.5)
    
angles[1] += random_float(-21.0,21.0)  

    
entity_set_vector idEV_VEC_v_angleangles)  
    
entity_set_int(id,EV_INT_fixangle,1)
    return 
PLUGIN_HANDLED


And it is true, the third value of angle is alweys 0..

Voi 04-22-2007 12:34

Re: get user aim angle and change it (htfiwdt??)
 
2 Attachment(s)
now it works but not exacly how it ment to be

try voi_sniperrealism2.sma
it should work similiar to voi_sniperrealism.sma

Nican 04-22-2007 12:59

Re: get user aim angle and change it (htfiwdt??)
 
hmm... I see what you want

You want a plugin that set's player view up and down while he walks

-I do not think you need to use ScrShake, it is just too much
-The correct would the player view go up and down, but you are just setting random numbers, I would say to do something to the player's view go up and a little to one side one time, and down and a little to the other side
-You are executing moving(id, mode) two times in check_movement(playerid[]), and one time even if the player is not moving

-I never sow someone use this:
PHP Code:

switch ( is_user_bot id ) )
       {
             case 
1:
             return 
PLUGIN_CONTINUE
       


I think the correct is:
PHP Code:

if(is_user_bot(id))
       return 
PLUGIN_CONTINUE 



All times are GMT -4. The time now is 06:46.

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