Raised This Month: $ Target: $400
 0% 

Question about noclip


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
point.blank
Member
Join Date: Oct 2007
Old 07-20-2008 , 21:38   Question about noclip
Reply With Quote #1

Is it possible to have noclip and NOT be able to go through walls, to simulate something similar to flying?
__________________
point.blank is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-20-2008 , 21:45   Re: Question about noclip
Reply With Quote #2

This is just a code snippet, not a working plugin.
You should add checks to see if player is able to use this and other stuff.
This is very generic and not advanced.
It only goes the direction the player is aiming, instead of following the player's keys.
I could probably find out how to match the keys, but I decided to be lazy until you asked for it

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

public plugin_init()
{
    
register_forward(FM_PlayerPreThink"FwdPlayerPreThink"0);
}

public 
FwdPlayerPreThink(plr)
{
    if( !
is_user_alive(plr) )
    {
        return 
FMRES_IGNORED;
    }
    
    new 
Float:maxspeed;
    
pev(plrpev_maxspeedmaxspeed);
    
    new 
Float:velocity[3];
    
velocity_by_aim(plrfloatround(maxspeed), velocity);
    
    
set_pev(plrpev_velocityvelocity);
    
    return 
FMRES_IGNORED;

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
donnie.yang
New Member
Join Date: May 2007
Old 07-21-2008 , 04:42   Re: Question about noclip
Reply With Quote #3

bind "key" +hook
donnie.yang is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-21-2008 , 04:53   Re: Question about noclip
Reply With Quote #4

Not all servers have the hook mod.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Prajch
Senior Member
Join Date: Dec 2007
Location: anger++
Old 08-19-2008 , 01:35   Re: Question about noclip
Reply With Quote #5

You could set their gravity to 0 and then set their velocity with velocityByAim in their prethink, whenever they're holding IN_FORWARD (and when they aren't, set it to 0).

You'll have to simulate strafing and moving backwards too. Moving backwards would be the same but with a negative velocity. For strafing, it's a little more complicated. You'll have to use angle_vector ( Float:vector[3], FRU, Float:vReturn[3] ).

The first parameter is an array containing their view angles; you can get it with something like this if you use Fakemeta:

Code:
 new Float:viewAngles[3]
 pev(id, pev_v_angle, viewAngles)
FRU (stands for forward right up I'm guessing) is one of three values: ANGLEVECTOR_FORWARD (or 1), ANGLEVECTOR_RIGHT (or 2) and ANGLEVECTOR_UP (or 3). Then you create another array and use it as the third parameter; it'll store the components of a unit vector pointing in whatever direction you chose (a unit vector is a directed line with a length of 1).

So for example, if you want to simulate a left strafe movement, you check if the player is holding IN_MOVELEFT, then you use ANGLEVECTOR_RIGHT as your "FRU" value and get a vector pointing in that direction. Then you can set their velocity in the left direction by doing something like this:

Code:
angleVector[0] = -angleVector[0] * desiredVelocity
angleVector[1] = -angleVector[1] * desiredVelocity
angleVector[2] = -angleVector[2] * desiredVelocity
set_pev(id, pev_velocity, angleVector)
You set it as negative because left is the opposite direction of right, and you have to multiply each component by some number, otherwise it'll set their velocity to 1 in that direction (since it's a unit vector).
Prajch is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 08-19-2008 , 12:48   Re: Question about noclip
Reply With Quote #6

What about MOVETYPE_FLY? Did somebody test it?
danielkza is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-19-2008 , 15:12   Re: Question about noclip
Reply With Quote #7

Player pev_movetype values are restricted to MOVETYPE_WALK and MOVETYPE_NOCLIP.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
cs1.7
Senior Member
Join Date: Oct 2008
Old 11-19-2008 , 03:42   Re: Question about noclip
Reply With Quote #8

Quote:
Originally Posted by Prajch View Post
You could set their gravity to 0 and then set their velocity with velocityByAim in their prethink, whenever they're holding IN_FORWARD (and when they aren't, set it to 0).

You'll have to simulate strafing and moving backwards too. Moving backwards would be the same but with a negative velocity. For strafing, it's a little more complicated. You'll have to use angle_vector ( Float:vector[3], FRU, Float:vReturn[3] ).

The first parameter is an array containing their view angles; you can get it with something like this if you use Fakemeta:

Code:
 new Float:viewAngles[3]
 pev(id, pev_v_angle, viewAngles)
FRU (stands for forward right up I'm guessing) is one of three values: ANGLEVECTOR_FORWARD (or 1), ANGLEVECTOR_RIGHT (or 2) and ANGLEVECTOR_UP (or 3). Then you create another array and use it as the third parameter; it'll store the components of a unit vector pointing in whatever direction you chose (a unit vector is a directed line with a length of 1).

So for example, if you want to simulate a left strafe movement, you check if the player is holding IN_MOVELEFT, then you use ANGLEVECTOR_RIGHT as your "FRU" value and get a vector pointing in that direction. Then you can set their velocity in the left direction by doing something like this:

Code:
angleVector[0] = -angleVector[0] * desiredVelocity
angleVector[1] = -angleVector[1] * desiredVelocity
angleVector[2] = -angleVector[2] * desiredVelocity
set_pev(id, pev_velocity, angleVector)
You set it as negative because left is the opposite direction of right, and you have to multiply each component by some number, otherwise it'll set their velocity to 1 in that direction (since it's a unit vector).


omg Prajch

that was a Genius idea!
Mind posting the full code?
i'm going to try to code it right now myself but it will take years for me, especially with the angle_vector part.

IN_LEFT
and IN_RIGHT has to be simulated, too.


Many many +karmas for this code, i promise.
cs1.7 is offline
Reply


Thread Tools
Display Modes

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 05:38.


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