AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [CSGO] Change dmg with cvar (https://forums.alliedmods.net/showthread.php?t=338932)

WhiteAngel4 08-04-2022 06:34

[CSGO] Change dmg with cvar
 
Hi!

I would like to ask some help about this.
How could I equal the static damage value to cvar variable?

PHP Code:

public Action Event_OnTakeDamage(int victimint &attackerint &inflictorfloat &damageint &damagetype

    if (!
attacker || attacker MaxClients || !IsClientInGame(attacker)) 
    { 
        return 
Plugin_Continue
    } 
    
char sWeapon[32]; 
    
GetClientWeapon(attackersWeaponsizeof(sWeapon)); 
    if(
StrContains(sWeapon"fists"false) != -1
     {
        if (
g_iClientFistPhase[attacker] % == 0)     damage 40.0;
        else                                         
damage 40.0;
        
        return 
Plugin_Changed
    } 
    return 
Plugin_Continue


Thank you for advices! :)

Script from https://forums.alliedmods.net/showth...25#post2730825

Actually what I'd like to do is merge these plugins and add a cvar for change fistsdmg:
Change fists dmg
csgo_meleeweapons

oqyh 08-05-2022 16:21

Re: [CSGO] Change dmg with cvar
 
1 Attachment(s)
Give us your try at least

here but not tested
Code:

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

#define CFG_NAME "fist_damage"

ConVar g_forcegivefist;
ConVar g_damage;

new        Handle:g_removebuyzone = INVALID_HANDLE;

char CfgFile[PLATFORM_MAX_PATH];
       
public Plugin:myinfo =
{
        name = "fist_damage",
        author = "Gold_KingZ",
        description = "Spawn With Fist + Modify Damage",
        version = "1.0.0",
        url = "https://steamcommunity.com/id/oQYh"
}

public OnPluginStart()
{
        Format(CfgFile, sizeof(CfgFile), "sourcemod/%s.cfg", CFG_NAME);
       
        g_forcegivefist = CreateConVar( "sm_force_give_fist", "1", "Spawn With Fist || 1= Yes || 0= No", _, true, 0.0, true, 1.0);
        g_damage = CreateConVar( "sm_fist_damage", "300", "Damage Fist Deal  || 0= No Damage || 1= Lowest Damage || 300= 1 Hit");
        g_removebuyzone = CreateConVar( "sm_disable_buyzone", "1", "Disable Buy Zone || 1= Yes || 0= No", _, true, 0.0, true, 1.0);

        for (int i = 1; i < MaxClients; ++i)
                {
                        if (IsClientInGame(i))
                        {
                                SDKHook(i, SDKHook_OnTakeDamage, OneHitDamage);
                        }
                }
               
        HookEvent( "player_spawn",        Event_PlayerSpawn);
        LoadCfg();
}

void LoadCfg()
{
        AutoExecConfig(true, CFG_NAME);
}

public OnClientPutInServer(client)
{
        SDKHook(client, SDKHook_PostThinkPost, Hook_PostThinkPost);
        SDKHook(client, SDKHook_OnTakeDamage, OneHitDamage);
}


public void Hook_PostThinkPost(int entity)
{
        if( !GetConVarBool( g_removebuyzone ) )
                return;
       
        SetEntProp(entity, Prop_Send, "m_bInBuyZone", 0);
}

public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
    int client = GetClientOfUserId(GetEventInt(event, "userid"));
       
    CreateTimer(1.6, Timer_Delay, GetClientUserId(client));


stock void StripWeapons(int client)
{
        int index;
        int weapon;
       
        while((weapon = GetNextWeapon(client, index)) != -1)
        {
                RemovePlayerItem(client, weapon);
                AcceptEntityInput(weapon, "Kill");
        }
}

stock int GetNextWeapon(int client, int &weaponIndex)
{
        static int weaponsOffset = -1;
        if (weaponsOffset == -1)
                weaponsOffset = FindDataMapInfo(client, "m_hMyWeapons");
       
        int offset = weaponsOffset + (weaponIndex * 4);
       
        int weapon;
        while (weaponIndex < 48)
        {
                weaponIndex++;
               
                weapon = GetEntDataEnt2(client, offset);
               
                if (IsValidEdict(weapon))
                        return weapon;
               
                offset += 4;
        }
       
        return -1;
}

public Action Timer_Delay(Handle timer, int id)
{
        if( GetConVarBool( g_forcegivefist ) )
        {
                int client = GetClientOfUserId(id);
                if(!client || !IsClientInGame(client) || !IsPlayerAlive(client) || (4 < 4 && 4 != GetClientTeam(client)))
                        return Plugin_Continue;
                       
                StripWeapons(client);
                int iMelee;
                iMelee = GivePlayerItem(client, "weapon_fists");
                EquipPlayerWeapon(client, iMelee);
               
                return Plugin_Continue;
                }
        return Plugin_Handled;
}

public Action OneHitDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
{
    if (!attacker || attacker > MaxClients || !IsClientInGame(attacker))
    {
        return Plugin_Continue;
    }
    char sWeapon[32];
    GetClientWeapon(attacker, sWeapon, sizeof(sWeapon));
    if(StrContains(sWeapon, "fists", false) != -1)
    {
        damage = g_damage.FloatValue;
               
        return Plugin_Changed;
    }
    return Plugin_Continue;
}



All times are GMT -4. The time now is 08:48.

Powered by vBulletin®
Copyright ©2000 - 2022, vBulletin Solutions, Inc.