Raised This Month: $68 Target: $400
 17% 

[L4D2]I have a new plugin idea/ request Help me plz/ all developers enter this post


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Darkwob
Member
Join Date: Oct 2018
Old 08-14-2019 , 16:39   [L4D2]I have a new plugin idea/ request Help me plz/ all developers enter this post
Reply With Quote #1

Hi, I saw this plugin on this site a long time ago. So this plugin automatically spawns melee weapons at a certain point in the safe room. I was thinking of a question like this, it's the same plug-in, but I just thought, why not for the guns, so the guns that are determined at a certain point in the safe room will spawn. Can you make such an Plugin?


PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

#define VERSION "2.0.7"

new Handle:g_hEnabled;
new 
Handle:g_hWeaponRandom;
new 
Handle:g_hWeaponRandomAmount;
new 
Handle:g_hWeaponBaseballBat;
new 
Handle:g_hWeaponCricketBat;
new 
Handle:g_hWeaponCrowbar;
new 
Handle:g_hWeaponElecGuitar;
new 
Handle:g_hWeaponFireAxe;
new 
Handle:g_hWeaponFryingPan;
new 
Handle:g_hWeaponGolfClub;
new 
Handle:g_hWeaponKnife;
new 
Handle:g_hWeaponKatana;
new 
Handle:g_hWeaponMachete;
new 
Handle:g_hWeaponRiotShield;
new 
Handle:g_hWeaponTonfa;

new 
bool:g_bSpawnedMelee;

new 
g_iMeleeClassCount 0;
new 
g_iMeleeRandomSpawn[20];
new 
g_iRound 2;

new 
String:g_sMeleeClass[16][32];

public 
Plugin:myinfo =
{
    
name "Melee In The Saferoom",
    
author "N3wton",
    
description "Spawns a selection of melee weapons in the saferoom, at the start of each round.",
    
version VERSION
};

public 
OnPluginStart()
{
    
decl String:GameName[12];
    
GetGameFolderName(GameNamesizeof(GameName));
    if( !
StrEqual(GameName"left4dead2") )
        
SetFailState"Melee In The Saferoom is only supported on left 4 dead 2." );
        
    
CreateConVar"l4d2_MITSR_Version",        VERSION"The version of Melee In The Saferoom"FCVAR_PLUGIN ); 
    
g_hEnabled                CreateConVar"l4d2_MITSR_Enabled",        "1""Should the plugin be enabled"FCVAR_PLUGIN ); 
    
g_hWeaponRandom            CreateConVar"l4d2_MITSR_Random",        "1""Spawn Random Weapons (1) or custom list (0)"FCVAR_PLUGIN ); 
    
g_hWeaponRandomAmount    CreateConVar"l4d2_MITSR_Amount",        "4""Number of weapons to spawn if l4d2_MITSR_Random is 1"FCVAR_PLUGIN ); 
    
g_hWeaponBaseballBat     CreateConVar"l4d2_MITSR_BaseballBat",    "1""Number of baseball bats to spawn (l4d2_MITSR_Random must be 0)"FCVAR_PLUGIN );
    
g_hWeaponCricketBat     CreateConVar"l4d2_MITSR_CricketBat",     "1""Number of cricket bats to spawn (l4d2_MITSR_Random must be 0)"FCVAR_PLUGIN );
    
g_hWeaponCrowbar         CreateConVar"l4d2_MITSR_Crowbar",     "1""Number of crowbars to spawn (l4d2_MITSR_Random must be 0)"FCVAR_PLUGIN );
    
g_hWeaponElecGuitar        CreateConVar"l4d2_MITSR_ElecGuitar",    "1""Number of electric guitars to spawn (l4d2_MITSR_Random must be 0)"FCVAR_PLUGIN );
    
g_hWeaponFireAxe            CreateConVar"l4d2_MITSR_FireAxe",        "1""Number of fireaxes to spawn (l4d2_MITSR_Random must be 0)"FCVAR_PLUGIN );
    
g_hWeaponFryingPan        CreateConVar"l4d2_MITSR_FryingPan",    "1""Number of frying pans to spawn (l4d2_MITSR_Random must be 0)"FCVAR_PLUGIN );
    
g_hWeaponGolfClub        CreateConVar"l4d2_MITSR_GolfClub",    "1""Number of golf clubs to spawn (l4d2_MITSR_Random must be 0)"FCVAR_PLUGIN );
    
g_hWeaponKnife            CreateConVar"l4d2_MITSR_Knife",        "1""Number of knifes to spawn (l4d2_MITSR_Random must be 0)"FCVAR_PLUGIN );
    
g_hWeaponKatana            CreateConVar"l4d2_MITSR_Katana",        "1""Number of katanas to spawn (l4d2_MITSR_Random must be 0)"FCVAR_PLUGIN );
    
g_hWeaponMachete            CreateConVar"l4d2_MITSR_Machete",        "1""Number of machetes to spawn (l4d2_MITSR_Random must be 0)"FCVAR_PLUGIN );
    
g_hWeaponRiotShield        CreateConVar"l4d2_MITSR_RiotShield",    "1""Number of riot shields to spawn (l4d2_MITSR_Random must be 0)"FCVAR_PLUGIN );
    
g_hWeaponTonfa            CreateConVar"l4d2_MITSR_Tonfa",        "1""Number of tonfas to spawn (l4d2_MITSR_Random must be 0)"FCVAR_PLUGIN );
    
AutoExecConfigtrue"[L4D2]MeleeInTheSaferoom" );
    
    
HookEvent"round_start"Event_RoundStart );
    
    
RegAdminCmd"sm_melee"Command_SMMeleeADMFLAG_KICK"Lists all melee weapons spawnable in current campaign" );
}

public 
Action:Command_SMMelee(clientargs)
{
    for( new 
0g_iMeleeClassCounti++ )
    {
        
PrintToChatclient"%d : %s"ig_sMeleeClass[i] );
    }
}

public 
OnMapStart()
{
    
PrecacheModel"models/weapons/melee/v_bat.mdl"true );
    
PrecacheModel"models/weapons/melee/v_cricket_bat.mdl"true );
    
PrecacheModel"models/weapons/melee/v_crowbar.mdl"true );
    
PrecacheModel"models/weapons/melee/v_electric_guitar.mdl"true );
    
PrecacheModel"models/weapons/melee/v_fireaxe.mdl"true );
    
PrecacheModel"models/weapons/melee/v_frying_pan.mdl"true );
    
PrecacheModel"models/weapons/melee/v_golfclub.mdl"true );
    
PrecacheModel"models/weapons/melee/v_katana.mdl"true );
    
PrecacheModel"models/weapons/melee/v_machete.mdl"true );
    
PrecacheModel"models/weapons/melee/v_tonfa.mdl"true );
    
    
PrecacheModel"models/weapons/melee/w_bat.mdl"true );
    
PrecacheModel"models/weapons/melee/w_cricket_bat.mdl"true );
    
PrecacheModel"models/weapons/melee/w_crowbar.mdl"true );
    
PrecacheModel"models/weapons/melee/w_electric_guitar.mdl"true );
    
PrecacheModel"models/weapons/melee/w_fireaxe.mdl"true );
    
PrecacheModel"models/weapons/melee/w_frying_pan.mdl"true );
    
PrecacheModel"models/weapons/melee/w_golfclub.mdl"true );
    
PrecacheModel"models/weapons/melee/w_katana.mdl"true );
    
PrecacheModel"models/weapons/melee/w_machete.mdl"true );
    
PrecacheModel"models/weapons/melee/w_tonfa.mdl"true );
    
    
PrecacheGeneric"scripts/melee/baseball_bat.txt"true );
    
PrecacheGeneric"scripts/melee/cricket_bat.txt"true );
    
PrecacheGeneric"scripts/melee/crowbar.txt"true );
    
PrecacheGeneric"scripts/melee/electric_guitar.txt"true );
    
PrecacheGeneric"scripts/melee/fireaxe.txt"true );
    
PrecacheGeneric"scripts/melee/frying_pan.txt"true );
    
PrecacheGeneric"scripts/melee/golfclub.txt"true );
    
PrecacheGeneric"scripts/melee/katana.txt"true );
    
PrecacheGeneric"scripts/melee/machete.txt"true );
    
PrecacheGeneric"scripts/melee/tonfa.txt"true );
}

public 
Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    if( !
GetConVarBoolg_hEnabled ) ) return Plugin_Continue;
    
    
g_bSpawnedMelee false;
    
    if( 
g_iRound == && IsVersus() ) g_iRound 1; else g_iRound 2;
    
    
GetMeleeClasses();
    
    
CreateTimer1.0Timer_SpawnMelee );
    
    return 
Plugin_Continue;
}

public 
Action:Timer_SpawnMeleeHandle:timer )
{
    new 
client GetInGameClient();

    if( 
client != && !g_bSpawnedMelee )
    {
        
decl Float:SpawnPosition[3], Float:SpawnAngle[3];
        
GetClientAbsOriginclientSpawnPosition );
        
SpawnPosition[2] += 20SpawnAngle[0] = 90.0;
        
        if( 
GetConVarBoolg_hWeaponRandom ) )
        {
            new 
0;
            while( 
GetConVarIntg_hWeaponRandomAmount ) )
            {
                new 
RandomMelee GetRandomInt0g_iMeleeClassCount-);
                if( 
IsVersus() && g_iRound == RandomMelee g_iMeleeRandomSpawn[i]; 
                
SpawnMeleeg_sMeleeClass[RandomMelee], SpawnPositionSpawnAngle );
                if( 
IsVersus() && g_iRound == g_iMeleeRandomSpawn[i] = RandomMelee;
                
i++;
            }
            
g_bSpawnedMelee true;
        }
        else
        {
            
SpawnCustomListSpawnPositionSpawnAngle );
            
g_bSpawnedMelee true;
        }
    }
    else
    {
        if( !
g_bSpawnedMelee CreateTimer1.0Timer_SpawnMelee );
    }
}

stock SpawnCustomListFloat:Position[3], Float:Angle[3] )
{
    
decl String:ScriptName[32];
    
    
//Spawn Basseball Bats
    
if( GetConVarIntg_hWeaponBaseballBat ) > )
    {
        for( new 
0GetConVarIntg_hWeaponBaseballBat ); i++ )
        {
            
GetScriptName"baseball_bat"ScriptName );
            
SpawnMeleeScriptNamePositionAngle );
        }
    }
    
    
//Spawn Cricket Bats
    
if( GetConVarIntg_hWeaponCricketBat ) > )
    {
        for( new 
0GetConVarIntg_hWeaponCricketBat ); i++ )
        {
            
GetScriptName"cricket_bat"ScriptName );
            
SpawnMeleeScriptNamePositionAngle );
        }
    }
    
    
//Spawn Crowbars
    
if( GetConVarIntg_hWeaponCrowbar ) > )
    {
        for( new 
0GetConVarIntg_hWeaponCrowbar ); i++ )
        {
            
GetScriptName"crowbar"ScriptName );
            
SpawnMeleeScriptNamePositionAngle );
        }
    }
    
    
//Spawn Electric Guitars
    
if( GetConVarIntg_hWeaponElecGuitar ) > )
    {
        for( new 
0GetConVarIntg_hWeaponElecGuitar ); i++ )
        {
            
GetScriptName"electric_guitar"ScriptName );
            
SpawnMeleeScriptNamePositionAngle );
        }
    }
    
    
//Spawn Fireaxes
    
if( GetConVarIntg_hWeaponFireAxe ) > )
    {
        for( new 
0GetConVarIntg_hWeaponFireAxe ); i++ )
        {
            
GetScriptName"fireaxe"ScriptName );
            
SpawnMeleeScriptNamePositionAngle );
        }
    }
    
    
//Spawn Frying Pans
    
if( GetConVarIntg_hWeaponFryingPan ) > )
    {
        for( new 
0GetConVarIntg_hWeaponFryingPan ); i++ )
        {
            
GetScriptName"frying_pan"ScriptName );
            
SpawnMeleeScriptNamePositionAngle );
        }
    }
    
    
//Spawn Golfclubs
    
if( GetConVarIntg_hWeaponGolfClub ) > )
    {
        for( new 
0GetConVarIntg_hWeaponGolfClub ); i++ )
        {
            
GetScriptName"golfclub"ScriptName );
            
SpawnMeleeScriptNamePositionAngle );
        }
    }
    
    
//Spawn Knifes
    
if( GetConVarIntg_hWeaponKnife ) > )
    {
        for( new 
0GetConVarIntg_hWeaponKnife ); i++ )
        {
            
GetScriptName"hunting_knife"ScriptName );
            
SpawnMeleeScriptNamePositionAngle );
        }
    }
    
    
//Spawn Katanas
    
if( GetConVarIntg_hWeaponKatana ) > )
    {
        for( new 
0GetConVarIntg_hWeaponKatana ); i++ )
        {
            
GetScriptName"katana"ScriptName );
            
SpawnMeleeScriptNamePositionAngle );
        }
    }
    
    
//Spawn Machetes
    
if( GetConVarIntg_hWeaponMachete ) > )
    {
        for( new 
0GetConVarIntg_hWeaponMachete ); i++ )
        {
            
GetScriptName"machete"ScriptName );
            
SpawnMeleeScriptNamePositionAngle );
        }
    }
    
    
//Spawn RiotShields
    
if( GetConVarIntg_hWeaponRiotShield ) > )
    {
        for( new 
0GetConVarIntg_hWeaponRiotShield ); i++ )
        {
            
GetScriptName"riotshield"ScriptName );
            
SpawnMeleeScriptNamePositionAngle );
        }
    }
    
    
//Spawn Tonfas
    
if( GetConVarIntg_hWeaponTonfa ) > )
    {
        for( new 
0GetConVarIntg_hWeaponTonfa ); i++ )
        {
            
GetScriptName"tonfa"ScriptName );
            
SpawnMeleeScriptNamePositionAngle );
        }
    }
}

stock SpawnMelee( const String:Class[32], Float:Position[3], Float:Angle[3] )
{
    
decl Float:SpawnPosition[3], Float:SpawnAngle[3];
    
SpawnPosition Position;
    
SpawnAngle Angle;
    
    
SpawnPosition[0] += ( -10 GetRandomInt020 ) );
    
SpawnPosition[1] += ( -10 GetRandomInt020 ) );
    
SpawnPosition[2] += GetRandomInt010 );
    
SpawnAngle[1] = GetRandomFloat0.0360.0 );

    new 
MeleeSpawn CreateEntityByName"weapon_melee" );
    
DispatchKeyValueMeleeSpawn"melee_script_name", Class );
    
DispatchSpawnMeleeSpawn );
    
TeleportEntity(MeleeSpawnSpawnPositionSpawnAngleNULL_VECTOR );
}

stock GetMeleeClasses()
{
    new 
MeleeStringTable FindStringTable"MeleeWeapons" );
    
g_iMeleeClassCount GetStringTableNumStringsMeleeStringTable );
    
    for( new 
0g_iMeleeClassCounti++ )
    {
        
ReadStringTableMeleeStringTableig_sMeleeClass[i], 32 );
    }    
}

stock GetScriptName( const String:Class[32], String:ScriptName[32] )
{
    for( new 
0g_iMeleeClassCounti++ )
    {
        if( 
StrContainsg_sMeleeClass[i], Class, false ) == )
        {
            
FormatScriptName32"%s"g_sMeleeClass[i] );
            return;
        }
    }
    
FormatScriptName32"%s"g_sMeleeClass[0] );    
}

stock GetInGameClient()
{
    for( new 
1<= GetClientCounttrue ); x++ )
    {
        if( 
IsClientInGame) && GetClientTeam) == )
        {
            return 
x;
        }
    }
    return 
0;
}

stock bool:IsVersus()
{
    new 
String:GameMode[32];
    
GetConVarStringFindConVar"mp_gamemode" ), GameMode32 );
    if( 
StrContainsGameMode"versus"false ) != -) return true;
    return 
false;

Original plugin

Last edited by Darkwob; 08-14-2019 at 16:41.
Darkwob is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:57.


Powered by vBulletin®
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Theme made by Freecode