Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma semicolon 1
- #include <sourcemod>
- #include <sdktools>
- #include <cstrike>
- #define PLUGIN_VERSION "1.0"
- #define MSG "%t"
- new vote_counter;
- new bool:voted_clients[MAXPLAYERS];
- new Handle:g_hPlugin = INVALID_HANDLE;
- new Handle:g_hPlayersToVote = INVALID_HANDLE;
- new Handle:g_hAllowToClients = INVALID_HANDLE;
- public Plugin:myinfo =
- {
- name = "С4 Drop",
- author = "Push",
- description = "Teleport C4 to Terrorists' Spawn Point",
- version = PLUGIN_VERSION,
- url = "http://css-quad.ru"
- };
- public OnPluginStart()
- {
- RegAdminCmd( "sm_drc4", CommandHandler, ADMFLAG_BAN);
- RegConsoleCmd( "sm_votec4", ClientsCommandHandler );
- g_hPlugin = CreateConVar( "dropc4_enabled", "1", "Enable plugin?" );
- g_hPlayersToVote = CreateConVar( "dropc4_pct_to_vote", "40", "How many clients' votes for doing something?" );
- g_hAllowToClients = CreateConVar( "dropc4_allow_to_clients", "1", "Allow clients to use votec4 command?" );
- LoadTranslations( "return_c4.phrases" );
- }
- public OnMapStart()
- {
- vote_counter = 0;
- for( new i = 0; i < sizeof( voted_clients ); i++ ) voted_clients[i] = false;
- }
- public Action:CommandHandler( client, args )
- {
- if( GetConVarBool( g_hPlugin ) )
- {
- if ( args != 0 )
- {
- return Plugin_Handled;
- }
- DropC4();
- return Plugin_Handled;
- }
- return Plugin_Continue;
- }
- public OnClientDisconnect( client )
- {
- if( GetConVarBool( g_hPlugin ) )
- {
- if( voted_clients[ client ] )
- {
- voted_clients[ client ] = false;
- counter--;
- }
- }
- }
- public Action:ClientsCommandHandler( client, args )
- {
- if( GetConVarBool( g_hPlugin ) && GetConVarBool( g_hAllowToClients ) )
- {
- if( IsClientInGame( client ) && !voted_clients[ client ] )
- {
- voted_clients[ client ] = true;
- counter ++;
- PrintToChat( client, MSG, "Player voted", counter, );
- }
- else
- {
- PrintToChat( client, MSG, "Already voted" );
- }
- if( float(counter) >= float(MaxClients) / 100 * GetConVarInt(g_hPlayersToVote) )
- {
- PrintToChatAll( MSG, "Taken away" );
- counter = 0;
- DropC4();
- }
- return Plugin_Handled;
- }
- return Plugin_Continue;
- }
- stock void:DropC4()
- {
- for( new i = 1; i < MaxClients; i++ )
- {
- if( IsClientInGame(i) && GetPlayerWeaponSlot(i, 4) != -1 && GetClientTeam(i) == CS_TEAM_T )
- {
- CreateTimer( 0.050, TimerProc, GetPlayerWeaponSlot(i, 4) );
- CS_DropWeapon( i, 4, false, true );
- }
- }
- }
- public Action:TimerProc( Handle:hTimer, any:weapon )
- {
- new spawn_point = -1, counter;
- new iEntityArray[ 64 ];
- while ((spawn_point = FindEntityByClassname(spawn_point, "info_player_terrorist")) != INVALID_ENT_REFERENCE)
- {
- iEntityArray[counter++] = spawn_point;
- }
- new Float:fSpawnPos[3];
- GetEntPropVector(iEntityArray[GetRandomInt(0, counter - 1)]), Prop_Send, "m_vecOrigin", fSpawnPos);
- TeleportEntity( weapon, fSpawnPos, NULL_VECTOR, NULL_VECTOR );
- return Plugin_Continue;
- }
Advertisement
Add Comment
Please, Sign In to add comment