Raised This Month: $12 Target: $400
 3% 

Preventing a player from moving in a certain direction


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
rexcision
SourceMod Donor
Join Date: Dec 2015
Location: Canada
Old 08-06-2016 , 09:52   Preventing a player from moving in a certain direction
Reply With Quote #1

I'm trying to make it so that when a player tries to do +left for example by using their A key, nothing happens. Is this the right way to go about it? Also I'm not sure what to put in to stop the player from moving left.

PHP Code:
public Action OnPlayerRunCmd(int clientint &buttons)
{
     if (
buttons && IN_MOVELEFT)
     {
          
//Some command to disable the move left bind
     
}

__________________
rexcision is offline
Michael Shoe Maker
Senior Member
Join Date: Apr 2016
Old 08-06-2016 , 10:14   Re: Preventing a player from moving in a certain direction
Reply With Quote #2

Not sure, you could try:
PHP Code:
buttons &= ~IN_MOVELEFT 
Or:

PHP Code:
vel view_as<float>({0.00.00.0}) 

Last edited by Michael Shoe Maker; 08-06-2016 at 10:17.
Michael Shoe Maker is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 08-06-2016 , 16:46   Re: Preventing a player from moving in a certain direction
Reply With Quote #3

+left is IN_LEFT
+right is IN_RIGHT

You could check for if(buttons & IN_LEFT), apply vel[1] = 0.0 and return Plugin_Changed.

What you're looking for, is IN_MOVELEFT (bind a defaults to +moveleft).
This is not the most accurate check, and you should be checking for if(vel[1] < 0.0) instead.
__________________
retired

Last edited by shavit; 08-06-2016 at 16:47.
shavit is offline
rexcision
SourceMod Donor
Join Date: Dec 2015
Location: Canada
Old 08-06-2016 , 17:11   Re: Preventing a player from moving in a certain direction
Reply With Quote #4

Quote:
Originally Posted by shavit View Post
+left is IN_LEFT
+right is IN_RIGHT

You could check for if(buttons & IN_LEFT), apply vel[1] = 0.0 and return Plugin_Changed.

What you're looking for, is IN_MOVELEFT (bind a defaults to +moveleft).
This is not the most accurate check, and you should be checking for if(vel[1] < 0.0) instead.
Okay i will try this out, thanks!
__________________
rexcision 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 11:07.


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