Raised This Month: $ Target: $400
 0% 

Plugin to force snd_restart at map start.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KALASH NICOLE
Member
Join Date: Feb 2016
Old 07-06-2017 , 07:22   Plugin to force snd_restart at map start.
Reply With Quote #1

Hi, in need a plugin able to force snd_restart on each players at a each map start. the reason is i'm using custom maps containing custom sounds, and very otfen these custom sounds doesn't load and the players can't hear them if they don't manually type snd_restart in their console.

so i would like an automated solution via a plugin.
KALASH NICOLE is offline
WatchDogs
Senior Member
Join Date: Oct 2015
Location: Iran
Old 07-06-2017 , 09:24   Re: Plugin to force snd_restart at map start.
Reply With Quote #2

Hi,

You can do it with a simple code (If client command snd_restart is not in cannot execute by server) in two ways:

1. On client joined the game at all:
PHP Code:
// Command to run when client joined the game
#define    SND_Command    "snd_restart"

#include <sourcemod>

#pragma newdecls required

public void OnClientPutInServer(int client)
{
    if(
IsClientConnected(client) && !IsFakeClient(client))
    {
        
ClientCommand(clientSND_Command);
    }

2. Or using timer on map start:

PHP Code:
// Command to run on map start
#define    SND_Command    "snd_restart"

// When map started after this time the command will execute
#define Timer_Interval 10


#include <sourcemod>

#pragma newdecls required

public void OnConfigsExecuted()
{
    
CreateTimer(float(Timer_Interval), PlaySoundToAll_TIMER_FLAG_NO_MAPCHANGE);
}

public 
Action PlaySoundToAll(Handle timer)
{
    for (
int i 1<= MaxClientsi++)
    {
        if(
IsClientInGame(i) && !IsFakeClient(i))
        {
            
ClientCommand(iSND_Command);
        }
    }

EDIT: Oh sorry about my terrible mistake ! Corrected.

Last edited by WatchDogs; 07-06-2017 at 17:08.
WatchDogs is offline
KALASH NICOLE
Member
Join Date: Feb 2016
Old 07-06-2017 , 14:34   Re: Plugin to force snd_restart at map start.
Reply With Quote #3

i tried to compile the second code :

i got this error :

PHP Code:
//SourceMod Batch Compiler
// by the SourceMod Dev Team


//// soundrestart.sp
//
// C:\Program Files (x86)\Steam\SteamApps\common\insurgency2\insurgency\addons\s
ourcemod\scripting\soundrestart.sp(23) : error 017undefined symbol "client"
//
// 1 Error.
//
// Compilation Time: 0,12 sec
// ----------------------------------------

Press enter to exit ... 
KALASH NICOLE is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 07-06-2017 , 15:02   Re: Plugin to force snd_restart at map start.
Reply With Quote #4

In the first example, change:

Code:
public void OnClientPutInServer(int client)
to
Code:
public void OnClientPutInServer(int i)
and

Code:
        ClientCommand(client, SND_Command);
to
Code:
        ClientCommand(i, SND_Command);

In the second example, change:

Code:
            ClientCommand(client, SND_Command);
to
Code:
            ClientCommand(i, SND_Command);

It is because of a mix of what variables it has and what variables it uses.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].

Last edited by DarkDeviL; 07-06-2017 at 15:02.
DarkDeviL is offline
KALASH NICOLE
Member
Join Date: Feb 2016
Old 07-06-2017 , 16:44   Re: Plugin to force snd_restart at map start.
Reply With Quote #5

i tested both plugins with the changes, none of them seems to execute snd_restart to players at map start or to someone who just joined the server.

Last edited by KALASH NICOLE; 07-06-2017 at 16:53.
KALASH NICOLE is offline
WatchDogs
Senior Member
Join Date: Oct 2015
Location: Iran
Old 07-06-2017 , 17:12   Re: Plugin to force snd_restart at map start.
Reply With Quote #6

Sorry for my terrible mistakes ! Corrected.

Check your console when you connect. Maybe it's giving "FCVAR_SERVER_CAN_EXECUTE prevented server running command" error because some commands cannot execute from server to client.

Also if your sound file is specified you can use EmitSoundClient.

Last edited by WatchDogs; 07-06-2017 at 17:12.
WatchDogs is offline
KALASH NICOLE
Member
Join Date: Feb 2016
Old 07-06-2017 , 17:25   Re: Plugin to force snd_restart at map start.
Reply With Quote #7

yes now i see the : "FCVAR_SERVER_CAN_EXECUTE prevented server running command: snd_restart"

i tried with FakeClientCommand(i, SND_Command);

but it says unknown command : snd_restart

so there is no way to execute this command ?

thanks you anyway for the help Watchdogs.

Last edited by KALASH NICOLE; 07-06-2017 at 17:35.
KALASH NICOLE is offline
WatchDogs
Senior Member
Join Date: Oct 2015
Location: Iran
Old 07-06-2017 , 17:38   Re: Plugin to force snd_restart at map start.
Reply With Quote #8

Fake command is not usable here.


What sound file do you want to play ? Is it in client's sound folder or no ? (I think it should be )


EDIT: We can do it easily if we know the sound file path.
EDIT2: Also I recommend testing with FakeClientCommandEx too. ;)

Last edited by WatchDogs; 07-06-2017 at 18:22.
WatchDogs is offline
KALASH NICOLE
Member
Join Date: Feb 2016
Old 07-06-2017 , 18:28   Re: Plugin to force snd_restart at map start.
Reply With Quote #9

FakeClientCommandEx still give me unknown command : snd_restart

the sound files (.wav) i want to play are packed into a custom map (.bsp) when i open the .bsp with VIDE the sounds use this path : /sound/custom

Last edited by KALASH NICOLE; 07-06-2017 at 18:41.
KALASH NICOLE is offline
WatchDogs
Senior Member
Join Date: Oct 2015
Location: Iran
Old 07-06-2017 , 18:36   Re: Plugin to force snd_restart at map start.
Reply With Quote #10

Aaaa, Is it a game sound ? (Game sounds are found in a game's scripts/game_sound.txt or other files referenced from it)

Also you can test FakeClientCommandEx .

Last edited by WatchDogs; 07-06-2017 at 18:37.
WatchDogs 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 22:59.


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