This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Solved Removing spread in CS:S


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
godzcsgo
Senior Member
Join Date: Jul 2017
Old 05-08-2024 , 15:53   Removing spread in CS:S
Reply With Quote #1

Hello, as stated in the title. I am trying to remove spread for all weapons on my cs:s server.

I have seen other cs:s servers do this. So I am wondering how I can also do this?

I looked around the forums, and found this code and tried it:
Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

#pragma newdecls required

public Plugin myinfo = 
{
	name = "No Spread",
	author = "godzcsgo",
	description = "Removes spread from all weapons.",
	version = "1.0.0",
	url = ""
};

public Action OnPlayerRunCmd(int iClient, int &iButtons, int &iImpulse, float fVel[3], float fAngle[3], int &iWeapon, int &iSubType, int &iCmdnNum, int &iTickCount, int &iSeed)
{
    if (IsPlayerAlive(iClient)) {
        iSeed = 0;
        return Plugin_Changed;
    }

    return Plugin_Continue;
}
But I am not sure it works? Can anyone confirm this is the right way to do it.

Thanks.

Edit:

Found something about modifying the m_fAccuracyPenalty, I did this but there still seems to be spread.

Updated code:
Code:
public void OnPluginStart() {
    for (int client = 1; client <= MaxClients; client++) {
        if (IsClientInGame(client)) {
            if (IsPlayerAlive(client)) {
                SDKHook(client, SDKHook_PreThink, NoSpread);
                SDKHook(client, SDKHook_PreThinkPost, NoSpread);
                SDKHook(client, SDKHook_PostThink, NoSpread);
                SDKHook(client, SDKHook_PostThinkPost, NoSpread);
            }
        }
    }
}

public Action NoSpread(int client) {
    if (client <= 0 || client > MaxClients || !IsClientInGame(client) || GetClientTeam(client) < 2 || !IsPlayerAlive(client)) {
        return Plugin_Continue;
    }

    int buttons = GetClientButtons(client);
    float game_time = GetGameTime();

    if (buttons & IN_ATTACK) {
        int active_weapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
        if (!IsValidEdict(active_weapon) || !IsValidEntity(active_weapon) || (active_weapon == -1)) return Plugin_Continue;

        if (game_time < GetEntPropFloat(active_weapon, Prop_Send, "m_flNextPrimaryAttack")) return Plugin_Continue;
        if (game_time < GetEntPropFloat(client, Prop_Send, "m_flNextAttack")) return Plugin_Continue;

        int clip_ammo = GetEntProp(active_weapon, Prop_Send, "m_iClip1");
        if (!clip_ammo) return Plugin_Continue;

        float spread = 0.0;
        SetEntPropFloat(active_weapon, Prop_Send, "m_fAccuracyPenalty", spread);

        float new_spread = GetEntPropFloat(active_weapon, Prop_Send, "m_fAccuracyPenalty");
        PrintToServer("Spread: %f", new_spread);

        return Plugin_Changed;
    }

    return Plugin_Continue;
}

Last edited by godzcsgo; 05-17-2024 at 07:12. Reason: Added code and more info
godzcsgo is offline
 



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 00:08.


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