Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Formatright © 2009, Jon
- "Weed (CS)" is free software;
- you can redistribute it and/or modify it under the terms of the
- GNU General Public License as published by the Free Software Foundation.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with "Weed (CS)"; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
- */
- #include <amxmodx>
- #include <fakemeta>
- #include <engine>
- #define PLUGIN "Weed"
- #define VERSION "1.0"
- #define AUTHOR "Jon"
- #define write_coord_f(%1) engfunc(EngFunc_WriteCoord,%1)
- #define FOV_AMOUNT 120
- new const g_szHatModel[ ] = "models/hat/jamacahat2.mdl";
- new const g_szSmokeSprite[ ] = "sprites/steam1.spr";
- new const g_szSoundFile[ ] = "your_sound_file.mp3";
- new const g_szEntityClass[ ] = "class_weed";
- new g_pDuration;
- new g_pCoolDown;
- new g_pAngles;
- new g_pDamage;
- new g_pColor;
- new g_pAdminOnly;
- new g_iMaxPlayers;
- new g_iMsgSetFOV;
- new g_iMsgScreenFade;
- new g_iSmoke;
- new g_iTimer[ 33 ];
- new bool:g_bColor;
- new bool:g_bAngles;
- new bool:g_bDamage;
- new bool:g_bSmoking[ 33 ];
- new Float:g_fCoolDown[ 33 ];
- public plugin_precache( )
- {
- precache_sound( g_szSoundFile );
- precache_model( g_szHatModel );
- precache_model( "models/rpgrocket.mdl" );
- g_iSmoke = precache_model( g_szSmokeSprite );
- }
- public plugin_init( )
- {
- register_plugin( PLUGIN, VERSION, AUTHOR );
- g_pDuration = register_cvar( "weed_duration", "10" );
- g_pCoolDown = register_cvar( "weed_cooldown", "60.0" );
- g_pColor = register_cvar( "weed_color", "1" );
- g_pDamage = register_cvar( "weed_damage", "1" );
- g_pAngles = register_cvar( "weed_angles", "1" );
- g_pAdminOnly = register_cvar( "weed_adminonly", "0" );
- g_iMaxPlayers = get_maxplayers( );
- g_iMsgSetFOV = get_user_msgid( "SetFOV" );
- g_iMsgScreenFade = get_user_msgid( "ScreenFade" );
- register_event( "HLTV", "EventNewRound", "a", "1=0", "2=0" );
- register_logevent( "EventStartRound", 2, "1=Round_Start" );
- register_think( g_szEntityClass, "FwdWeedThink" );
- register_clcmd( "say /weed", "CmdWeed" );
- }
- public EventNewRound( )
- {
- for( new i = 1; i <= g_iMaxPlayers; i++ )
- {
- g_bSmoking[ i ] = false;
- }
- }
- public EventStartRound( )
- {
- g_bColor = bool:get_pcvar_num( g_pColor );
- g_bAngles = bool:get_pcvar_num( g_pAngles );
- g_bDamage = bool: get_pcvar_num( g_pDamage );
- }
- public CmdWeed( iClient )
- {
- if( !is_user_alive( iClient ) )
- {
- client_print( iClient, print_chat, "[WEED] Dead men smoke no weed." );
- }
- else if( g_fCoolDown[ iClient ] > get_gametime( ) )
- {
- client_print( iClient, print_chat, "[WEED] Try again in %.1f seconds.", g_fCoolDown[ iClient ] - get_gametime( ) );
- }
- else if( g_bSmoking[ iClient ] )
- {
- client_print( iClient, print_chat, "[WEED] Dumbass! You're already smoking." );
- }
- else if( get_pcvar_num( g_pAdminOnly ) && !( get_user_flags( iClient ) & ADMIN_BAN ) )
- {
- client_print( iClient, print_chat, "[WEED] Only admins smoke weed." );
- }
- else
- {
- StartSmoking( iClient );
- }
- }
- public FwdWeedThink( iEnt )
- {
- new iClient = entity_get_edict( iEnt, EV_ENT_aiment );
- if( !is_user_alive( iClient ) || !g_bSmoking[ iClient ] )
- {
- StopSmoking( iClient, iEnt );
- return PLUGIN_HANDLED;
- }
- if( g_iTimer[ iClient ] > 0 )
- {
- UTIL_Smoke( iEnt );
- if( g_bColor )
- {
- UTIL_ScreenFade( iClient );
- }
- if( g_bAngles )
- {
- new Float:vPunchAngle[ 3 ];
- vPunchAngle[ 0 ] = random_float( 0.0, 180.0 );
- vPunchAngle[ 1 ] = random_float( 0.0, 180.0 );
- vPunchAngle[ 2 ] = random_float( 0.0, 180.0 );
- entity_set_vector( iClient, EV_VEC_punchangle, vPunchAngle );
- }
- if( g_bDamage )
- {
- fakedamage( iClient, "weed", 1.0, DMG_FREEZE );
- }
- g_iTimer[ iClient ]--;
- entity_set_float( iEnt, EV_FL_nextthink, get_gametime( ) + 1.0 );
- }
- else
- {
- StopSmoking( iClient, iEnt );
- }
- return PLUGIN_CONTINUE;
- }
- StartSmoking( const iClient )
- {
- new iEnt = create_entity( "info_target" );
- entity_set_string( iEnt, EV_SZ_classname, g_szEntityClass );
- entity_set_int( iEnt, EV_INT_movetype, MOVETYPE_FOLLOW );
- entity_set_edict( iEnt, EV_ENT_aiment, iClient );
- entity_set_model( iEnt, g_szHatModel );
- g_bSmoking[ iClient ] = true;
- g_iTimer[ iClient ] = get_pcvar_num( g_pDuration );
- UTIL_Fov( iClient, 130 );
- entity_set_float( iEnt, EV_FL_nextthink, get_gametime( ) );
- client_cmd( iClient, "mp3 play sound/%s", g_szSoundFile );
- new szName[ 33 ];
- get_user_name( iClient, szName, 32 );
- set_hudmessage( random( 256 ), random( 256 ), random( 256 ), -1.0, -1.0, 1, 0.0, 4.0 );
- show_hudmessage( 0, "%s is smoking weeeeed!", szName );
- }
- StopSmoking( const iClient, const iEnt )
- {
- g_bSmoking[ iClient ] = false;
- g_fCoolDown[ iClient ] = get_gametime( ) + get_pcvar_float( g_pCoolDown );
- UTIL_Fov( iClient, 90 );
- client_cmd( iClient, "mp3 stop" );
- if( g_bAngles )
- {
- entity_set_vector( iClient, EV_VEC_punchangle, Float:{ 0.0, 0.0, 0.0 } );
- }
- remove_entity( iEnt );
- }
- UTIL_ScreenFade( const iClient )
- {
- message_begin( MSG_ONE, g_iMsgScreenFade, _, iClient )
- write_short( 4096 );
- write_short( 4096 );
- write_short( 0x0000 );
- write_byte( random( 256 ) );
- write_byte( random( 256 ) );
- write_byte( random( 256 ) );
- write_byte( random( 256 ) );
- message_end( );
- }
- UTIL_Fov( const iClient, const iAmount )
- {
- message_begin( MSG_ONE, g_iMsgSetFOV, _, iClient );
- write_byte( iAmount );
- message_end( );
- }
- UTIL_Smoke( const iEnt )
- {
- new Float:vOrigin[ 3 ];
- entity_get_vector( iEnt, EV_VEC_origin, vOrigin );
- message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
- write_byte( TE_SMOKE );
- write_coord_f( vOrigin[ 0 ] );
- write_coord_f( vOrigin[ 1 ] );
- write_coord_f( vOrigin[ 2 ] );
- write_short( g_iSmoke );
- write_byte( 10 );
- write_byte( 10 );
- message_end( );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement