AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   the plugin does not work in pirates, Vikings, knights 2 (https://forums.alliedmods.net/showthread.php?t=338199)

ORdli 06-16-2022 19:23

the plugin does not work in pirates, Vikings, knights 2
 
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?

Marttt 06-17-2022 04:51

Re: the plugin does not work in pirates, Vikings, knights 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

ORdli 07-19-2022 10:48

Re: the plugin does not work in pirates, Vikings, knights 2
 
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 07-19-2022 19:01

Re: the plugin does not work in pirates, Vikings, knights 2
 
probably:
DMG_FALL (1 << 5)

ORdli 07-20-2022 14:25

Re: the plugin does not work in pirates, Vikings, knights 2
 
this is already written into the plugin...

Marttt 07-20-2022 15:08

Re: the plugin does not work in pirates, Vikings, knights 2
 
Quote:

Originally Posted by ORdli (Post 2784174)
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

¯\_(ツ)_/¯

Bacardi 07-28-2022 03:36

Re: the plugin does not work in pirates, Vikings, knights 2
 
2 Attachment(s)
Quote:

Originally Posted by ORdli (Post 2781812)
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/


Marttt 07-28-2022 04:54

Re: the plugin does not work in pirates, Vikings, knights 2
 
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)

Bacardi 07-28-2022 09:32

Re: the plugin does not work in pirates, Vikings, knights 2
 
...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.

Marttt 07-28-2022 13:34

Re: the plugin does not work in pirates, Vikings, knights 2
 
I mean the damage parameter, not the damagetype.
Also, I remember that the hook was trigerring twice.


All times are GMT -4. The time now is 18:38.

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