I have a plugin that plays 3 random sounds when falling, but it doesn't work, the sounds can't be heard, the plugin source itself will be lower, what do I need to edit to make the plugin work in Pvkii?
KeyValues kv;
#include <sdktools>
#include <sdkhooks>
ArrayList sounds;
public void OnPluginStart()
{
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i)) OnClientPutInServer(i);
}
}
public void OnConfigsExecuted()
{
if(sounds != null)
{
delete sounds;
}
sounds = new ArrayList(ByteCountToCells(PLATFORM_MAX_PATH) );
if(kv != null)
delete kv;
kv = new KeyValues("sample");
char soundfile[PLATFORM_MAX_PATH];
BuildPath(Path_SM, soundfile, sizeof(soundfile), "configs/falldamagesound.txt");
if(!kv.ImportFromFile(soundfile))
{
SetFailState("Missing KeyValue file: \"configs/falldamagesound.txt\"");
}
kv.Rewind();
if(!kv.GotoFirstSubKey(false))
{
SetFailState("could'nt enter in first subkey")
}
char buffer[PLATFORM_MAX_PATH];
do
{
kv.GetString(NULL_STRING, buffer, sizeof(buffer));
//PrintToServer("%s %i", buffer, sounds.Length);
if(strlen(buffer) < 5)
continue;
sounds.PushString(buffer);
PrecacheSound(buffer);
Format(buffer, sizeof(buffer), "sound/%s", buffer);
AddFileToDownloadsTable(buffer);
}
while(kv.GotoNextKey(false))
}
public void OnClientPutInServer(int client)
{
SDKHook(client, SDKHook_OnTakeDamagePost, OnTakeDamagePost);
}
public void OnTakeDamagePost(int victim, int attacker, int inflictor, float damage, int damagetype)
{
if(damagetype == DMG_FALL)
{
int random = GetRandomInt(1, sounds.Length-1);
if(sounds.Length <= 1)
{
random = 0;
}
char buffer[PLATFORM_MAX_PATH];
sounds.GetString(random, buffer, sizeof(buffer));
//PrintToServer("array random %i %s", random, buffer);
EmitSoundToAll(buffer, victim);
}
}
OnMapStart does not work, sounds are loaded, but also not played, the plugin itself works, sounds are played through the console, but there is no playback
it seems to me it's about the type of damage, but I do not know how to find out which one the game uses when taking damage from a fall, maybe there are some console commands for debug?
Last edited by ORdli; 06-17-2022 at 10:10.
|