PHP Code:
#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >
#include < engine >
#include < cstrike >
#include < fun >
#pragma semicolon 1
#define PLUGIN_VERSION "1.0.1"
#define TASER_COST 2500
#define TASER_CSGO_DISTANCE_DEFAULT 230
#define is_player(%1) ( 1 <= %1 <= gMaxPlayers )
/* --| Weapon replacement */
new const szZeusWeaponName[ ] = "weapon_fiveseven";
new const gBeamSprite[ ] = "sprites/bolt1.spr";
new const szZeusViewModel[ ] = "models/csg_z/v_zeus.mdl";
new const szZeusPlayerModel[ ] = "models/csg_z/p_zeus.mdl";
new const szNewZeusW[] = "models/csg_z/w_zeus.mdl";
new const szOldZeusW[] = "models/w_fiveseven.mdl";
new const gZeusDrawSound[ ] = "csg_z/zeus_draw.wav";
new const gZeusHitSound[ ] = "csg_z/zeus_hit.wav";
new const gZeusShootSound[ ] = "csg_z/zeus_shoot.wav";
new gBoltSprite; // Efect zeus
new gMaxPlayers; // Jucatori conectati
new pBuyZone; // Pointer buyzone zeus
const m_LinuxDiff = 5;
const XO_CbasePlayerWeapon = 4;
const m_pPlayer = 41;
const m_flNextSecondaryAttack = 47;
const m_flNextAttack = 83;
const m_rgpPlayerItems = 269;
const m_fKnown = 44;
const m_iClip = 51;
const m_iClientClip = 52;
const m_iFivesevenAmmo = 386;
new const m_rgpPlayerItems_CWeaponBox[ 6 ] = { 34, 35, ... };
public plugin_init( )
{
register_plugin( "CS:GO Zeus/taser", PLUGIN_VERSION, "tuty" );
register_forward( FM_CmdStart, "forward_FM_CmdStart" );
register_forward(FM_SetModel, "fwd_SetModel");
register_clcmd( "say /zeus", "command_BuyZeus" );
register_clcmd( "say_team /zeus", "command_BuyZeus" );
register_clcmd( "fiveseven", "block_BuyingFiveSeven" );
register_clcmd( "fn57", "block_BuyingFiveSeven" );
register_clcmd( "buyammo2", "block_BuyingAmmoFiveSeven" );
pBuyZone = register_cvar("zeus_buyzone", "1", FCVAR_EXTDLL|FCVAR_SPONLY|FCVAR_PRINTABLEONLY);
RegisterHam( Ham_Item_AttachToPlayer, szZeusWeaponName, "bacon_AttachToPlayer" );
RegisterHam( Ham_Item_Deploy, szZeusWeaponName, "bacon_ZeusDeploy", 1 );
RegisterHam( Ham_Weapon_SecondaryAttack, szZeusWeaponName, "bacon_SecondaryAttack_Pre", false );
register_touch( "weaponbox", "player", "touch_OnPlayerTouchWeaponBox" );
gMaxPlayers = get_maxplayers( );
}
public plugin_precache( )
{
gBoltSprite = precache_model( gBeamSprite );
precache_model( szZeusViewModel );
precache_model( szZeusPlayerModel );
precache_model( szNewZeusW );
precache_sound( gZeusDrawSound );
precache_sound( gZeusHitSound );
precache_sound( gZeusShootSound );
}
public bacon_ZeusDeploy( iWeaponEntity )
{
new id = get_pdata_cbase( iWeaponEntity, m_pPlayer, m_LinuxDiff );
set_pev( id, pev_viewmodel2, szZeusViewModel );
set_pev( id, pev_weaponmodel2, szZeusPlayerModel );
set_pdata_int( id, m_iFivesevenAmmo, 0, m_LinuxDiff );
set_pdata_float( iWeaponEntity, m_flNextSecondaryAttack, 999999.9, XO_CbasePlayerWeapon );
set_pdata_float( id, m_flNextAttack, 9999.0 );
UTIL_PlayWeaponAnimation( id, 3 );
emit_sound( iWeaponEntity, CHAN_WEAPON, gZeusDrawSound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
}
public forward_FM_CmdStart( id, uc_handle, seed )
{
new iTempTrash[ 2 ];
new iWeapon = get_user_weapon( id, iTempTrash[ 0 ], iTempTrash[ 1 ] );
if ( iWeapon != CSW_FIVESEVEN )
{
return FMRES_IGNORED;
}
new iButtons = get_uc( uc_handle, UC_Buttons );
new iOldButtons = pev( id, pev_oldbuttons );
if( iButtons & IN_ATTACK && !( iOldButtons & IN_ATTACK ) )
{
new iTarget, iDistance = TASER_CSGO_DISTANCE_DEFAULT, iBody;
get_user_aiming( id, iTarget, iBody, iDistance );
if( pev_valid( iTarget )
&& get_user_team( id ) != get_user_team( iTarget )
&& id != iTarget )
{
new iOrigin[ 3 ], iTargetOrigin[ 3 ];
get_user_origin( id, iOrigin, 0 );
get_user_origin( iTarget, iTargetOrigin, 0 );
UTIL_PlayWeaponAnimation( id, 2 );
emit_sound( id, CHAN_WEAPON, gZeusHitSound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
UTIL_CreateThunder( iOrigin, iTargetOrigin );
ExecuteHam( Ham_TakeDamage, iTarget, 0, id, 4000.0, DMG_SHOCK );
engclient_cmd( id, "drop", szZeusWeaponName );
return FMRES_IGNORED;
}
UTIL_PlayWeaponAnimation( id, 2 );
emit_sound( id, CHAN_WEAPON, gZeusShootSound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
engclient_cmd( id, "drop", szZeusWeaponName );
iButtons &= ~IN_ATTACK;
set_uc( uc_handle, UC_Buttons, iButtons );
}
return FMRES_IGNORED;
}
public fwd_SetModel(ent, model[])
{
if(equal(model, szOldZeusW))
{
engfunc(EngFunc_SetModel, ent, szNewZeusW);
return FMRES_SUPERCEDE;
}
return FMRES_IGNORED;
}
public bacon_SecondaryAttack_Pre( iWeaponEntity )
{
return HAM_SUPERCEDE;
}
public block_BuyingFiveSeven( id )
{
if( is_user_alive( id ) )
{
return PLUGIN_HANDLED_MAIN;
}
return PLUGIN_CONTINUE;
}
public block_BuyingAmmoFiveSeven( id )
{
new iTempTrash[ 2 ];
new iWeapon = get_user_weapon( id, iTempTrash[ 0 ], iTempTrash[ 1 ] );
if( iWeapon == CSW_FIVESEVEN )
{
return PLUGIN_HANDLED_MAIN;
}
return PLUGIN_CONTINUE;
}
public command_BuyZeus( id )
{
if( !is_user_alive( id ) )
{
return PLUGIN_HANDLED;
}
if( user_has_weapon( id, CSW_FIVESEVEN ) )
{
client_print( id, print_center, "Ai deja un Zeus X27!" );
return PLUGIN_HANDLED;
}
if (!cs_get_user_buyzone(id) && get_pcvar_num(pBuyZone))
{
client_print( id, print_center, "Nu esti in buyzone.");
return PLUGIN_HANDLED;
}
new iMoney = cs_get_user_money( id );
if( iMoney < TASER_COST )
{
client_print( id, print_center, "Pentru a cumpara Zeus X27 ai nevoie de $%d.", TASER_COST );
return PLUGIN_HANDLED;
}
client_print( id, print_chat, "[CS:GO] Ai cumparat Zeus X27 $%d ca arma secundara.", TASER_COST );
cs_set_user_money( id, iMoney - TASER_COST, 1 );
give_item( id, szZeusWeaponName );
return PLUGIN_CONTINUE;
}
public touch_OnPlayerTouchWeaponBox( iEnt, id )
{
new iId = UTIL_GetWeaponBoxWeaponType( iEnt );
if( is_user_alive( id )
&&is_player( id )
&& pev_valid( iEnt ) )
{
if( iId == CSW_FIVESEVEN )
{
return PLUGIN_HANDLED;
}
}
return PLUGIN_CONTINUE;
}
public bacon_AttachToPlayer( iEnt, id )
{
if( get_pdata_int( iEnt, m_fKnown, XO_CbasePlayerWeapon ) )
{
return;
}
set_pdata_int( iEnt, m_iClip, 1, XO_CbasePlayerWeapon );
set_pdata_int( id, m_iClientClip, 0, m_LinuxDiff );
}
stock UTIL_PlayWeaponAnimation( const Player, const Sequence )
{
if(is_user_connected(Player)) {
set_pev( Player, pev_weaponanim, Sequence );
message_begin( MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player );
write_byte( Sequence );
write_byte( pev( Player, pev_body ) );
message_end( );
}
}
stock UTIL_CreateThunder( iStart[ 3 ], iEnd[ 3 ] )
{
message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
write_byte( TE_BEAMPOINTS );
write_coord( iStart[ 0 ] );
write_coord( iStart[ 1 ] );
write_coord( iStart[ 2 ] );
write_coord( iEnd[ 0 ] );
write_coord( iEnd[ 1 ] );
write_coord( iEnd[ 2 ] );
write_short( gBoltSprite );
write_byte( 1 );
write_byte( 5 );
write_byte( 7 );
write_byte( 20 );
write_byte( 30 );
write_byte( 135 );
write_byte( 206 );
write_byte( 250 );
write_byte( 255 );
write_byte( 145 );
message_end( );
}
/* --| Connor */
stock UTIL_GetWeaponBoxWeaponType( iEntity )
{
new iWeapon;
for( new i = 1; i <= 5; i++ )
{
iWeapon = get_pdata_cbase( iEntity, m_rgpPlayerItems_CWeaponBox[ i ], XO_CbasePlayerWeapon );
if( iWeapon > 0 )
{
return cs_get_weapon_id( iWeapon );
}
}
return 0;
}