Raised This Month: $404 Target: $400
 101% 

plugin to emit sound every X seconds


Post New Thread Reply   
 
Thread Tools Display Modes
vegeta1241
Member
Join Date: Apr 2017
Old 10-08-2018 , 17:56   Re: plugin to emit sound every X seconds
Reply With Quote #11

i change it and its not downloading
vegeta1241 is offline
vegeta1241
Member
Join Date: Apr 2017
Old 10-08-2018 , 17:56   Re: plugin to emit sound every X seconds
Reply With Quote #12

maybe we need this : AddFileToDownloadsTable
vegeta1241 is offline
dustinandband
Senior Member
Join Date: May 2015
Old 10-08-2018 , 18:48   Re: plugin to emit sound every X seconds
Reply With Quote #13

Quote:
Originally Posted by Crasher_3637 View Post
PHP Code:
public void OnMapStart()
{
     
CreateTimer(1.0tTimerRandomSound_TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT); // Start a timer on every map start that ends when map ends.

Timer callbacks don't get called when servers are in hibernation mode.

For example, the plugin below won't execute the timer callback on map start (when empty) without setting these AFK cvars:
Code:
sm_cvar director_afk_timeout 99999
sm_cvar sb_all_bot_game 1
sm_cvar allow_all_bot_survivor_team 1
PHP Code:
#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

int g_tTimerCount;
char g_sDebugLog[PLATFORM_MAX_PATH];

public 
void OnPluginStart()
{
    
BuildPath(Path_SMg_sDebugLogsizeof(g_sDebugLog), "logs/TimerTest.log");
}
public 
void OnMapStart()
{
    
g_tTimerCount 0;
    
CreateTimer(1.0tTimerTest_TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT); // Start a timer on every map start that ends when map ends.
}

public 
Action tTimerTest(Handle timer)
{
    
g_tTimerCount++;
    
LogToFile(g_sDebugLog"Timer Callback executed. Number of times executed: '%i'"g_tTimerCount);


Edit: Turns out even when you connect directly to an empty server (connect ip:port) it launches a new map anyway so nvm about the above ^

Last edited by dustinandband; 10-09-2018 at 13:44.
dustinandband is offline
vegeta1241
Member
Join Date: Apr 2017
Old 10-09-2018 , 07:11   Re: plugin to emit sound every X seconds
Reply With Quote #14

the plugin is working, timer also. but the files are not downloading
vegeta1241 is offline
vegeta1241
Member
Join Date: Apr 2017
Old 10-09-2018 , 09:54   Re: plugin to emit sound every X seconds
Reply With Quote #15

i have this error
Code:
[Sound] S_StartSound(): Failed to load sound 'random\sound1.mp3'. File is missing from disk or is invalid.
Code:
[Sound] S_StartSound(): Failed to load sound 'random\sound2.mp3'. File is missing from disk or is invalid.
Files copy in mirror server OK
But Files not present in my sound folders because not downloading on server

my script :

Code:
#include <sourcemod> 
#include <sdktools> 

char g_sSounds[][] = 
{
    "random/sound1.mp3",
    "random/sound2.mp3"
}

public void OnMapStart() 
{ 
    for(int i = 0; i < sizeof(g_sSounds); i++)
        PrecacheSound(g_sSounds[i], true); // Precache sound file... 
    CreateTimer(60.0, tTimerRandomSound, _, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT); // Start a timer on every map start that ends when map ends. 
} 

public Action tTimerRandomSound(Handle timer) 
{ 
    // void EmitSoundToAll(const char[] sample, int entity, int channel, int level, int flags, float volume, int pitch, int speakerentity, const float origin[3], const float dir[3], bool updatePos, float soundtime) 
    int random = GetRandomInt(0, sizeof(g_sSounds)-1);
    EmitSoundToAll(g_sSounds[random]); 
}

Last edited by vegeta1241; 10-09-2018 at 09:56.
vegeta1241 is offline
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 10-09-2018 , 11:42   Re: plugin to emit sound every X seconds
Reply With Quote #16

Since we're here in scripting section of the forum. And you where on the right way with 'AddFileToDownloadsTable' why not try yourself? Just take a look at a similar plugin which use this function as an example.
You're very welcome to come back with your first try. We'll help you finish this yourself!

Learning by doing - you'll never learn when you don't try
__________________
free software
coding

Last edited by shanapu; 10-09-2018 at 11:44.
shanapu is offline
vegeta1241
Member
Join Date: Apr 2017
Old 10-09-2018 , 12:28   Re: plugin to emit sound every X seconds
Reply With Quote #17

I try it with a simular plugin but i have errors

Last edited by vegeta1241; 10-09-2018 at 12:28.
vegeta1241 is offline
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 10-09-2018 , 13:20   Re: plugin to emit sound every X seconds
Reply With Quote #18

when you don't tell us your error, we can't help.
__________________
free software
coding
shanapu is offline
dustinandband
Senior Member
Join Date: May 2015
Old 10-09-2018 , 13:42   Re: plugin to emit sound every X seconds
Reply With Quote #19

You can follow this guide and view his source code ("Dedicated Server Files") to get an idea of how he forces downloads.
https://steamcommunity.com/sharedfil...?id=1365081668

Not sure if in your case it would be necessary to have a separate web server for dispatching the downloads (so it doesn't slow down the game server's upload speed). I guess it depends on the amount of custom sound files and how often people are joining the server.
dustinandband 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 16:45.


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