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

EmitSoundAny - Cross-game sound emitting (aka CS:GO compatible) (1.0.2, 2014-03-19)


Post New Thread Reply   
 
Thread Tools Display Modes
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 01-31-2017 , 21:43   Re: EmitSoundAny - Cross-game sound emitting (aka CS:GO compatible) (1.0.2, 2014-03-1
Reply With Quote #51

Quote:
Originally Posted by DeagLe.Studio View Post
Hey, it seems that the EmitSoundToClientAny is not working, but EmitAmbientSoundAny seems to work just fine.

I'm getting an error like this when I use EmitSoundToClientAny even tho the sounds is precached and I tried to precache the sound just before playing it too but it still doesnt work
Code:
SV_StartSound: *sound.mp3 not precached (7229)
PS: The game is CSGO
Check to make sure it is being downloaded properly. Delete it from your csgo sounds folder and see if you re-download it. If not, make sure the plugin is adding it to the downloads table and that it is on your fastDL and everything is named properly.
__________________
ThatOneGuy is offline
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 02-01-2017 , 04:32   Re: EmitSoundAny - Cross-game sound emitting (aka CS:GO compatible) (1.0.2, 2014-03-1
Reply With Quote #52

Quote:
Originally Posted by ThatOneGuy View Post
Check to make sure it is being downloaded properly. Delete it from your csgo sounds folder and see if you re-download it. If not, make sure the plugin is adding it to the downloads table and that it is on your fastDL and everything is named properly.
Its added in the sounds folder, and no I dont have a server atm so I'm testing in a listen server.
TheDS1337 is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 02-01-2017 , 05:24   Re: EmitSoundAny - Cross-game sound emitting (aka CS:GO compatible) (1.0.2, 2014-03-1
Reply With Quote #53

Did you use PrecacheSoundAny in OnMapStart?
__________________
Peace-Maker is offline
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 02-01-2017 , 05:37   Re: EmitSoundAny - Cross-game sound emitting (aka CS:GO compatible) (1.0.2, 2014-03-1
Reply With Quote #54

Quote:
Originally Posted by Peace-Maker View Post
Did you use PrecacheSoundAny in OnMapStart?
Yes I did I tried also to use it just before starting the song (saw this in Zombie Reloaded's sourcecode) but it didnt work aswell.
TheDS1337 is offline
thomasjosif
AlliedModders Donor
Join Date: Mar 2016
Old 02-02-2017 , 21:21   Re: EmitSoundAny - Cross-game sound emitting (aka CS:GO compatible) (1.0.2, 2014-03-1
Reply With Quote #55

Quote:
Originally Posted by DeagLe.Studio View Post
Yes I did I tried also to use it just before starting the song (saw this in Zombie Reloaded's sourcecode) but it didnt work aswell.
Would be better if you posted the code
__________________
Systems Admin @ http://hellsgamers.com
thomasjosif is offline
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 02-04-2017 , 10:03   Re: EmitSoundAny - Cross-game sound emitting (aka CS:GO compatible) (1.0.2, 2014-03-1
Reply With Quote #56

Quote:
Originally Posted by thomasjosif View Post
Would be better if you posted the code
Well here it is.. the code is not fully functional and not completed but you should get me.
Code:
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <emitsoundany>

#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo = 
{
	name = "[ZR] Jetpack",
	author = "",
	description = "",
	version = "",
	url = ""
};

#define JETPACK_ENERGY 150			// Calculated like: secs * 20.0
#define JETPACK_SPEED 350.0
#define JETPACK_ROCKET_DELAY 15.0	
#define JETPACK_ROCKET_SPEED 4000.0
#define JETPACK_ROCKET_MODEL "models/props/cs_italy/bananna.mdl"

bool g_HasJetpack[MAXPLAYERS + 1];
int g_JetpackEnergy[MAXPLAYERS + 1];
float g_NextRocketTime[MAXPLAYERS + 1];

float g_MaxSpeed[MAXPLAYERS + 1];

public void OnPluginStart()
{	
}

public void OnClientPutInServer(int client)
{
	g_HasJetpack[1] = true;
	g_JetpackEnergy[1] = JETPACK_ENERGY;
	g_NextRocketTime[1] = GetGameTime() * GetTickInterval();
	
	SDKHook(client, SDKHook_PreThink, OnPlayerPreThink);
	SDKHook(client, SDKHook_PreThinkPost, OnPlayerPreThink_Post);
}

public void OnMapStart()
{
	AddFileToDownloadsTable("sound/zombie_revolution/jetpack_fly.mp3"); 
	AddFileToDownloadsTable("sound/zombie_revolution/jetpack_noenergy.mp3");
	AddFileToDownloadsTable("sound/zombie_revolution/jetpack_firerocket.mp3");
	
	PrecacheSoundAny("zombie_revolution/jetpack_fly.mp3");
	PrecacheSoundAny("zombie_revolution/jetpack_noenergy.mp3");
	PrecacheSoundAny("zombie_revolution/jetpack_firerocket.mp3");
	
	PrecacheModel(JETPACK_ROCKET_MODEL);
}

public void OnPlayerPreThink(int client)
{
	if( !IsPlayerAlive(client) || !g_HasJetpack[client] )
	{	
		return;
	}
	
	static float origin[3], eyeAngles[3], velocity[3];
	
	int flags = GetEntityFlags(client);
	int buttons = GetClientButtons(client);
	int entity = 0;
	float gameTime = GetGameTime() * GetTickInterval();	
	
	if( g_JetpackEnergy[client] < JETPACK_ENERGY && ((flags & FL_ONGROUND) || (flags & FL_INWATER)) )
	{	
		g_JetpackEnergy[client]++;
	}		
	else if( g_JetpackEnergy[client] > 0 && (buttons & IN_JUMP) && (buttons & IN_DUCK) )
	{				
		GetClientAbsOrigin(client, origin);
		GetClientEyeAngles(client, eyeAngles);
		
		eyeAngles[0] = -40.0;
		
		GetAngleVectors(eyeAngles, velocity, NULL_VECTOR, NULL_VECTOR);
		ScaleVector(velocity, JETPACK_SPEED);
		
		velocity[2] *= 0.8;
		
		TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, velocity);
		
		g_JetpackEnergy[client]--;		
		
		if( GetRandomInt(0, 2) == 0 )
		{
			DataPack data = new DataPack();
			
			eyeAngles[0] = 110.0;
			origin[2] += 25.0;
			
			PrecacheSoundAny("zombie_revolution/jetpack_fly.mp3");
			PrecacheSoundAny("zombie_revolution/jetpack_noenergy.mp3");
	
//			EmitAmbientSoundAny(g_JetpackEnergy[client] > JETPACK_ENERGY / 4 ? "zombie_revolution/jetpack_fly.mp3" : "zombie_revolution/jetpack_noenergy.mp3", NULL_VECTOR, client);
			EmitSoundToClientAny(client, g_JetpackEnergy[client] > JETPACK_ENERGY / 4 ? "zombie_revolution/jetpack_fly.mp3" : "zombie_revolution/jetpack_noenergy.mp3", SOUND_FROM_PLAYER, SNDCHAN_ITEM, SNDLEVEL_NORMAL, SND_NOFLAGS, SNDVOL_NORMAL, SNDPITCH_HIGH);
			
			static char parentname[32], targetname[32];			
			Format(parentname, sizeof(parentname), "jetpack_owner_%d", client);
			
			DispatchKeyValue(client, "targetname", targetname);			

			entity = CreateEntityByName("env_steam");

			if( IsValidEdict(entity) )
			{
				Format(targetname, sizeof(targetname), "jetpack_flame_%d", client);
				
				DispatchKeyValue(entity, "parentname", parentname);
				DispatchKeyValue(entity, "targetname", targetname);				
				DispatchKeyValue(entity, "SpawnFlags", "1");
				DispatchKeyValue(entity, "Type", "0");
				DispatchKeyValue(entity, "InitialState", "1");
				DispatchKeyValue(entity, "Spreadspeed", "10");
				DispatchKeyValue(entity, "Speed", "400");
				DispatchKeyValue(entity, "Startsize", "20");
				DispatchKeyValue(entity, "EndSize", "600");
				DispatchKeyValue(entity, "Rate", "30");
				DispatchKeyValue(entity, "JetLength", "200");
				DispatchKeyValue(entity, "RenderColor", "255 100 30");
				DispatchKeyValue(entity, "RenderAmt", "180");				
				DispatchSpawn(entity);
				
				TeleportEntity(entity, origin, eyeAngles, NULL_VECTOR);
				
				SetVariantString(parentname);

				AcceptEntityInput(entity, "SetParent", entity, entity, 0);
				AcceptEntityInput(entity, "TurnOn");
				
				data.WriteCell(entity);
			}
			
			entity = CreateEntityByName("env_steam");
			
			if( IsValidEdict(entity) )
			{
				Format(targetname, sizeof(targetname), "jetpack_flame02_%d", client);
				
				DispatchKeyValue(entity, "parentname", parentname);
				DispatchKeyValue(entity, "targetname", targetname);				
				DispatchKeyValue(entity, "SpawnFlags", "1");
				DispatchKeyValue(entity, "Type", "1");
				DispatchKeyValue(entity, "InitialState", "1");
				DispatchKeyValue(entity, "Spreadspeed", "10");
				DispatchKeyValue(entity, "Speed", "400");
				DispatchKeyValue(entity, "Startsize", "20");
				DispatchKeyValue(entity, "EndSize", "600");
				DispatchKeyValue(entity, "Rate", "10");
				DispatchKeyValue(entity, "JetLength", "200");
				DispatchSpawn(entity);

				TeleportEntity(entity, origin, eyeAngles, NULL_VECTOR);

				SetVariantString(parentname);

				AcceptEntityInput(entity, "SetParent", entity, entity, 0);
				AcceptEntityInput(entity, "TurnOn");
				
				data.WriteCell(entity);
			}
			
			CreateTimer(1.0, Timer_RemoveFlame, data);
		}
	}	
	
	if( g_NextRocketTime[client] <= gameTime && (buttons & IN_ATTACK2) )
	{
		entity = CreateEntityByName("hegrenade_projectile");
		
		if( IsValidEdict(entity) )
		{
			GetClientAbsOrigin(client, origin);
			GetClientEyeAngles(client, eyeAngles);			
		
			GetAngleVectors(eyeAngles, velocity, NULL_VECTOR, NULL_VECTOR);
			ScaleVector(velocity, JETPACK_ROCKET_SPEED);					
			
			SetEntPropEnt(entity, Prop_Data, "m_hOwnerEntity", client);			
			SetEntProp(entity, Prop_Send, "m_nSolidType", 2);
			SetEntProp(entity, Prop_Data, "m_takedamage", 2);
			
			SetEntityMoveType(entity, MOVETYPE_FLY);
			SetEntityModel(entity, JETPACK_ROCKET_MODEL);
			
			DispatchSpawn(entity);
			
			TeleportEntity(entity, origin, NULL_VECTOR, velocity);
		}
		
		g_NextRocketTime[client] = gameTime + JETPACK_ROCKET_DELAY;
	}
}

public void OnPlayerPreThink_Post(int client)
{
	g_MaxSpeed[client] = GetEntPropFloat(client, Prop_Data, "m_flMaxspeed");
}

public Action Timer_RemoveFlame(Handle timer, DataPack data)
{
	static char classname[32];
	
	data.Reset();
	
	int flameEntity = data.ReadCell();
	
	if( IsValidEdict(flameEntity) )
	{
		GetEdictClassname(flameEntity, classname, sizeof(classname));
		
		if( StrEqual(classname, "env_steam") )
		{
			AcceptEntityInput(flameEntity, "TurnOff");
			AcceptEntityInput(flameEntity, "Kill");
		}
	}
	
	flameEntity = data.ReadCell();
	
	if( IsValidEdict(flameEntity) )
	{
		GetEdictClassname(flameEntity, classname, sizeof(classname));
		
		if( StrEqual(classname, "env_steam") )
		{
			AcceptEntityInput(flameEntity, "TurnOff");
			AcceptEntityInput(flameEntity, "Kill");
		}
	}
	
	delete data;	
}
TheDS1337 is offline
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 02-22-2017 , 13:08   Re: EmitSoundAny - Cross-game sound emitting (aka CS:GO compatible) (1.0.2, 2014-03-1
Reply With Quote #57

emitsoundany.inc with updated syntax.
Attached Files
File Type: inc emitsoundany.inc (6.1 KB, 222 views)
Kailo is offline
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 03-02-2017 , 17:11   Re: EmitSoundAny - Cross-game sound emitting (aka CS:GO compatible) (1.0.2, 2014-03-1
Reply With Quote #58

Quote:
Originally Posted by Kailo View Post
emitsoundany.inc with updated syntax.
Did you test this?
TheDS1337 is offline
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 03-03-2017 , 09:19   Re: EmitSoundAny - Cross-game sound emitting (aka CS:GO compatible) (1.0.2, 2014-03-1
Reply With Quote #59

Quote:
Originally Posted by DeagLe.Studio View Post
Did you test this?
Yes, i tested.
Kailo is offline
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 03-03-2017 , 10:10   Re: EmitSoundAny - Cross-game sound emitting (aka CS:GO compatible) (1.0.2, 2014-03-1
Reply With Quote #60

Quote:
Originally Posted by Kailo View Post
Yes, i tested.
I tested with EmitSoundToClientAny and it didnt work :/
TheDS1337 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 02:15.


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