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

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


Post New Thread Reply   
 
Thread Tools Display Modes
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
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 06-17-2022 , 04:51   Re: the plugin does not work in pirates, Vikings, knights 2
Reply With Quote #2

Better share the .sp file or put everything inside the PHP forum tag.

From my knowledge, OnConfigsExecuted is not working for PVKII in the current version

https://github.com/alliedmodders/sourcemod/issues/1738

And OnTakeDamagePost is not working properly as well.

--------

Try changing OnConfigsExecuted to OnMapStart
__________________

Last edited by Marttt; 06-17-2022 at 04:51.
Marttt is online now
ORdli
Member
Join Date: Nov 2021
Old 07-19-2022 , 10:48   Re: the plugin does not work in pirates, Vikings, knights 2
Reply With Quote #3

is it possible to somehow find out through the game files what type of damage a player receives when falling? "net_showevents 2" also does not show events when taking damage

Last edited by ORdli; 07-19-2022 at 10:55.
ORdli is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-19-2022 , 19:01   Re: the plugin does not work in pirates, Vikings, knights 2
Reply With Quote #4

probably:
DMG_FALL (1 << 5)
__________________
Marttt is online now
ORdli
Member
Join Date: Nov 2021
Old 07-20-2022 , 14:25   Re: the plugin does not work in pirates, Vikings, knights 2
Reply With Quote #5

this is already written into the plugin...
ORdli is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-20-2022 , 15:08   Re: the plugin does not work in pirates, Vikings, knights 2
Reply With Quote #6

Quote:
Originally Posted by ORdli View Post
is it possible to somehow find out through the game files what type of damage a player receives when falling? "net_showevents 2" also does not show events when taking damage
¯\_(ツ)_/¯
__________________
Marttt is online now
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 07-28-2022 , 03:36   Re: the plugin does not work in pirates, Vikings, knights 2
Reply With Quote #7

Quote:
Originally Posted by ORdli View Post
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?
It would help a lot if you tell us more specific how you got that plugin at first place.
This ? Random sounds when taking fall damage "ZPS"

Because in that ZPS game, there was no event for player hurt when damaged by fall, plugin use SDKHooks OnTakeDamage to look that.

When look this another game Pirates, Vikings, & Knights II, game pass gibberish damagetype from SDKHook OnTakeDamage while event player_hurt pass right damagetype bit.

Here is version, what use event player_hurt, not OnTakeDamage.



*PS
OnConfigsExecuted() works fine. Unless I have missed something.
And we always use SRCDS, not in-game listen server.
Code:
meta version
 Metamod:Source Version Information
    Metamod:Source version 1.11.0-dev+1148
    Plugin interface version: 16:14
    SourceHook version: 5:5
    Loaded As: Valve Server Plugin
    Compiled on: Jun 24 2022 14:27:03
    Built from: https://github.com/alliedmodders/metamod-source/commit/4bdc218
    Build ID: 1148:4bdc218
    http://www.metamodsource.net/
sm version
 SourceMod Version Information:
    SourceMod Version: 1.11.0.6906
    SourcePawn Engine: 1.11.0.6906, jit-x86 (build 1.11.0.6906)
    SourcePawn API: v1 = 5, v2 = 16
    Compiled on: Jul  8 2022 14:44:49
    Built from: https://github.com/alliedmodders/sourcemod/commit/aa4145c7
    Build ID: 6906:aa4145c7
    http://www.sourcemod.net/
Attached Files
File Type: sp Get Plugin or Get Source (falldamage_sound_test.sp - 56 views - 2.2 KB)
File Type: txt falldamagesound.txt (324 Bytes, 32 views)
__________________
Do not Private Message @me
Bacardi is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-28-2022 , 04:54   Re: the plugin does not work in pirates, Vikings, knights 2
Reply With Quote #8

If you could try, check if damage is returning valid numbers, when I tested was outputting "NaN" results sometimes and twice. (didn't try with _Post tho)
__________________

Last edited by Marttt; 07-28-2022 at 04:54.
Marttt is online now
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 07-28-2022 , 09:32   Re: the plugin does not work in pirates, Vikings, knights 2
Reply With Quote #9

...SDKHooks OnTakeDamage damagetype returned random value in different map (or player class)

But wierd thing is, player_hurt event comes before OnTakeDamage.
It should be opposite ?

*Server own event-dumb-message appear after OnTakeDamage post,
and hooked event by SM plugin trigger/show before ontakedamage post.
__________________
Do not Private Message @me

Last edited by Bacardi; 07-28-2022 at 10:21.
Bacardi is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-28-2022 , 13:34   Re: the plugin does not work in pirates, Vikings, knights 2
Reply With Quote #10

I mean the damage parameter, not the damagetype.
Also, I remember that the hook was trigerring twice.
__________________
Marttt is online now
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 21:19.


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