Raised This Month: $12 Target: $400
 3% 

[CS:GO] AddNormalSoundHook is getting as native error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 12-08-2019 , 08:10   [CS:GO] AddNormalSoundHook is getting as native error
Reply With Quote #1

Hey!

Today I tried to do something different...

PHP Code:
#pragma semicolon 1

#define DEBUG

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

char firesound[] = "sound/weapon/knife/knife_slash1.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_ak47"))
        {
            
SetWeaponFireSound();
        }
    }
}

void SetWeaponFireSound()
{
    
AddNormalSoundHook(SoundHook);
}

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

As u can see above, there is the code for changing the sound to others...

But when compiling I got this error:
http://prntscr.com/q7v0uv

What's the solution for it?

Thanks for helping and best regards,

SpirT.
__________________

Last edited by SpirT; 12-08-2019 at 08:11.
SpirT is offline
xerox8521
Senior Member
Join Date: Sep 2011
Old 12-08-2019 , 09:31   Re: [CS:GO] AddNormalSoundHook is getting as native error
Reply With Quote #2

Check the error its in the include file itself.
xerox8521 is offline
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 12-08-2019 , 13:31   Re: [CS:GO] AddNormalSoundHook is getting as native error
Reply With Quote #3

Quote:
Originally Posted by xerox8521 View Post
Check the error its in the include file itself.
I don't understand why. I always used #include <sktools> and never got this error... Tried to update all includes by downloading the last sourcemod version for linux and compiling it.

http://prntscr.com/q7yijv (the line of the error)

Best Regards,

SpirT.
__________________
SpirT is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 12-11-2019 , 22:24   Re: [CS:GO] AddNormalSoundHook is getting as native error
Reply With Quote #4

You should provide your actual code and not screenshots. Your paths look like you might be using includes or the compiler from 1.8, also.
Fyren is offline
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 12-14-2019 , 04:23   Re: [CS:GO] AddNormalSoundHook is getting as native error
Reply With Quote #5

Quote:
Originally Posted by Fyren View Post
You should provide your actual code and not screenshots. Your paths look like you might be using includes or the compiler from 1.8, also.
Yes, I am using sourcemod compiler 1.8 (spedit program compiler)... But I think that installing it again will just keep the same version for the compiler. But, like compiling with the spedit version for error correction and compiling with sourcemod last version for publish & use?

EDIT: Nevermind xD. How stoopid I am. I had it like that http://prntscr.com/qap3qe, but btw code problem is fixed but what about the question above? What should I do?

Best Regards,

SpirT
__________________

Last edited by SpirT; 12-14-2019 at 04:27.
SpirT is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 12-14-2019 , 15:55   Re: [CS:GO] AddNormalSoundHook is getting as native error
Reply With Quote #6

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.

Last edited by Fyren; 12-14-2019 at 15:55.
Fyren is offline
foxhound27
AlliedModders Donor
Join Date: Sep 2019
Location: Argentina
Old 12-16-2019 , 04:55   Re: [CS:GO] AddNormalSoundHook is getting as native error
Reply With Quote #7

Enjoy
Attached Files
File Type: sp Get Plugin or Get Source (CustomWeaponFireSounds.sp - 198 views - 1.5 KB)
foxhound27 is offline
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
foxhound27
AlliedModders Donor
Join Date: Sep 2019
Location: Argentina
Old 12-19-2019 , 09:54   Re: [CS:GO] AddNormalSoundHook is getting as native error
Reply With Quote #9

try with

PHP Code:
AddAmbientSoundHook(view_as<AmbientSHook>(OnNormalSoundPlayed));


public 
Action OnNormalSoundPlayed(int clients[64], int &numClientschar sample[PLATFORM_MAX_PATH], int &entityint &channelfloat &volumeint &levelint &pitchint &flags)
{    
    if (
entity <= MaxClients)
    {
        if(
StrContains(sample"weapons/knife/knife_hit") != -1)
        {
                
StopSound(entitySNDCHAN_STATICsample);
                
EmitSoundToAll("weapons/ak47/ak47_01.wav");            
                return 
Plugin_Stop;
        }
    }
    return 
Plugin_Continue;

foxhound27 is offline
Reply


Thread Tools
Display Modes

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 06:25.


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