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? |
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 |
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
|
Re: the plugin does not work in pirates, Vikings, knights 2
probably:
DMG_FALL (1 << 5) |
Re: the plugin does not work in pirates, Vikings, knights 2
this is already written into the plugin...
|
Re: the plugin does not work in pirates, Vikings, knights 2
Quote:
|
Re: the plugin does not work in pirates, Vikings, knights 2
2 Attachment(s)
Quote:
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 |
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)
|
Re: the plugin does not work in pirates, Vikings, knights 2
...SDKHooks OnTakeDamage damagetype returned random value in different map (or player class)
It should be opposite ? *Server own event-dumb-message appear after OnTakeDamage post, and hooked event by SM plugin trigger/show before ontakedamage post. |
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.