Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <fakemeta>
- #include <colorchat>
- #pragma semicolon 1
- #define MIN_DISTANCE 215.0
- #define MAX_DISTANCE 275.0
- enum JumpType {
- Type_LongJump = 0,
- Type_HighJump = 1,
- Type_CountJump = 2,
- Type_BhopLongJump = 3,
- Type_DuckBhopLongJump = 4,
- Type_StandupBhopLongJump = 5,
- Type_WeirdLongJump = 6,
- Type_Drop_BhopLongJump = 7,
- Type_Drop_CountJump = 8,
- Type_Multi_CountJump = 9,
- Type_Multi_Bhop = 10
- };
- new Float:old_angle1[33];
- new g_lj_stats[33];
- new strafe_num[33];
- new g_Jumped[33];
- new g_reset[33];
- new sv_gravity;
- public plugin_init() {
- register_plugin( "KZ Stats", "xPaw", "SchlumPF" );
- register_clcmd( "say beta", "cmdljStats" );
- register_clcmd( "say /beta", "cmdljStats" );
- register_forward( FM_PlayerPreThink, "fwdPlayerPreThink", 0 );
- register_forward( FM_PlayerPostThink, "fwdPlayerPostThink", 0 );
- sv_gravity = get_cvar_pointer( "sv_gravity" );
- }
- public fwdPlayerPreThink(plr) {
- if( !g_lj_stats[plr] ) {
- return FMRES_IGNORED;
- }
- //else if(get_user_team(plr) == 1) {
- static JumpType:jump_type[33];
- static frames[33], frames_gained_speed[33];
- static bool:in_air[33], bool:in_duck[33], bool:in_bhop[33];
- static bool:failed_jump[33], bool:failed_ducking[33];
- static bool:first_frame[33], bool:started_cj_pre[33], bool:started_multicj_pre[33];
- static Float:maxspeed[33], Float:prestrafe[33];
- static Float:frame_origin[33][2][3], Float:frame_velocity[33][2][3];
- static Float:duckoff_time[33], Float:jumpoff_time[33], Float:last_land_time[33];
- static Float:duckoff_origin[33][3], Float:jumpoff_origin[33][3], Float:pre_jumpoff_origin[33][3];
- static Float:failed_origin[33][3];
- if( g_reset[plr] ) {
- g_reset[plr] = false;
- g_Jumped[plr] = false;
- in_air[plr] = false;
- in_duck[plr] = false;
- in_bhop[plr] = false;
- failed_jump[plr] = false;
- frames_gained_speed[plr] = 0;
- frames[plr] = 0;
- strafe_num[plr] = 0;
- started_multicj_pre[plr] = false;
- started_cj_pre[plr] = false;
- jump_type[plr] = Type_LongJump;
- }
- static button, oldbuttons, flags;
- button = pev( plr, pev_button );
- flags = pev( plr, pev_flags );
- oldbuttons = pev( plr, pev_oldbuttons );
- static Float:origin[3];
- pev( plr, pev_origin, origin );
- static Float:velocity[3], Float:speed;
- pev( plr, pev_velocity, velocity );
- speed = get_speed( velocity );
- if( in_air[plr] && !( flags & FL_ONGROUND ) && !failed_jump[plr] )
- {
- static Float:old_speed[33];
- if( speed > old_speed[plr] )
- {
- frames_gained_speed[plr]++;
- }
- frames[plr]++;
- old_speed[plr] = speed;
- if( speed > maxspeed[plr] )
- {
- maxspeed[plr] = speed;
- }
- if( in_bhop[plr] ? floatsub( origin[2] + 18.0, pre_jumpoff_origin[plr][2] ) < 0 : floatsub( origin[2] + 18.0, jumpoff_origin[plr][2] ) < 0 )
- {
- failed_jump[plr] = true;
- failed_jump[plr] = true;
- failed_ducking[plr] = is_user_ducking( plr );
- static Float:jumpoff_z_origin;
- jumpoff_z_origin = jumpoff_origin[plr][2];
- if( failed_ducking[plr] )
- {
- jumpoff_z_origin -= 18.0;
- origin[2] -= 18.0;
- }
- static Float:temp;
- temp = ( jumpoff_z_origin - frame_origin[plr][1][2] ) / ( origin[2] - frame_origin[plr][1][2] );
- failed_origin[plr][0] = temp * ( origin[0] - frame_origin[plr][1][0] ) + frame_origin[plr][1][0];
- failed_origin[plr][1] = temp * ( origin[1] - frame_origin[plr][1][1] ) + frame_origin[plr][1][1];
- failed_origin[plr][2] = jumpoff_z_origin;
- return FMRES_IGNORED;
- }
- if( first_frame[plr] )
- {
- first_frame[plr] = false;
- frame_origin[plr][0] = origin;
- frame_velocity[plr][0] = velocity;
- if( in_bhop[plr] )
- {
- if( velocity[2] < 229.0 )
- {
- jump_type[plr] = Type_BhopLongJump;
- }
- else if( velocity[2] )
- {
- if( button & IN_DUCK && oldbuttons & IN_DUCK )
- {
- jump_type[plr] = Type_DuckBhopLongJump;
- }
- else
- {
- jump_type[plr] = Type_StandupBhopLongJump;
- }
- }
- jumpoff_origin[plr][2] = pre_jumpoff_origin[plr][2];
- }
- } else {
- frame_origin[plr][1] = origin;
- frame_velocity[plr][1] = velocity;
- }
- }
- else if( button & IN_JUMP && !( oldbuttons & IN_JUMP ) && flags & FL_ONGROUND && !in_air[plr] )
- {
- jumpoff_time[plr] = get_gametime( );
- jumpoff_origin[plr] = origin;
- if( jump_type[plr] == Type_CountJump || jump_type[plr] == Type_Multi_CountJump ) {
- if( ( button & IN_DUCK && oldbuttons & IN_DUCK ) && ( 0.35 > jumpoff_time[plr] - duckoff_time[plr] > 0.3 ) )
- {
- // russian walk + bhop after it.
- }
- else if( jumpoff_time[plr] - duckoff_time[plr] >= 0.3 )
- {
- jump_type[plr] = Type_LongJump;
- }
- else
- {
- static bool:ducking;
- ducking = is_user_ducking( plr );
- static classname[32];
- pev( pev( plr, pev_groundentity ), pev_classname, classname, 31 );
- static Float:height_difference;
- height_difference = floatabs( ducking ? jumpoff_origin[plr][2] - origin[2] - 18.0 : jumpoff_origin[plr][2] - origin[2] );
- if( equal( classname, "func_door" ) && height_difference >= 1.0 )
- {
- g_reset[plr] = true;
- return FMRES_IGNORED;
- }
- else if( !equal( classname, "func_door" ) && height_difference )
- {
- g_reset[plr] = true;
- return FMRES_IGNORED;
- }
- }
- }
- in_air[plr] = true;
- g_Jumped[plr] = true;
- first_frame[plr] = true;
- prestrafe[plr] = speed;
- maxspeed[plr] = speed;
- }
- else if( flags & FL_ONGROUND && in_air[plr] ) {
- static bool:ducking;
- static type[32];
- type[0] = '^0';
- if( failed_jump[plr] )
- {
- origin = failed_origin[plr];
- ducking = failed_ducking[plr];
- }
- else
- ducking = is_user_ducking( plr );
- last_land_time[plr] = get_gametime( );
- static Float:distance1;
- distance1 = get_distance_f( jumpoff_origin[plr], origin ) + 32.0625;
- static Float:gravity;
- gravity = get_pcvar_float( sv_gravity );
- static Float:_time;
- _time = floatdiv( floatsqroot( floatpower( frame_velocity[plr][0][2], 2.0 ) + ( 2 * gravity * ( frame_origin[plr][0][2] - origin[2] ) ) ) * -1.0 - frame_velocity[plr][1][2], gravity * -1.0 );
- if( frame_velocity[plr][1][0] < 0.0 ) frame_velocity[plr][1][0] *= -1.0;
- if( frame_velocity[plr][1][1] < 0.0 ) frame_velocity[plr][1][1] *= -1.0;
- static Float:x_difference, Float:y_difference;
- x_difference = _time * frame_velocity[plr][1][0];
- y_difference = _time * frame_velocity[plr][1][1];
- static Float:land_origin[3];
- land_origin[0] = frame_origin[plr][1][0] < origin[0] ? frame_origin[plr][1][0] + x_difference : frame_origin[plr][1][0] - x_difference;
- land_origin[1] = frame_origin[plr][1][1] < origin[1] ? frame_origin[plr][1][1] + y_difference : frame_origin[plr][1][1] - y_difference;
- land_origin[2] = ducking ? origin[2] + 18.0 : origin[2];
- static Float:distance2;
- distance2 = get_distance_f( jumpoff_origin[plr], land_origin ) + 32.0625;
- static Float:distance;
- distance = distance1 > distance2 ? distance2 : distance1;
- if( distance < MIN_DISTANCE || MAX_DISTANCE < distance ) {
- g_reset[plr] = true;
- return FMRES_IGNORED;
- }
- if( jump_type[plr] == Type_LongJump ) {
- static Float:start[3];
- start[0] = ( jumpoff_origin[plr][0] + land_origin[0] ) * 0.5;
- start[1] = ( jumpoff_origin[plr][1] + land_origin[1] ) * 0.5;
- start[2] = ducking ? origin[2] - 18.1 : origin[2] - 36.1;
- if( engfunc( EngFunc_PointContents, start ) == CONTENTS_EMPTY ) {
- static Float:stop[3], Float:fraction, Float:max_fraction;
- stop[0] = jumpoff_origin[plr][0];
- stop[1] = jumpoff_origin[plr][1];
- if( start[0] < stop[0] )
- stop[0] += stop[0] - start[0];
- else
- stop[0] -= start[0] - stop[0];
- if( start[1] < stop[1] )
- stop[1] += stop[1] - start[1];
- else
- stop[1] -= start[1] - stop[1];
- stop[2] = start[2];
- jumpoff_origin[plr][2] -= 0.1;
- static Float:temp;
- temp = get_distance_f( jumpoff_origin[plr], start );
- max_fraction = floatdiv( temp + 16.03125, temp * 2.0 );
- engfunc( EngFunc_TraceHull, start, stop, IGNORE_MONSTERS, HULL_HUMAN, plr, 0 );
- get_tr2( 0, TR_flFraction, fraction );
- if( fraction < max_fraction ) {
- get_tr2( 0, TR_vecEndPos, start );
- stop[0] = start[0];
- stop[1] = start[1];
- stop[2] = start[2] - 69.9;
- engfunc( EngFunc_TraceLine, start, stop, IGNORE_MONSTERS, plr, 0 );
- get_tr2( 0, TR_flFraction, fraction );
- if( fraction == 1.0 )
- jump_type[plr] = Type_HighJump;
- }
- }
- }
- // Primitive Weird LJ fake :D
- if( jump_type[plr] == Type_LongJump || jump_type[plr] == Type_HighJump )
- if(distance >= 256.0 || prestrafe[plr] >= 278.0)
- jump_type[plr] = Type_WeirdLongJump;
- static Float:sync, Float:gain;
- sync = floatdiv( float( frames_gained_speed[plr] * 100 ), float( frames[plr] ) );
- gain = floatsub( maxspeed[plr], prestrafe[plr] );
- if( !failed_jump[plr] )
- set_hudmessage( 111, 111, 160, -1.0, -0.2, 0, 6.0, 2.5, 0.1, 0.3, 3 );
- else
- set_hudmessage( 255, 0, 109, -1.0, -0.2, 0, 6.0, 2.5, 0.1, 0.3, 3 );
- static Float:max_prestrafe;
- if( jump_type[plr] == Type_LongJump || jump_type[plr] == Type_HighJump )
- {
- max_prestrafe = pev( plr, pev_maxspeed ) * 1.115;
- }
- else
- {
- max_prestrafe = pev( plr, pev_maxspeed ) * 1.2;
- }
- if( distance >= 220.0 ) {
- show_hudmessage( plr, "Distance: %f^nMaxSpeed: %f (%.03f)^nPreStrafe: %f (%.03f)^nStrafes: %d ^nSync: %d%%", distance, maxspeed[plr], gain, prestrafe[plr], max_prestrafe, strafe_num[plr], floatround(sync) );
- }
- client_print( plr, print_console, "Distance: %f MaxSpeed: %f (Gain %f) Prestrafe: %f Strafes: %d Sync: %d", distance, maxspeed[plr], gain, prestrafe[plr], strafe_num[plr], floatround(sync) );
- g_reset[plr] = true;
- }
- if( !in_air[plr] && button & IN_DUCK && flags & FL_ONGROUND && !in_duck[plr] )
- {
- if( get_gametime( ) - duckoff_time[plr] < 0.3 )
- started_multicj_pre[plr] = true;
- else
- started_cj_pre[plr] = true;
- in_duck[plr] = true;
- }
- else if( !in_air[plr] && oldbuttons & IN_DUCK )
- {
- if( !is_user_ducking( plr ) )
- {
- in_duck[plr] = false;
- if( started_cj_pre[plr] )
- {
- started_cj_pre[plr] = false;
- duckoff_time[plr] = get_gametime( );
- duckoff_origin[plr] = origin;
- strafe_num[plr] = 0;
- jump_type[plr] = Type_CountJump;
- }
- else if( started_multicj_pre[plr] )
- {
- started_multicj_pre[plr] = false;
- duckoff_time[plr] = get_gametime( );
- duckoff_origin[plr] = origin;
- strafe_num[plr] = 0;
- jump_type[plr] = Type_Multi_CountJump;
- }
- }
- //}
- }
- return FMRES_IGNORED;
- }
- public fwdPlayerPostThink( id ) {
- // This is only strafecounter added by xPaw!
- if( g_Jumped[id] ) {
- static buttons;
- static Float:angle[3];
- static bool:turning_left[33];
- static bool:turning_right[33];
- static bool:straifing_aw[33];
- static bool:straifing_sd[33];
- buttons = pev(id, pev_button);
- pev(id, pev_angles, angle);
- if( old_angle1[id] > angle[1] ) {
- turning_left[id] = false;
- turning_right[id] = true;
- }
- else if( old_angle1[id] < angle[1] ) {
- turning_left[id] = true;
- turning_right[id] = false;
- } else {
- turning_left[id] = false;
- turning_right[id] = false;
- }
- if( !straifing_aw[id]
- && (buttons&IN_MOVELEFT
- || buttons&IN_FORWARD)
- && (turning_left[id]
- || turning_right[id] )
- && !(buttons&IN_MOVERIGHT
- || buttons&IN_BACK) ) {
- straifing_aw[id] = true;
- straifing_sd[id] = false;
- strafe_num[id] += 1;
- }
- else if( !straifing_sd[id]
- && (buttons&IN_MOVERIGHT
- || buttons&IN_BACK)
- && (turning_left[id]
- || turning_right[id] )
- && !(buttons&IN_MOVELEFT
- || buttons&IN_FORWARD) ) {
- straifing_aw[id] = false;
- straifing_sd[id] = true;
- strafe_num[id] += 1;
- }
- }
- }
- public client_command( plr ) {
- static command[32];
- read_argv( 0, command, 31 );
- static const forbidden[][] = {
- "tele", "tp", "gocheck", "gc", "stuck", "unstuck", "start", "reset", "restart",
- "spawn", "respawn"
- };
- if( equal( command, "say" ) ) {
- read_args( command, 31 );
- remove_quotes( command );
- }
- if( equal( command, "+hook" ) ) {
- g_reset[plr] = true;
- }
- else if( command[0] == '/' || command[0] == '.' ) {
- copy( command, 31, command[1] );
- for( new i ; i < sizeof( forbidden ) ; i++ ) {
- if( equal( command, forbidden[i] ) ) {
- g_reset[plr] = true;
- break;
- }
- }
- }
- }
- public cmdljStats( plr ) {
- g_lj_stats[plr] = !g_lj_stats[plr];
- ColorChat(plr, GREY, "%s, minimali distancija 220", g_lj_stats[plr] ? "ijungta" : "isjungta");
- client_cmd(plr,"say /ljstats");
- }
- public client_connect( plr )
- g_lj_stats[plr] = false;
- Float:get_speed( Float:velocity[3] )
- return floatsqroot( floatpower( velocity[0], 2.0 ) + floatpower( velocity[1], 2.0 ) );
- bool:is_user_ducking( plr ) {
- if( !pev_valid( plr ) )
- return false;
- new Float:abs_min[3], Float:abs_max[3];
- pev( plr, pev_absmin, abs_min );
- pev( plr, pev_absmax, abs_max );
- abs_min[2] += 64.0;
- if( abs_min[2] < abs_max[2] )
- return false;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement