/*
Formatright © 2014
Knife Vip
Author: OvidiuS
Original idea: GaMeR_FoReVeR (http://steamcommunity.com/id/GaMeR_FoReVeR/)
Realease date: 11:20 PM, Wednesday, June 18, 2014 (CEST)
*English*
This plugin is free software;
You can modify it under the terms of the
GNU General Public License as published by the Free Software Foundation.
*Serbian*
Ovaj plugin je besplatni program;
Možete ga menjati poštujući prava autora, samo ga ne smete prodavati.
Svako kršenje GNU licence može da rezultitra tužbom.
*/
#include < amxmodx >
#include < amxmisc >
#include < fakemeta >
#include < engine >
#include < hamsandwich >
#include < cstrike >
#include < fun >
#define flag_set(%1,%2) ( %1 |= ( 1 << ( %2 & 31 ) ) )
#define flag_rem(%1,%2) ( %1 &= ~( 1 << ( %2 & 31 ) ) )
#define flag_get(%1,%2) ( %1 & ( 1 << ( %2 & 31 ) ) )
#define MAX_JUMPS 2
#define XTRA_OFS_PLAYER 5
#define m_afButtonPressed 246
#define Ham_CS_Player_ResetMaxSpeed Ham_Item_PreFrame
enum
{
SCOREATTRIB_ARG_PLAYERID = 1,
SCOREATTRIB_ARG_FLAGS
};
enum ( <<= 1 )
{
SCOREATTRIB_FLAG_NONE = 0,
SCOREATTRIB_FLAG_DEAD = 1,
SCOREATTRIB_FLAG_BOMB,
SCOREATTRIB_FLAG_VIP
};
enum CVARS
{
GRAVITY,
SPEED,
MONEY,
FLAGS_JUMP,
FLAGS_MONEY,
FLAGS_GRAVITY,
FLAGS_SPEED,
FLAGS_PARACHUTE
};
new const global_pCvars[ CVARS ][ ] =
{
"vip_gravity",
"vip_speed",
"vip_money",
"vip_jump_flags",
"vip_money_flags",
"vip_gravity_flags",
"vip_speed_flags",
"vip_parachute_flags"
};
new const global_pValues[ CVARS ][ ] =
{
"0.4",
"500.0",
"2000",
"b",
"t",
"t",
"t",
"t"
};
new global_sModels[ ][ ] =
{
"assasin",
"doktor"
};
new global_msgScreenFade,
global_bIsVip,
global_bIsVip_Jump,
global_bIsVip_Money,
global_bIsVip_Gravity,
global_bIsVip_Speed,
global_bIsVip_Parachute;
new global_iPlayerJumps[ 33 ],
global_iParachuteEntity[ 33 ],
global_sPlayerModel[ 33 ][ 64 ];
new global_cPointer[ CVARS ];
public plugin_init( )
{
register_plugin( "Knife Vip", "0.1", "OvidiuS" );
for ( new CVARS:i = GRAVITY ; i < CVARS ; i++ )
global_cPointer[ i ] = register_cvar( global_pCvars[ i ], global_pValues[ i ] );
RegisterHam( Ham_Spawn, "player", "ham_Spawn_player_post", .Post = true );
RegisterHam( Ham_Player_Jump, "player", "ham_Player_Jump_pre" );
RegisterHam( Ham_CS_Player_ResetMaxSpeed, "player", "ham_ResetMaxSpeed_player_post", .Post = true );
register_forward( FM_SetClientKeyValue, "forward_SetKeyValue" );
register_event( "DeathMsg", "event_DeathMsg", "a" );
register_message( get_user_msgid( "ClCorpse" ), "message_ClCorpse" );
register_message( get_user_msgid( "ScoreAttrib" ), "message_ScoreAttrib" );
global_msgScreenFade = get_user_msgid( "ScreenFade" );
}
public plugin_precache( )
{
precache_model( "models/player/doktor/doktor.mdl" );
precache_model( "models/player/assasin/assasin.mdl" );
precache_model( "models/parachute.mdl" );
}
public client_putinserver( id )
{
global_sPlayerModel[ id ][ 0 ] = EOS;
new sFlags_Jump[ 2 ], sFlags_Money[ 2 ], sFlags_Gravity[ 2 ], sFlags_Speed[ 2 ], sFlags_Parachute[ 2 ];
get_pcvar_string( global_cPointer[ FLAGS_JUMP ], sFlags_Jump, charsmax( sFlags_Jump ) );
get_pcvar_string( global_cPointer[ FLAGS_MONEY ], sFlags_Money, charsmax( sFlags_Money ) );
get_pcvar_string( global_cPointer[ FLAGS_GRAVITY ], sFlags_Gravity, charsmax( sFlags_Gravity ) );
get_pcvar_string( global_cPointer[ FLAGS_SPEED ], sFlags_Speed, charsmax( sFlags_Speed ) );
get_pcvar_string( global_cPointer[ FLAGS_PARACHUTE ], sFlags_Parachute, charsmax( sFlags_Parachute ) );
new iFlags = get_user_flags( id );
new iFlags_Jump = read_flags( sFlags_Jump );
new iFlags_Money = read_flags( sFlags_Money );
new iFlags_Gravity = read_flags( sFlags_Gravity );
new iFlags_Speed = read_flags( sFlags_Speed );
new iFlags_Parachute = read_flags( sFlags_Parachute );
if( iFlags & iFlags_Jump || iFlags & iFlags_Money || iFlags & iFlags_Gravity || iFlags & iFlags_Speed || iFlags & iFlags_Parachute )
{
flag_set( global_bIsVip, id )
if( iFlags & iFlags_Jump )
flag_set( global_bIsVip_Jump, id );
if( iFlags & iFlags_Money )
flag_set( global_bIsVip_Money, id );
if( iFlags & iFlags_Gravity )
flag_set( global_bIsVip_Gravity, id );
if( iFlags & iFlags_Speed )
flag_set( global_bIsVip_Speed, id );
if( iFlags & iFlags_Parachute )
flag_set( global_bIsVip_Parachute, id );
}
}
public client_disconnect( id )
{
flag_rem( global_bIsVip, id );
flag_rem( global_bIsVip_Jump, id );
flag_rem( global_bIsVip_Gravity, id );
flag_rem( global_bIsVip_Speed, id );
flag_rem( global_bIsVip_Parachute, id );
}
public client_PreThink( id )
{
if( flag_get( global_bIsVip_Parachute, id ) )
{
if( !is_user_alive( id ) )
return;
new button = get_user_button( id );
new flags = get_entity_flags( id );
if( button & IN_USE )
{
if( !( flags & FL_ONGROUND ) )
{
new Float:fVelocity[ 3 ];
entity_get_vector( id, EV_VEC_velocity, fVelocity );
if( fVelocity[ 2 ] < 0.0 )
{
if( global_iParachuteEntity[ id ] <= 0 )
{
global_iParachuteEntity[ id ] = create_entity( "info_target" );
if( global_iParachuteEntity[ id ] > 0 )
{
entity_set_model( global_iParachuteEntity[ id ], "models/parachute.mdl" );
entity_set_int( global_iParachuteEntity[ id ], EV_INT_movetype, MOVETYPE_FOLLOW );
entity_set_edict( global_iParachuteEntity[ id ], EV_ENT_aiment, id );
}
}
if( global_iParachuteEntity[ id ] > 0 )
{
fVelocity[ 2 ] = ( fVelocity[ 2 ] + 40.0 < -100.0 ) ? fVelocity[ 2 ] + 40.0 : -100.0;
entity_set_vector( id, EV_VEC_velocity, fVelocity );
if( entity_get_float( global_iParachuteEntity[ id ], EV_FL_frame) < 0.0 || entity_get_float( global_iParachuteEntity[ id ] , EV_FL_frame ) > 254.0 )
{
if( entity_get_int( global_iParachuteEntity[ id ], EV_INT_sequence) != 1 )
entity_set_int( global_iParachuteEntity[ id ], EV_INT_sequence, 1 );
entity_set_float( global_iParachuteEntity[ id ], EV_FL_frame, 0.0 );
}
else
entity_set_float( global_iParachuteEntity[ id ], EV_FL_frame, entity_get_float( global_iParachuteEntity[ id ], EV_FL_frame ) + 1.0 );
}
}
else if( global_iParachuteEntity[ id ] > 0 )
{
remove_entity( global_iParachuteEntity[ id ] )
global_iParachuteEntity[ id ] = 0
}
}
else if( global_iParachuteEntity[ id ] > 0 )
{
remove_entity( global_iParachuteEntity[ id ] )
global_iParachuteEntity[ id ] = 0
}
}
else if( global_iParachuteEntity[ id ] > 0 )
{
remove_entity( global_iParachuteEntity[ id ] )
global_iParachuteEntity[ id ] = 0
}
}
}
public ham_Spawn_player_post( id )
{
if( is_user_alive( id ) && flag_get( global_bIsVip, id ) )
{
new CsTeams:iTeam = cs_get_user_team( id );
if( iTeam == CS_TEAM_CT || iTeam == CS_TEAM_T )
{
copy( global_sPlayerModel[ id ], charsmax( global_sPlayerModel[ ] ), global_sModels[ _:iTeam - 1 ] );
set_user_info( id, "model", global_sPlayerModel[ id ] );
}
if( global_iParachuteEntity[ id ] > 0 )
{
remove_entity( global_iParachuteEntity[ id ] )
entity_set_float( id, EV_FL_gravity, 1.0 );
global_iParachuteEntity[ id ] = 0;
}
if( flag_get( global_bIsVip_Gravity, id ) )
entity_set_float( id, EV_FL_gravity, 1.0 - get_pcvar_float( global_cPointer[ GRAVITY ] ) );
if( flag_get( global_bIsVip_Money, id ) )
cs_set_user_money( id, cs_get_user_money( id ) + get_pcvar_num( global_cPointer[ MONEY ] ) );
}
}
public ham_ResetMaxSpeed_player_post( id )
{
if( flag_get( global_bIsVip_Speed, id ) )
{
static Float:flSpeed;
flSpeed = get_pcvar_float( global_cPointer[ SPEED ] );
engfunc( EngFunc_SetClientMaxspeed, id, flSpeed );
set_pev( id, pev_maxspeed, flSpeed );
//client_cmd( id, "cl_forwardspeed %0.1f;cl_sidespeed %0.1f;cl_backspeed %0.1f", flSpeed, flSpeed, flSpeed );
}
}
public ham_Player_Jump_pre( id )
{
if( !is_user_alive( id ) )
return HAM_IGNORED;
new fFlags = pev( id, pev_flags );
if( fFlags & FL_WATERJUMP || pev( id, pev_waterlevel ) >= 2 || !( get_pdata_int( id, m_afButtonPressed, XTRA_OFS_PLAYER ) & IN_JUMP ) )
{
return HAM_IGNORED;
}
if( fFlags & FL_ONGROUND )
{
global_iPlayerJumps[ id ] = 0;
return HAM_IGNORED;
}
if( flag_get( global_bIsVip_Jump, id ) && ++global_iPlayerJumps[ id ] < MAX_JUMPS )
{
new Float:fVelocity[ 3 ];
pev( id, pev_velocity, fVelocity );
fVelocity[ 2 ] = random_float( 265.0, 285.0 );
set_pev( id, pev_velocity, fVelocity );
return HAM_HANDLED;
}
return HAM_IGNORED;
}
public event_DeathMsg( )
{
new iAttacker = read_data( 1 );
new iVictim = read_data( 2 );
if( global_iParachuteEntity[ iVictim ] > 0 )
{
if( is_valid_ent( global_iParachuteEntity[ iVictim ] ) )
remove_entity( global_iParachuteEntity[ iVictim ] );
global_iParachuteEntity[ iVictim ] = 0;
}
if( iVictim != iAttacker )
{
if( flag_get( global_bIsVip, iVictim ) )
UTIL_ScreenFade( iVictim, 1<<14, 1<<14, 1<<16, 0, 200, 250, 230 );
}
}
public forward_SetKeyValue( id, const _szInfoBuffer[ ], const _szKey[ ], const _szValue[ ] )
{
if( global_sPlayerModel[ id ][ 0 ] && equal( _szKey, "model" ) && !equal( _szValue, global_sPlayerModel[ id ] ) )
{
set_user_info( id, "model", global_sPlayerModel[ id ] );
return FMRES_SUPERCEDE;
}
return FMRES_IGNORED;
}
public message_ClCorpse( )
{
new id = get_msg_arg_int( 12 );
if( global_sPlayerModel[ id ][ 0 ] )
set_msg_arg_string( 1, global_sPlayerModel[ id ] );
}
public message_ScoreAttrib( msgId, iDestination, iReceiver )
{
new id = get_msg_arg_int( SCOREATTRIB_ARG_PLAYERID );
if( flag_get( global_bIsVip, id ) )
set_msg_arg_int( SCOREATTRIB_ARG_FLAGS, ARG_BYTE, SCOREATTRIB_FLAG_VIP );
}
stock UTIL_ScreenFade( id, iDuration, iHoldtime, iFadetype, red, green, blue, alpha )
{
message_begin( MSG_ONE, global_msgScreenFade, { 0, 0, 0 }, id );
write_short( iDuration ); // Duration of fadeout
write_short( iHoldtime ); // Hold time of color
write_short( iFadetype ); // Fade type
write_byte ( red ); // Red
write_byte ( green ); // Green
write_byte ( blue ); // Blue
write_byte ( alpha ); // Alpha
message_end( );
}
Comments