AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [HELP] pev_angles Problem (https://forums.alliedmods.net/showthread.php?t=317491)

hellmonja 07-16-2019 13:50

[HELP] pev_angles Problem
 
I wanted to make a dizzy plugin. So I'm spinning the players view using pev_angles. The problem is the Y axis (players view up or down) keeps resetting to 0 and I don't know why. I'm storing all current pev_angle information in g_dizzyangle[user][0] and only editing g_dizzyangle[user][2] to spin the view. Still the Y axis keeps resetting itself. I want the player to still be able to look up or down while his world is spinning...

PHP Code:

public Dizzy(user)
{
    if(!
g_is_dizzy[user])
    {
        
g_is_dizzy[user] = true;
        
EnableHamForward(HandleDizzyPreThink[user]);
    }
    else
    {
        
g_is_dizzy[user] = false;
        
DisableHamForward(HandleDizzyPreThink[user]);
    }
}

public 
Ham_Dizzy_PreThink(user)
{
    new 
Float:g_old_angle[3];
    new 
Float:g_old_vangle[3], Float:g_vangle[3];

    
pev(userpev_anglesg_old_angle);
    
    
g_dizzyangle[user][0] = g_old_angle[0];
    
g_dizzyangle[user][1] = g_old_angle[1];

    if(
g_is_dizzy[user])
    {
        
g_dizzyangle[user][2] += 2.0;
        
set_pev(userpev_anglesg_dizzyangle[user]);
        
set_pev(userpev_fixangle1);
    }
    else
        
DisableHamForward(HandleDizzyPreThink[user]);

    return 
HAM_HANDLED



CrazY. 07-16-2019 13:59

Re: [HELP] pev_angles Problem
 
pev_angle it's model angle, pev_v_angle it's the view angle, that being said, rotate the pev_v_angle instead.

hellmonja 07-16-2019 15:06

Re: [HELP] pev_angles Problem
 
Quote:

Originally Posted by CrazY. (Post 2659350)
pev_angle it's model angle, pev_v_angle it's the view angle, that being said, rotate the pev_v_angle instead.

I'm sorry but it doesn't seem to work. It still resets the view (for example I'm looking up and when I turn it on it instantly makes me look straight forward) plus the effect is not there unlike when using pev_angle. I've already disabled all other plugins and only had that one running...

PHP Code:

public Ham_Dizzy_PreThink(user)
{
    new 
Float:old_angle[3];
    
    
pev(userpev_v_angleold_angle);
    
    
g_dizzyangle[user][0] = old_angle[0];
    
g_dizzyangle[user][1] = old_angle[1];

    if(
g_is_dizzy[user])
    {
        
g_dizzyangle[user][2] += 2.0;
        
set_pev(userpev_v_angleg_dizzyangle[user]);
        
set_pev(userpev_fixangle1);
    }
    else
        
DisableHamForward(HandleDizzyPreThink[user]);

    return 
HAM_HANDLED



edon1337 07-16-2019 15:21

Re: [HELP] pev_angles Problem
 
Try removing pev_fixangle from the code.

<VeCo> 07-16-2019 15:24

Re: [HELP] pev_angles Problem
 
alter punchangle instead, view angles are reset by the game

hellmonja 07-17-2019 02:54

Re: [HELP] pev_angles Problem
 
I got it! In order to make your Y axis angle (up and down view) stay the same you have to multiply it by -3. I'll explain it in detail in case someone needs this as well.

So basically your angle for pev_angles has 3 parts: Angle [0] makes you look up or down. Angle [1] left to right. And angle [2], well let's say you spin in this angle and it'll like you're doing cartwheels.

I experimented and made two commands: Check_Angle and Set_Angle, which are both self explanatory. But when I check angle[0] and it returns, let's say 7.0; when I then set angle[0] to 7.0 it gives me a different angle. So I set the angle to -90.0 and when I checked it it was 30.0. Here's the code I used.
PHP Code:

public plugin_init()
{
    
register_plugin("Dizzy Test""alpha""hellmonja");
    
    
register_clcmd("check_angle""Check_Angle");
    
register_clcmd("set_angle""Set_Angle");
}

public 
Check_Angle(user)
{
    new 
Float:old_angle[3];
        
pev(userpev_anglesold_angle);
//    pev(user, pev_v_angle, old_angle);
    
    
client_print(userprint_chat"0:%f | 1:%f | 2:%f"old_angle[0], old_angle[1], old_angle[2]);
    
    return 
PLUGIN_HANDLED
}

public 
Set_Angle(user)
{
    new 
y_angle[32];
    
read_argv1y_anglesizeof y_angle );
    
    new 
Float:old_angle[3], Float:new_angle[3];
        
pev(userpev_anglesold_angle);
//    pev(user, pev_v_angle, old_angle);
    
    
new_angle[0] = str_to_float(y_angle);
    
new_angle[1] = old_angle[1];
    
new_angle[2] = old_angle[2];

    
set_pev(userpev_anglesnew_angle);
//    set_pev(user, pev_v_angle, new_angle);
    
set_pev(userpev_fixangle1);
    
    return 
PLUGIN_HANDLED


Like I said, if you want to get angle[0] of pev_angles and want to set to view back to that angle you have to multiply it by -3 when you set pev_angles again.

Thanks to everyone who replied. Knowing people are ready support you in this site is much appreciated...

Natsheh 07-17-2019 03:42

Re: [HELP] pev_angles Problem
 
Quote:

Originally Posted by <VeCo> (Post 2659362)
alter punchangle instead, view angles are reset by the game

That's incorrect.

Also the difference between the pev_v_angle and pev_angles is the origin position for View angel it's the player pos and for angles its the model origin.

So I do suggest just to apply a random left and right velocity with changing in punchangles slightly.


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

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