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

[REQ] Plugin for jump in head sound


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 12-08-2019 , 13:35   [REQ] Plugin for jump in head sound
Reply With Quote #1

The title says all.

I want a plugin for my server. I have seen it on some servers and didn't found anything here...

The plugin needs to do:

Play a sound when someone jumps on the other's head
And print to the chat "Player SpirT jumped on SourceMod's head"

Best Regards,

SpirT.
__________________
SpirT is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 12-08-2019 , 14:50   Re: [REQ] Plugin for jump in head sound
Reply With Quote #2

The 'Goomba Stomp' plugin by Flyflo may work for you. Link: https://forums.alliedmods.net/showthread.php?t=111893
PC Gamer is offline
Balimbanana
Member
Join Date: Jan 2017
Old 12-08-2019 , 14:59   Re: [REQ] Plugin for jump in head sound
Reply With Quote #3

Assuming there are collisions between players in the game you want this for, you could do it by checking the client property m_hGroundEntity if it is a client, and the previous ent is not the same. Either checking OnGameFrame() or by 0.1 repeating timer, here is an example:
Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#pragma semicolon 1;
#pragma newdecls required;

int lastground[MAXPLAYERS+1];
char g_SoundPath[128];
bool PlaySound = true;

public void OnPluginStart()
{
	CreateTimer(0.1,repeater,_,TIMER_REPEAT);
	Handle cvar = FindConVar("sm_jumponhead_sound");
	if (cvar == INVALID_HANDLE) cvar = CreateConVar("sm_jumponhead_sound", "", "Sound to play when landing on players head.");
	if (cvar != INVALID_HANDLE)
	{
		GetConVarString(cvar,g_SoundPath,sizeof(g_SoundPath));
		HookConVarChange(cvar,soundpathch);
	}
	CloseHandle(cvar);
}

public void OnMapStart()
{
	if (strlen(g_SoundPath) > 0)
	{
		char fullpath[128];
		Format(fullpath,sizeof(fullpath),"sound/%s",g_SoundPath);
		if (FileExists(fullpath,true,NULL_STRING))
		{
			PrecacheSound(g_SoundPath,true);
			PlaySound = true;
		}
		else
		{
			PrintToServer("Sound \"%s\" does not exist",g_SoundPath);
			PlaySound = false;
		}
	}
	else PlaySound = false;
}

public Action repeater(Handle timer)
{
	for (int i = 1;i<MaxClients+1;i++)
	{
		if ((IsValidEntity(i)) && (i != 0))
		{
			if (IsClientConnected(i))
			{
				if (IsClientInGame(i))
				{
					if (IsPlayerAlive(i))
					{
						if (HasEntProp(i,Prop_Data,"m_hGroundEntity"))
						{
							int groundent = GetEntPropEnt(i,Prop_Data,"m_hGroundEntity");
							if ((groundent > 0) && (groundent < MaxClients+1) && (groundent != lastground[i]))
							{
								lastground[i] = groundent;
								PrintToChatAll("Player %N jumped on %N's head", i, groundent);
								if (PlaySound) EmitSoundToAll(g_SoundPath, i, SNDCHAN_AUTO, SNDLEVEL_NORMAL);
							}
							else lastground[i] = groundent;
						}
					}
				}
			}
		}
	}
}

public void OnClientDisconnect(int client)
{
	lastground[client] = 0;
}

public void soundpathch(Handle convar, const char[] oldValue, const char[] newValue)
{
	Format(g_SoundPath,sizeof(g_SoundPath),"%s",newValue);
	if (strlen(g_SoundPath) > 0)
	{
		char fullpath[128];
		Format(fullpath,sizeof(fullpath),"sound/%s",g_SoundPath);
		if (FileExists(fullpath,true,NULL_STRING))
		{
			PrecacheSound(g_SoundPath,true);
			PlaySound = true;
		}
		else
		{
			PrintToServer("Sound \"%s\" does not exist",g_SoundPath);
			PlaySound = false;
		}
	}
	else PlaySound = false;
}

Last edited by Balimbanana; 12-09-2019 at 21:12.
Balimbanana is offline
Lund
Junior Member
Join Date: Mar 2020
Old 04-17-2020 , 12:44   Re: [REQ] Plugin for jump in head sound
Reply With Quote #4

Quote:
Originally Posted by Balimbanana View Post
Assuming there are collisions between players in the game you want this for, you could do it by checking the client property m_hGroundEntity if it is a client, and the previous ent is not the same. Either checking OnGameFrame() or by 0.1 repeating timer, here is an example:
Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#pragma semicolon 1;
#pragma newdecls required;

int lastground[MAXPLAYERS+1];
char g_SoundPath[128];
bool PlaySound = true;

public void OnPluginStart()
{
	CreateTimer(0.1,repeater,_,TIMER_REPEAT);
	Handle cvar = FindConVar("sm_jumponhead_sound");
	if (cvar == INVALID_HANDLE) cvar = CreateConVar("sm_jumponhead_sound", "", "Sound to play when landing on players head.");
	if (cvar != INVALID_HANDLE)
	{
		GetConVarString(cvar,g_SoundPath,sizeof(g_SoundPath));
		HookConVarChange(cvar,soundpathch);
	}
	CloseHandle(cvar);
}

public void OnMapStart()
{
	if (strlen(g_SoundPath) > 0)
	{
		char fullpath[128];
		Format(fullpath,sizeof(fullpath),"sound/%s",g_SoundPath);
		if (FileExists(fullpath,true,NULL_STRING))
		{
			PrecacheSound(g_SoundPath,true);
			PlaySound = true;
		}
		else
		{
			PrintToServer("Sound \"%s\" does not exist",g_SoundPath);
			PlaySound = false;
		}
	}
	else PlaySound = false;
}

public Action repeater(Handle timer)
{
	for (int i = 1;i<MaxClients+1;i++)
	{
		if ((IsValidEntity(i)) && (i != 0))
		{
			if (IsClientConnected(i))
			{
				if (IsClientInGame(i))
				{
					if (IsPlayerAlive(i))
					{
						if (HasEntProp(i,Prop_Data,"m_hGroundEntity"))
						{
							int groundent = GetEntPropEnt(i,Prop_Data,"m_hGroundEntity");
							if ((groundent > 0) && (groundent < MaxClients+1) && (groundent != lastground[i]))
							{
								lastground[i] = groundent;
								PrintToChatAll("Player %N jumped on %N's head", i, groundent);
								if (PlaySound) EmitSoundToAll(g_SoundPath, i, SNDCHAN_AUTO, SNDLEVEL_NORMAL);
							}
							else lastground[i] = groundent;
						}
					}
				}
			}
		}
	}
}

public void OnClientDisconnect(int client)
{
	lastground[client] = 0;
}

public void soundpathch(Handle convar, const char[] oldValue, const char[] newValue)
{
	Format(g_SoundPath,sizeof(g_SoundPath),"%s",newValue);
	if (strlen(g_SoundPath) > 0)
	{
		char fullpath[128];
		Format(fullpath,sizeof(fullpath),"sound/%s",g_SoundPath);
		if (FileExists(fullpath,true,NULL_STRING))
		{
			PrecacheSound(g_SoundPath,true);
			PlaySound = true;
		}
		else
		{
			PrintToServer("Sound \"%s\" does not exist",g_SoundPath);
			PlaySound = false;
		}
	}
	else PlaySound = false;
}
How do i setup the custom sound? I am new to sorcepawn, i installed the plugin corectly, it is saying in the chat but i dont hear any sound. i put the soundfile in the csgo/sound directory and put the cvar in server.cfg "sm_cvar sm_jumponhead_sound sound/headownage.mp3", or there is a cfg somewhere and i am really stupid?
Lund 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 00:55.


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