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

the plugin does not work in pirates, Vikings, knights 2


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
ORdli
Member
Join Date: Nov 2021
Old 06-16-2022 , 19:23   the plugin does not work in pirates, Vikings, knights 2
Reply With Quote #1

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.
ORdli is offline
 



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 12:04.


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