Posts: 180
Threads: 15
Joined: Feb 2011
Reputation:
10
09-18-2011, 21:55
(This post was last modified: 09-18-2011, 22:01 by Cyborgking.)
Can someone make a code that pushes the player in the direction he is aiming?
The player should not get pushed in the air but only the x and y axis.
This stuff might help:
setvelocity(x velocity, y velocity , z velocity)
getvelocity()
Code from 4funplaying:
Code: getAim()
{
forward = self getTagOrigin("tag_eye");
end = self vector_Scal(anglestoforward(self getPlayerAngles()),1000000);
Crosshair = BulletTrace( forward, end, true, self )[ "position" ];
return Crosshair;
}
vector_scal(vec, scale)
{
vec = (vec[0] * scale, vec[1] * scale, vec[2] * scale);
return vec;
}
You'd probably also have to do some vector math and such but that's the part of math I am the worst at so I know nothing about that.
Good luck to anyone who's going to try!
Posts: 4,530
Threads: 254
Joined: Nov 2010
Reputation:
65
09-18-2011, 22:01
(This post was last modified: 09-18-2011, 22:01 by AZUMIKKEL.)
04:35 ?
Posts: 180
Threads: 15
Joined: Feb 2011
Reputation:
10
(09-18-2011, 22:01)AZUMIKKEL Wrote: 04:35 ?
Yea like that, but without the height.
Posts: 4,530
Threads: 254
Joined: Nov 2010
Reputation:
65
09-18-2011, 22:24
(This post was last modified: 09-18-2011, 22:24 by AZUMIKKEL.)
PHP Code: case 28: // NINJA
// self thread Weapon("creek_knife_sp");
// self thread Instruct("^2[^7[{+attack}]^2] ^7to jump!");
self setperk("specialty_bulletpenetration");
self setperk("specialty_bulletflinch");
self setperk("specialty_bulletdamage");
self setperk("specialty_bulletaccuracy");
self setperk("specialty_fastads");
self setperk("specialty_fallheight");
for(;;)
{
while(!self attackButtonPressed())
wait 0.05;
forward = AnglesToForward( self getPlayerAngles() );
self setOrigin(self.origin+(0,0,5));
self setVelocity((forward[0]*1000, forward[1]*1000, forward[2]*1000));
wait 0.01;
self setVelocity((forward[0]*1000, forward[1]*1000, forward[2]*1000));
wait 0.01;
self setVelocity((forward[0]*1000, forward[1]*1000, forward[2]*1000));
wait 0.01;
self setVelocity((forward[0]*1000, forward[1]*1000, forward[2]*1000));
wait 0.01;
self setVelocity((forward[0]*1000, forward[1]*1000, forward[2]*1000));
while(!self isOnGround())
{
wait 0.1;
}
}
VOTE 4 AZU
Posts: 180
Threads: 15
Joined: Feb 2011
Reputation:
10
09-19-2011, 07:23
(This post was last modified: 09-19-2011, 07:24 by Cyborgking.)
(09-18-2011, 22:24)AZUMIKKEL Wrote: PHP Code: case 28: // NINJA
// self thread Weapon("creek_knife_sp");
// self thread Instruct("^2[^7[{+attack}]^2] ^7to jump!");
self setperk("specialty_bulletpenetration");
self setperk("specialty_bulletflinch");
self setperk("specialty_bulletdamage");
self setperk("specialty_bulletaccuracy");
self setperk("specialty_fastads");
self setperk("specialty_fallheight");
for(;;)
{
while(!self attackButtonPressed())
wait 0.05;
forward = AnglesToForward( self getPlayerAngles() );
self setOrigin(self.origin+(0,0,5));
self setVelocity((forward[0]*1000, forward[1]*1000, forward[2]*1000));
wait 0.01;
self setVelocity((forward[0]*1000, forward[1]*1000, forward[2]*1000));
wait 0.01;
self setVelocity((forward[0]*1000, forward[1]*1000, forward[2]*1000));
wait 0.01;
self setVelocity((forward[0]*1000, forward[1]*1000, forward[2]*1000));
wait 0.01;
self setVelocity((forward[0]*1000, forward[1]*1000, forward[2]*1000));
while(!self isOnGround())
{
wait 0.1;
}
}
VOTE 4 AZU Thanks!
You certainly got my vote now!
Posts: 1,185
Threads: 72
Joined: Jan 2011
Reputation:
25
it would be much easier(i thin) with that code u posted above:
Code: doJump()
{
self endon("disconnect");
for( ; ; )
{
if(self AttackButtonPressed() && Distance2D(self.origin,self getAim()) <= 1000) //could be each other button too...
{
self setOrigin(self getAim());
wait 1;
}
wait 0.01;
}
}
getAim()
{
forward = self getTagOrigin("tag_eye");
end = self vector_Scal(anglestoforward(self getPlayerAngles()),1000000);
Crosshair = BulletTrace( forward, end, true, self )[ "position" ];
return (Crosshair[0], Crosshair[1], self.origin[2]);
}
vector_scal(vec, scale)
{
vec = (vec[0] * scale, vec[1] * scale, vec[2] * scale);
return vec;
}
Posts: 180
Threads: 15
Joined: Feb 2011
Reputation:
10
09-21-2011, 13:17
(This post was last modified: 09-21-2011, 13:19 by Cyborgking.)
(09-21-2011, 13:04)Tomsen1410 Wrote: it would be much easier(i thin) with that code u posted above:
Code: doJump()
{
self endon("disconnect");
for( ; ; )
{
if(self AttackButtonPressed() && Distance2D(self.origin,self getAim()) <= 1000) //could be each other button too...
{
self setOrigin(self getAim());
wait 1;
}
wait 0.01;
}
}
getAim()
{
forward = self getTagOrigin("tag_eye");
end = self vector_Scal(anglestoforward(self getPlayerAngles()),1000000);
Crosshair = BulletTrace( forward, end, true, self )[ "position" ];
return (Crosshair[0], Crosshair[1], self.origin[2]);
}
vector_scal(vec, scale)
{
vec = (vec[0] * scale, vec[1] * scale, vec[2] * scale);
return vec;
}
But with this code, I think the player gets teleported to the location and not pushed?
Azu code works fine with a small edit(remove the z push). The only drawback is that you get odd recoil while being pushed if you are still walking at the time you get pushed.
Posts: 1,185
Threads: 72
Joined: Jan 2011
Reputation:
25
Nope, u get pushed, cause of 3arc exactly like for AZU : )
|