Raised This Month: $ Target: $400
 0% 

[MODIF] KnifeSyphon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DaRk56
Senior Member
Join Date: Jul 2009
Location: France
Old 05-09-2011 , 18:36   [MODIF] KnifeSyphon
Reply With Quote #1

Hello, I'm French I need help changing the plugins KnifeSyphon.

The plugins should be used only by the flag t (Custom6) and b flag (GENERIC).

This is for the vip

Code:
#pragma semicolon 1

#include <sourcemod>

#define PLUGIN_VERSION "1.8"

#define cGreen 0x04
#define cDefault 0x01

new spawned[MAXPLAYERS + 1];

new bool:isHooked = false;
new bool:Announce = false;

new Handle:cvarEnable;
new Handle:cvarAnnounce;
new Handle:cvarLife;

new String:gameFolder[32];

public Plugin:myinfo =
{
	name = "KnifeSyphon",
	author = "bl4nk",
	description = "Gives players a health boost when they make a knife kill.",
	version = PLUGIN_VERSION,
	url = "http://forums.alliedmods.net"
};

public OnPluginStart()
{
	LoadTranslations("knifesyphon.phrases");

	CreateConVar("sm_knifesyphon_version", PLUGIN_VERSION, "KnifeSyphon Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
	cvarEnable = CreateConVar("sm_knifesyphon_enable", "1", "Enables/Disables the KnifeSyphon plugin.", FCVAR_PLUGIN, true, 0.0, true, 1.0);
	cvarAnnounce = CreateConVar("sm_knifesyphon_announce", "1", "Enables/Disables the KnifeSyphon announcement at the beginning of the round.", FCVAR_PLUGIN, true, 0.0, true, 1.0);
	cvarLife = CreateConVar("sm_knifesyphon_life", "25", "Sets the amount of health to give to a player after they kill someone with a knife.", FCVAR_PLUGIN, true, 0.0, true, 100.0);

	GetGameFolderName(gameFolder, sizeof(gameFolder));
	CreateTimer(3.0, OnPluginStart_Delayed);
}

public Action:OnPluginStart_Delayed(Handle:timer)
{
	if (GetConVarInt(cvarEnable))
	{
		isHooked = true;
		HookEvent("player_death", event_PlayerDeath);
		HookEvent("player_spawn", event_PlayerSpawn);

		LogMessage("[KnifeSyphon] - Loaded");
	}

	if (GetConVarInt(cvarAnnounce))
	{
		Announce = true;
	}

	HookConVarChange(cvarEnable, CvarChange_Enable);
	HookConVarChange(cvarAnnounce, CvarChange_Announce);
}

public event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
decl String:weaponName[12];
GetEventString(event, "weapon", weaponName, sizeof(weaponName));

new victim = GetClientOfUserId(GetEventInt(event, "userid"));
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));

if (GetUserFlagBits(attacker) & (ADMFLAG_CUSTOM6 || ADMFLAG_GENERIC))
{
if (WeaponCheck(weaponName))
{
if (victim && attacker)
{
if (GetClientTeam(victim) != GetClientTeam(attacker))
{
new AddToHealth = GetConVarInt(cvarLife);
new attackerHealth = GetPlayerHealth(attacker) + AddToHealth;
SetPlayerHealth(attacker, attackerHealth);

decl String:victimName[32];
GetClientName(victim, victimName, sizeof(victimName));

PrintToChat(attacker, "%c[KS]%c %t", cGreen, cDefault, "Life Syphoned", AddToHealth, victimName);
}
}
}
}
}


public event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
	new playerId = GetClientOfUserId(GetEventInt(event, "userid"));
	if (!playerId || !GetClientTeam(playerId))
	{
		return;
	}

	if (!spawned[playerId])
	{
		spawned[playerId] = true;

		new AddToHealth = GetConVarInt(cvarLife);
		PrintToChat(playerId,"%c[KS]%c %t", cGreen, cDefault, "Announce", AddToHealth);
	}
}

public CvarChange_Enable(Handle:convar, const String:oldValue[], const String:newValue[])
{
	if (!GetConVarInt(cvarEnable))
	{
		if (isHooked)
		{
			isHooked = false;
			UnhookEvent("player_death", event_PlayerDeath);
			UnhookEvent("player_spawn", event_PlayerSpawn);
		}
	}
	else if (!isHooked)
	{
		isHooked = true;
		HookEvent("player_death", event_PlayerDeath);
		HookEvent("player_spawn", event_PlayerSpawn);
	}
}

public CvarChange_Announce(Handle:convar, const String:oldValue[], const String:newValue[])
{
	if (!GetConVarInt(cvarAnnounce))
	{
		if (Announce)
		{
			Announce = false;
			UnhookEvent("player_spawn", event_PlayerSpawn);
		}
	}
	else if (!Announce)
	{
		if (GetConVarInt(cvarEnable))
		{
			Announce = true;
			HookEvent("player_spawn", event_PlayerSpawn);
		}
	}
}

GetPlayerHealth(entity)
{
	return GetEntProp(entity, Prop_Send, "m_iHealth");
}

SetPlayerHealth(entity, amount)
{
	SetEntProp(entity, Prop_Send, "m_iHealth", amount);
}

WeaponCheck(const String:weapon[])
{
	if (strcmp(gameFolder, "cstrike") == 0) // Counter-Strike: Source
	{
		if(strcmp(weapon, "knife") == 0)
		{
			return 1;
		}
	}
	else if (strcmp(gameFolder, "dod") == 0) // Day of Defeat: Source
	{
		if(strcmp(weapon, "spade") == 0 || strcmp(weapon, "amerknife") == 0 || strcmp(weapon, "punch") == 0)
		{
			return 1;
		}
	}
	else if (strcmp(gameFolder, "hl2mp") == 0) // Half-Life 2: Deathmatch
	{
		if(strcmp(weapon, "stunstick") == 0 || strcmp(weapon, "crowbar") == 0)
		{
			return 1;
		}
	}
	else if (strcmp(gameFolder, "tf") == 0) // Team Fortress 2
	{
		if(strcmp(weapon, "bat") == 0 || strcmp(weapon, "bonesaw") == 0 || strcmp(weapon, "bottle") == 0 || strcmp(weapon, "fireaxe") == 0 || strcmp(weapon, "fists") == 0 || strcmp(weapon, "shovel") == 0 || strcmp(weapon, "wrench") == 0 || strcmp(weapon, "club") == 0 || strcmp(weapon, "axtinguisher") == 0 || strcmp(weapon, "bat_wood") == 0 || strcmp(weapon, "gloves") == 0 || strcmp(weapon, "ubersaw") == 0)
		{
			return 1;
		}
	}

	return 0;
}
but an error appears in the log yet the plugin works correctly, but will just remove this error.

Code:
L 05/09/2011 - 21:52:42: [SM] Native "GetUserFlagBits" reported: Client index 0 is invalid
L 05/09/2011 - 21:52:42: [SM] Displaying call stack trace for plugin "knifesyphon.smx":
L 05/09/2011 - 21:52:42: [SM]   [0]  Line 71, /home/groups/sourcemod/upload_tmp/php68VbgG.sp::event_PlayerDeath()
if you can help me, I should say that I am not develop the plugin has been modified by a friend
DaRk56 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 05-10-2011 , 02:42   Re: [MODIF] KnifeSyphon
Reply With Quote #2

Why you not request this feature in plugin own topic ? KnifeSyphon


*edit
Anyway, you can done this way.
Find line 75 - 76 (and this is original plugin source code)
Code:
    if (GetClientTeam(victim) != GetClientTeam(attacker))
    {
and edit
Code:
    if (GetClientTeam(victim) != GetClientTeam(attacker) && CheckCommandAccess(attacker, "knifesyphon_advantage", ADMFLAG_GENERIC))
    {
- Now default, admins who have adminflag "b" (generic) can use this. root admins "z" are automatically.
- players who have added one of admin groups where have override "knifesyphon_advantage" "allow"

*edit edit
You could also change announce line 98-99
Code:
	if (!spawned[playerId])
	{
to
Code:
	if (!spawned[playerId] && CheckCommandAccess(attacker, "knifesyphon_advantage", ADMFLAG_GENERIC))
	{
admin_groups.cfg
Code:
Groups
{
    /**
     * Allowed properties for a group:
     *
     *   "flags"           - Flag string.
     *   "immunity"        - Immunity level number, or a group name.
     *                         If the group name is a number, prepend it with an 
     *                         '@' symbol similar to admins_simple.ini.  Users 
     *                         will only inherit the level number if it's higher 
     *                         than their current value.
     */
    "Default"
    {
        "immunity"        "1"
    }
    
    "Full Admins"
    {
        /**
         * You can override commands and command groups here.
         * Specify a command name or group and either "allow" or "deny"
         * Examples:
         *         ":CSDM"            "allow"
         *        "csdm_enable"    "deny"
         */
         Overrides
         {
         }
        "flags"            "abcdefghiz"

        /* Largish number for lots of in-between values. */
        "immunity"        "99"
    }

    "vip"
    {
        Overrides
        {
            "knifesyphon_advantage"        "allow"
        }
    }
}
admins.cfg
Code:
/**
 * USE THIS SECTION TO DECLARE DETAILED ADMIN PROPERTIES.
 *
 * Each admin should have its own "Admin" section, followed by a name.
 * The name does not have to be unique.
 *
 * Available properties: (Anything else is filtered as custom)
 *      "auth"          - REQUIRED - Auth method to use.  Built-in methods are:
 *                        "steam"  - Steam based authentication
 *                        "name"   - Name based authentication
 *                        "ip"    - IP based authentication
 *                        Anything else is treated as custom.
 *                     Note: Only one auth method is allowed per entry.
 *
 *      "identity"      - REQUIRED - Identification string, for example, a steamid or name.
 *                     Note: Only one identity is allowed per entry.
 *
 *      "password"      - Optional password to require.
 *      "group"         - Adds one group to the user's group table.
 *      "flags"         - Adds one or more flags to the user's permissions.
 *        "immunity"        - Sets the user's immunity level (0 = no immunity).
 *                          Immunity can be any value.  Admins with higher 
 *                          values cannot be targetted.  See sm_immunity_mode 
 *                          to tweak the rules.  Default value is 0.
 *
 * Example:
    "BAILOPAN"
    {
        "auth"            "steam"
        "identity"        "STEAM_0:1:16"
        "flags"            "abcdef"
    }
 *
 */
Admins
{
    "Admin who ?"
    {
        "auth"            "steam"
        "identity"        "STEAM_0:1:13456"
        "flags"            "abcd"
    }

    "Some vip player"
    {
        "auth"            "steam"
        "identity"        "STEAM_0:1:987645"
        "group"            "vip"
    }
}
But don't add same person in both admin_simple.ini and admins.cfg !
admin_simple.ini
Code:
//
// READ THIS CAREFULLY! SEE BOTTOM FOR EXAMPLES
//
// For each admin, you need three settings:
//  "identity"        "permissions"        "password"
//
// For the Identity, you can use a SteamID or Name.  To use an IP address, prepend a ! character.
// For the Permissions, you can use a flag string and an optional password.
//
// PERMISSIONS:
//  Flag definitions are in "admin_levels.cfg"
//  You can combine flags into a string like this:
//  "abcdefgh"
//
//  If you want to specify a group instead of a flag, use an @ symbol.  Example:
//  "@Full Admins"
//
//    You can also specify immunity values.  Two examples:
//    "83:abcdefgh"            //Immunity is 83, flags are abcdefgh
//    "6:@Full Admins"        //Immunity is 6, group is "Full Admins"
//
//    Immunity values can be any number.  An admin cannot target an admin with 
//    a higher access value (see sm_immunity_mode to tweak the rules).  Default 
//  immunity value is 0 (no immunity).
//
// PASSWORDS:
//  Passwords are generally not needed unless you have name-based authentication.
//  In this case, admins must type this in their console:
//
//   setinfo "KEY" "PASSWORD"
//
//  Where KEY is the "PassInfoVar" setting in your core.cfg file, and "PASSWORD"
//  is their password.  With name based authentication, this must be done before
//  changing names or connecting.  Otherwise, SourceMod will automatically detect
//  the password being set.
//
////////////////////////////////
// Examples: (do not put // in front of real lines, as // means 'comment')
//
//   "STEAM_0:1:16"        "bce"                //generic, kick, unban for this steam ID, no immunity
//   "!127.0.0.1"        "99:z"                //all permissions for this ip, immunity value is 99
//   "BAILOPAN"            "abc"    "Gab3n"        //name BAILOPAN, password "Gab3n": gets reservation, generic, kick
//
////////////////////////////////
"STEAM_0:1:13456"        "10:abcd"
"STEAM_0:1:987645"        "@vip"
You want change that adminflag "b" to another else ?
Override
admin_overrides.cfg
Code:
Overrides
{
    /**
     * By default, commands are registered with three pieces of information:
     * 1)Command Name         (for example, "csdm_enable")
     * 2)Command Group Name    (for example, "CSDM")
     * 3)Command Level        (for example, "changemap")
     *
     * You can override the default flags assigned to individual commands or command groups in this way.
     * To override a group, use the "@" character before the name.  Example:
     * Examples:
     *        "@CSDM"            "b"                // Override the CSDM group to 'b' flag
     *         "csdm_enable"    "bgi"            // Override the csdm_enable command to 'bgi' flags
     *
     * Note that for overrides, order is important.  In the above example, csdm_enable overwrites
     * any setting that csdm_enable previously had.
     *
     * You can make a command completely public by using an empty flag string.
     */
    "knifesyphon_advantage"        "z"
}
- Change to admin flag "z" (root)

Last edited by Bacardi; 05-10-2011 at 03:19.
Bacardi is offline
DaRk56
Senior Member
Join Date: Jul 2009
Location: France
Old 05-10-2011 , 03:13   Re: [MODIF] KnifeSyphon
Reply With Quote #3

I is not creating our sourcebans vip group, since we ourselves develop a site that will handle the VIP and it's easier than managing the flag itself rather than the group.

It's just a bit too much for what I ask. ^^

I was just looking coriger error

Last edited by DaRk56; 05-10-2011 at 03:19.
DaRk56 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 12:02.


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