View Single Post
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 12-17-2019 , 16:18   Re: [CS:GO] AddNormalSoundHook is getting as native error
Reply With Quote #8

Quote:
Originally Posted by Fyren View Post
Older verions of the compiler had issues where it reported errors as happening on the next line, which could end up reporting the error as being in the wrong file if the next line had an #include or the last line inside an include. Maybe that's what happened with your code since the next non-blank, non-comment line is an include.

The 1.8 compiler is probably years old at this point, so it's missing fixes like that. I have no idea about pointing SPEdit at a newer version.
So, should I start by download the new sourcemod version and use that compiler that comes with it?

Or what if I change all the main sourcemod includes and the spedit compiler on the %appdata&? What do u recommend.

Another thing. I did the same thing but just tested out this version:
PHP Code:
#pragma semicolon 1

#define DEBUG

#define PLUGIN_AUTHOR "SpirT"
#define PLUGIN_VERSION "1.0"

char firesound[] = "weapons/ak47/ak47_01.wav";

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

#pragma newdecls required

public Plugin myinfo 
{
    
name "[SpirT] Custom Weapon Fire Sounds",
    
author PLUGIN_AUTHOR,
    
description "This plugin allows a client to change his weapon fire sound WARNING: For client, it would play the sound that he choosed and the client sided sound, because that cannot be changed (i think)...",
    
version PLUGIN_VERSION,
    
url "https://paypal.me/spirtcfg"
};

public 
void OnPluginStart()
{
    
HookEvent("weapon_fire"OnWeaponFire);
}

public 
Action OnWeaponFire(Event eventchar[] namebool dontBroadCast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    
    if(
CheckCommandAccess(client"weapon_vip_firesound"ADMFLAG_ROOT))
    {
        
char weapon[64];
        
GetClientWeapon(clientweaponsizeof(weapon));
        if(
StrEqual(weapon"weapon_knife_ct") && StrEqual(weapon"weapon_knife_t"))
        {
            
SetWeaponFireSound();
        }
    }
}

void SetWeaponFireSound()
{
    
AddNormalSoundHook(SoundHookAk);
}

public 
Action SoundHookAk(int clients[64], int &numClientschar sound[PLATFORM_MAX_PATH], int &entityint &channelfloat &volumeint &levelint &pitchint &flags)
{
    if(
StrContains(sound"weapons/knife/knife_hit"))
    {
        
EmitSoundToAll(firesoundentitychannellevelflagsvolumepitch);
    }

And it didn't work. It didn't play the sound when I hit something, what should I do?

Best Regards,

SpirT.
__________________
SpirT is offline