Raised This Month: $32 Target: $400
 8% 

[ H3LP ] Player limit angles


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DarthMan
Veteran Member
Join Date: Aug 2011
Old 01-01-2019 , 13:05   [ H3LP ] Player limit angles
Reply With Quote #1

Hello. Does anybody knows how to limit player angle movement?
What I'm trying to achieve is a movement similar to a 2D game, so that the player can only move in 0, 90, 0 or 0, 270, 0 angles. So if I press a, the yaw angle will be 90, if I press d it must be 270. So kinda like an enforcement of 90 and 270, while the pitch and roll angles will always have to be 0. Even pressing W or S must retain these angles. Any ideas? Thanks !
DarthMan is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 01-01-2019 , 15:43   Re: [ H3LP ] Player limit angles
Reply With Quote #2

On every player's think/frame force him your angles.
__________________
My English is A0
E1_531G is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 01-01-2019 , 15:45   Re: [ H3LP ] Player limit angles
Reply With Quote #3

Quote:
Originally Posted by E1_531G View Post
On every player's think/frame force him your angles.
This won't work fine, if I set yaw angle to 90, the player will move to the right and not to the left when pressing a.

Last edited by DarthMan; 01-01-2019 at 15:46.
DarthMan is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 01-01-2019 , 15:48   Re: [ H3LP ] Player limit angles
Reply With Quote #4

This means you need the opposite angle's value (270 or -90).
Also, do you change angle or view angle?
__________________
My English is A0
E1_531G is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 01-01-2019 , 15:51   Re: [ H3LP ] Player limit angles
Reply With Quote #5

Quote:
Originally Posted by E1_531G View Post
This means you need the opposite angle's value (270 or -90).
Also, do you change angle or view angle?
I just changed pev_angle.
DarthMan is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 01-01-2019 , 15:55   Re: [ H3LP ] Player limit angles
Reply With Quote #6

Quote:
Originally Posted by E1_531G View Post
This means you need the opposite angle's value (270 or -90).
Also, do you change angle or view angle?
Well, what I want is, when pressing W, the player will aim to the left. When pressing D, to the right. No ideas? -90 will make him aim to the left.
DarthMan is offline
Xalus
Veteran Member
Join Date: Dec 2009
Location: Belgium
Old 01-01-2019 , 16:42   Re: [ H3LP ] Player limit angles
Reply With Quote #7

This is the way I used in my 'Tron'-mod,
not sure there is a better way but it worked.

(Maybe pev_fixangle is needed, if you want to force it)

PHP Code:
new Float:g_client_angle[33][3]

public 
client_spawn(client)
{
  
pev(clientpev_v_angleg_client_angle[client])
  
g_client_angle[client][1] = 90.0
}

public 
client_PreThink(client)
{
    if(
is_user_alive(client))
    {
        static 
client_buttonclient_oldbutton
        client_button 
pev(clientpev_button)
        
client_oldbutton pev(clientpev_client_oldbuttons)

        if(
client_button IN_MOVERIGHT
          
&& ~client_oldbutton IN_MOVERIGHT)
        {
            
g_client_angle[client][1] -= 90.0
        
}
        else if(
client_button IN_MOVELEFT
          
&& ~client_oldbutton IN_MOVELEFT)
        {
            
g_client_angle[client][1] += 90.0
        
}
        
set_pev(clientpev_anglesFloat:g_client_angle[client])
        
set_pev(clientpev_v_angleFloat:g_client_angle[client])
  }

__________________
Retired.

Last edited by Xalus; 01-01-2019 at 16:44.
Xalus is offline
raizo11
BANNED
Join Date: Dec 2013
Location: https://t.me/pump_upp
Old 01-01-2019 , 17:07   Re: [ H3LP ] Player limit angles
Reply With Quote #8

for exp:

Code:
#include <amxmodx>
#include <engine>

new Float:fVelocity[3];

public client_PreThink(id)
{
    new buttons = get_user_button(id)

    if (buttons & IN_MOVELEFT)
        move_left(id)

    if (buttons & IN_MOVERIGHT)
        move_right(id)
}

public move_left(id) 
{
    if (is_user_alive(id))
    {
        fVelocity[0] = 230.0;
        fVelocity[1] = 0.0;
        fVelocity[2] = 0.0;

        entity_set_vector(id,EV_VEC_velocity, fVelocity)
        set_Angle(id, Float:{0.0, 0.0, 0.0})
    } 
}

public move_right(id) 
{
    if (is_user_alive(id))
    {
        fVelocity[0] = -230.0;
        fVelocity[1] = 0.0;
        fVelocity[2] = 0.0;

        entity_set_vector(id,EV_VEC_velocity, fVelocity)
        set_Angle(id, Float:{0.0, 180.0, 0.0})
    } 
}

stock set_Angle( index , Float:fAngle[ 3 ])
{
    entity_set_vector( index , EV_VEC_angles , fAngle ); 
    entity_set_int( index , EV_INT_fixangle , 1 );
}

Last edited by raizo11; 01-01-2019 at 19:17.
raizo11 is offline
Send a message via ICQ to raizo11 Send a message via AIM to raizo11 Send a message via MSN to raizo11 Send a message via Yahoo to raizo11 Send a message via Skype™ to raizo11
DarthMan
Veteran Member
Join Date: Aug 2011
Old 01-01-2019 , 18:38   Re: [ H3LP ] Player limit angles
Reply With Quote #9

Quote:
Originally Posted by raizo11 View Post
for exp:

Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>

new Float:fVelocity[3];

public plugin_init() 
{
    register_forward(FM_PlayerPreThink,"FW_MOVEMENT")
}

public FW_MOVEMENT(id)
{
    if (pev(id,pev_button) & IN_MOVELEFT)
            move_left(id)

    if (pev(id,pev_button) & IN_MOVERIGHT)
            move_right(id)
}

public move_left(id) 
{
    if (is_user_alive(id))
    {
        fVelocity[0] = 230.0;
        fVelocity[1] = 0.0;
        fVelocity[2] = 0.0;

        set_pev( id, pev_velocity, fVelocity )
        set_Angle(id, Float:{0.0, 0.0, 0.0})
    } 
}

public move_right(id) 
{
    if (is_user_alive(id))
    {
        fVelocity[0] = -230.0;
        fVelocity[1] = 0.0;
        fVelocity[2] = 0.0;

        set_pev( id, pev_velocity, fVelocity )
        set_Angle(id, Float:{0.0, 180.0, 0.0})
    } 
}

stock set_Angle( index , Float:fAngle[ 3 ])
{
    entity_set_vector( index , EV_VEC_angles , fAngle ); 
    entity_set_int( index , EV_INT_fixangle , 1 );
}
Yes, but on TFC, for example, velocity is different according to the class. And on CS it's according to the holding weapon. So 230 is not a good value in this case.
Also, engine is not needed here since you're using FakeMeta, better use either engine or fakemeta.

EDIT: Maybe doing fVelocity[0] = -fVelocity[0]; will do the trick by using pev(id, pev_velocity, fVelocity) then applying the new velocity.
Will test tomorrow.

Last edited by DarthMan; 01-01-2019 at 18:48.
DarthMan is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-02-2019 , 04:08   Re: [ H3LP ] Player limit angles
Reply With Quote #10

Quote:
Also, engine is not needed here since you're using FakeMeta, better use either engine or fakemeta.
no no no no no no NO
__________________
HamletEagle is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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