Raised This Month: $32 Target: $400
 8% 

[l4d 2] melee limit enforcer


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GanjaStar
Senior Member
Join Date: Jun 2009
Old 12-26-2010 , 01:13   [l4d 2] melee limit enforcer
Reply With Quote #1

BIG thx to AtomicStryker for creation, and CanadaRox for the code template.

get it here

Last edited by GanjaStar; 01-12-2011 at 10:34.
GanjaStar is offline
CanadaRox
Member
Join Date: Dec 2009
Old 12-26-2010 , 16:22   Re: [l4d 2] melee limit enforcer
Reply With Quote #2

http://code.google.com/p/confogl/sou...dcb465fe7296ba

There is the Source to that module on Confogl. It wouldn't be very hard to change it so it applies to weapon_melee/secondary weapons instead of HR/primary.
CanadaRox is offline
GanjaStar
Senior Member
Join Date: Jun 2009
Old 12-27-2010 , 01:08   Re: [l4d 2] melee limit enforcer
Reply With Quote #3

thx for the heads up. was actually thinking of that.

however, your just like atomicstryker (thats a compliment)

yeah it might be easy for you, but not for code laymen like me.

ill give it a fair shot. and then if i fail, ill be back here begging


btw i say on some forum where you guys accept suggestions that people already requested this for confogl.
GanjaStar is offline
GanjaStar
Senior Member
Join Date: Jun 2009
Old 12-27-2010 , 02:17   Re: [l4d 2] melee limit enforcer
Reply With Quote #4

Code:
#pragma semicolon 1


#include <sourcemod>
#include <sdktools>


new Handle:WC_hLimitCount;


new WC_iLimitCount = 1;
new WC_iLastWeapon = -1;
new WC_iLastClient = -1;
new String:WC_sLastWeapon[64];


public WC_OnModuleStart()
{
	WC_hLimitCount = CreateConVar("limit_melee", "1", "Limits the maximum number of melee weapons at one time to this number", 0, true, 0.0, true, 4.0);
	HookConVarChange(WC_hLimitCount, WC_ConVarChange);
	
	WC_iLimitCount = GetConVarInt(WC_hLimitCount);
	
	HookEvent("player_use", WC_PlayerUse_Event);
	HookEvent("weapon_drop", WC_WeaponDrop_Event);
}


public WC_ConVarChange(Handle:convar, const String:oldValue[], const String:newValue[])
{
	WC_iLimitCount = GetConVarInt(WC_hLimitCount);
}


public Action:WC_WeaponDrop_Event(Handle:event, const String:name[], bool:dontBroadcast)
{
	WC_iLastWeapon = GetEventInt(event, "propid");
	WC_iLastClient = GetClientOfUserId(GetEventInt(event, "userid"));
	GetEventString(event, "item", WC_sLastWeapon, sizeof(WC_sLastWeapon));
	
}


public Action:WC_PlayerUse_Event(Handle:event, const String:name[], bool:dontBroadcast)
{
	if (!IsPluginEnabled()) return;

	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	
	new secondary = GetPlayerWeaponSlot(client, 0);
	if (!IsValidEdict(secondary)) return;
	
	decl String:secondary_name[64];
	GetEdictClassname(secondary, secondary_name, sizeof(secondary_name));
	
	if (StrEqual(secondary_name, "weapon_melee"))
	{
		if (MeleeWeaponCount(client) >= WC_iLimitCount)
		{
			if (IsValidEdict(secondary))
			{
				RemovePlayerItem(client, secondary);
				PrintToChat(client, "Maximum %d melee(s) is enforced.", WC_iLimitCount);
			}
			
			if (WC_iLastClient == client)
			{
				if (IsValidEdict(WC_iLastWeapon))
				{
					AcceptEntityInput(WC_iLastWeapon, "Kill");
					new flags = GetCommandFlags("give");
					SetCommandFlags("give", flags ^ FCVAR_CHEAT);
					
					decl String:sTemp[64];
					Format(sTemp, sizeof(sTemp), "give %s", WC_sLastWeapon);
					FakeClientCommand(client, sTemp);
					
					SetCommandFlags("give", flags);
				}
			}
		}
	}
	WC_iLastWeapon = -1;
	WC_iLastClient = -1;
	WC_sLastWeapon[0] = 0;
}

MeleeWeaponCount(client)
{
	new count = 0;
	for (new i = 0; i < 4; i++)
	{
		new index = GetSurvivorIndex(i);
		if (index != client && index != 0 && IsClientConnected(index))
		{
			new ent = GetPlayerWeaponSlot(index, 0);
			if (IsValidEdict(ent))
			{
				decl String:temp[64];
				GetEdictClassname(ent, temp, sizeof(temp));
				if (StrEqual(temp, "weapon_melee")) count++;
			}
		}
	}
	return count;
}
obviously i have no idea what im doing

Quote:
/groups/sourcemod/upload_tmp/texthiUQip.sp(46) : error 017: undefined symbol "IsPluginEnabled"
/groups/sourcemod/upload_tmp/texthiUQip.sp(93) : error 017: undefined symbol "GetSurvivorIndex"

2 Errors.
im assuming i can remove the line "ispluginenabled" since that probalby refers to the overall confogl package?

from "researching" the other error, i gahter i am missing parts of code for getsurvivorindex, but i can't find where in the confogl package that code is defined.

Last edited by GanjaStar; 12-27-2010 at 03:12.
GanjaStar is offline
GanjaStar
Senior Member
Join Date: Jun 2009
Old 12-27-2010 , 20:19   Re: [l4d 2] melee limit enforcer
Reply With Quote #5

any help is much appreciated, even if its just a bit of informatoin on where the parts of the code to fix the error could be found.
GanjaStar is offline
GanjaStar
Senior Member
Join Date: Jun 2009
Old 12-29-2010 , 02:59   Re: [l4d 2] melee limit enforcer
Reply With Quote #6

bumping this. im still trying to figure it out myself, but so far no luck.
GanjaStar is offline
GanjaStar
Senior Member
Join Date: Jun 2009
Old 12-31-2010 , 04:58   Re: [l4d 2] melee limit enforcer
Reply With Quote #7

last bump of the year
GanjaStar is offline
AtomicStryker
Veteran Member
Join Date: Apr 2009
Location: Teutonia!!
Old 01-02-2011 , 13:43   Re: [l4d 2] melee limit enforcer
Reply With Quote #8

I fixed the coding mistakes and some nitstuff, but i couldn't tell if its actually doing what its supposed to.

PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

new Handle:WC_hLimitCount;

new 
WC_iLimitCount 1;
new 
WC_iLastWeapon = -1;
new 
WC_iLastClient = -1;
new 
String:WC_sLastWeapon[64];

public 
WC_OnModuleStart()
{
    
WC_hLimitCount CreateConVar("l4d2_limit_melee""1""Limits the maximum number of melee weapons at one time to this number");
    
HookConVarChange(WC_hLimitCountWC_ConVarChange);
    
WC_iLimitCount GetConVarInt(WC_hLimitCount);
    
    
HookEvent("player_use"WC_PlayerUse_Event);
    
HookEvent("weapon_drop"WC_WeaponDrop_Event);
}

public 
WC_ConVarChange(Handle:convar, const String:oldValue[], const String:newValue[])
{
    
WC_iLimitCount GetConVarInt(WC_hLimitCount);
}

public 
Action:WC_WeaponDrop_Event(Handle:event, const String:name[], bool:dontBroadcast)
{
    
WC_iLastWeapon GetEventInt(event"propid");
    
WC_iLastClient GetClientOfUserId(GetEventInt(event"userid"));
    
GetEventString(event"item"WC_sLastWeaponsizeof(WC_sLastWeapon));
    
}

public 
Action:WC_PlayerUse_Event(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
    new 
secondary GetPlayerWeaponSlot(client0);
    if (!
IsValidEdict(secondary)) return;
    
    
decl String:secondary_name[64];
    
GetEdictClassname(secondarysecondary_namesizeof(secondary_name));
    
    if (
StrEqual(secondary_name"weapon_melee"))
    {
        if (
GetMeleeWeaponCount() >= WC_iLimitCount)
        {
            if (
IsValidEdict(secondary))
            {
                
RemovePlayerItem(clientsecondary);
                
PrintToChat(client"Maximum %d melee(s) is enforced."WC_iLimitCount);
            }
            
            if (
WC_iLastClient == client)
            {
                if (
IsValidEdict(WC_iLastWeapon))
                {
                    
AcceptEntityInput(WC_iLastWeapon"Kill");
                    
                    
decl String:sTemp[64];
                    
Format(sTempsizeof(sTemp), "give %s"WC_sLastWeapon);
                    
                    new 
flags GetCommandFlags("give");
                    
SetCommandFlags("give"flags FCVAR_CHEAT);
                    
FakeClientCommand(clientsTemp);
                    
SetCommandFlags("give"flags);
                }
            }
        }
    }
    
    
WC_iLastWeapon = -1;
    
WC_iLastClient = -1;
}

static 
GetMeleeWeaponCount()
{
    new 
count 0;
    new 
ent = -1;
    
decl String:temp[64];
    
    for (new 
0MaxClients+1i++)
    {
        if (
IsClientConnected(i)
        && 
GetClientTeam(i) == 2
        
&& IsPlayerAlive(i))
        {
            
ent GetPlayerWeaponSlot(i0);
            if (
IsValidEdict(ent))
            {
                
GetEdictClassname(enttempsizeof(temp));
                
                if (
StrEqual(temp"weapon_melee"))
                    
count++;
            }
        }
    }
    return 
count;

AtomicStryker is offline
GanjaStar
Senior Member
Join Date: Jun 2009
Old 01-03-2011 , 05:19   Re: [l4d 2] melee limit enforcer
Reply With Quote #9

much appreciated AtomicStryker!

will test it it out today.
GanjaStar is offline
GanjaStar
Senior Member
Join Date: Jun 2009
Old 01-03-2011 , 08:52   Re: [l4d 2] melee limit enforcer
Reply With Quote #10

it doenst work unfortunately, and theres no errors in the log.
GanjaStar is offline
Reply



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 09:49.


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