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

[L4D & L4D2] Difficulty Adjustment System (v14.0, 08-06-2018)


Post New Thread Reply   
 
Thread Tools Display Modes
Visual77
Veteran Member
Join Date: Jan 2009
Old 03-19-2018 , 08:17   Re: [L4D & L4D2] Difficulty Adjustment System (v9.0, 01-23-2018)
Reply With Quote #41

You have to give the plugin author more details, like your server values, if you have modified them etc. Add debug to the plugin, check whatever makes the plugin not continue.
Is the problem in the counting or is it in bIsSystemValid etc.

das_easydifficulty
das_normaldifficulty
das_advanceddifficulty
das_expertdifficulty

Last edited by Visual77; 03-19-2018 at 08:21.
Visual77 is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 03-22-2018 , 02:58   Re: [L4D & L4D2] Difficulty Adjustment System (v9.0, 01-23-2018)
Reply With Quote #42

Quote:
Originally Posted by Visual77 View Post
You have to give the plugin author more details, like your server values, if you have modified them etc. Add debug to the plugin, check whatever makes the plugin not continue.
Is the problem in the counting or is it in bIsSystemValid etc.

das_easydifficulty
das_normaldifficulty
das_advanceddifficulty
das_expertdifficulty
Yes, all that information would be helpful and greatly appreciated!
__________________
Psyk0tik is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 03-23-2018 , 11:36   Re: [L4D & L4D2] Difficulty Adjustment System (v9.0, 01-23-2018)
Reply With Quote #43

i'll take a look at this, i have a difficulty adjustment plugin I made that not only adjusts difficulty but zombie counts among other things dynamically based on player counts. Chances are if its not working 100 percent of the time it has to do with where your checking the survivor counts, i had to do it in mine in several places in order for it to properly get the counts when needed...i'll let u know after i've looked at the code. The best thing u can do is hook player_activate, player_replace_bot, bot_player_replace, and player_disconnect...That way it gets the player counts dynamically as players join and leave or become afk...and adjust the settings dynamically, not just at round start, if thats what your doing, i'll take a look.
MasterMind420 is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 03-23-2018 , 11:45   Re: [L4D & L4D2] Difficulty Adjustment System (v9.0, 01-23-2018)
Reply With Quote #44

ok i see your doing it dynamically, i have some other pointers as well if you want some help with this...
MasterMind420 is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 03-23-2018 , 11:58   Re: [L4D & L4D2] Difficulty Adjustment System (v9.0, 01-23-2018)
Reply With Quote #45

I'd do something like this...
Code:
public Action Player_Events(Event event, const char[] name, bool dontBroadcast)
{
	int data; //Just sending an int thru RequestFrame requires something to pass thru
	RequestFrame(NextFrame, data);
}

public void NextFrame(any data)
{
	vUpdatePlayerCount(iGetPlayerCount());
}
Some events won't catch the function properly to count players unless you do it a frame later or in some cases require a longer timer. I use this in my plugin because i had issues with it not getting the player count...player_activate event is fired whenever a bot or client is created, humans only trigger this when they take over the bot at the beginning of a round, bots trigger at round start and every time a player goes afk(because a bot is created to take there place). I find it highly accurate compared to most other hooks for first spawning in...

Also...this can be cleaned up a bit.
Code:
bool bIsHumanSurvivor(int client)
{
	return (client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && GetClientTeam(client) == 2 && IsPlayerAlive(client) && !IsClientInKickQueue(client) && !IsFakeClient(client) && IsValidEntity(client));
}

To This...

bool bIsHumanSurvivor(int client)
{
	return (client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && IsPlayerAlive(client) && !IsClientInKickQueue(client) && !IsFakeClient(client));
}
IsClientConnected is not necessary, IsClientInGame deals with that
IsValidEntity is not necessary either, your never passing an index higher than MaxPlayers thru anyway. If you were it would fail before it ever got to that check anyway checking <= MaxClients.

You can replace all three of these...
Code:
public void OnMapStart()
{
	vUpdatePlayerCount(iGetPlayerCount());
}

public void OnClientPutInServer(int client)
{
	vUpdatePlayerCount(iGetPlayerCount());
}

public void OnClientPostAdminCheck(int client)
{
	vUpdatePlayerCount(iGetPlayerCount());
}
With player_activate eventhook, use public void and a postnocopy hook, u don't require a return or any information from the hook itself.

Also change public Action Player_Events to public void Player_Events and all the hooks to it, to postnocopy for optimization

Also this...
if (cvEnablePlugin.BoolValue && bIsHumanSurvivor(client) && bIsSystemValid())

i'm not entirely sure if bIsHumanSurvivor(client) is even necessary here, when u call this function your getting it with the player count anyway...this may be causing an issue after the fact but i'm not sure...either way i don't think its necessary.

Hopefully this info helps

Last edited by MasterMind420; 03-23-2018 at 12:36.
MasterMind420 is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 03-23-2018 , 12:42   Re: [L4D & L4D2] Difficulty Adjustment System (v9.0, 01-23-2018)
Reply With Quote #46

ahh i caught it...

vUpdatePlayerCount(iGetPlayerCount());

void vUpdatePlayerCount(int client)

so client will always be the player count, technically a client index but it will always come back as checking
bIsHumanSurvivor(client) as the player count thats returned, this should not be necessary, the player count is checking bIsHumanSurvivor(i) anyway...

change this
void vUpdatePlayerCount(int client)

to this
void vUpdatePlayerCount(int iPlayerCount)

and change this
if (cvEnablePlugin.BoolValue && bIsHumanSurvivor(client) && bIsSystemValid())

to this
if (cvEnablePlugin.BoolValue && bIsSystemValid())

also change this
int iEasy = cvEasy.IntValue, iNormal = cvNormal.IntValue, iAdvanced = cvAdvanced.IntValue, iExpert = cvExpert.IntValue, iPlayerCount = iGetPlayerCount();

to this
int iEasy = cvEasy.IntValue, iNormal = cvNormal.IntValue, iAdvanced = cvAdvanced.IntValue, iExpert = cvExpert.IntValue;

u can make iPlayerCount a global but it shouldn't be necessary, every thing i've shown should optimize and fix it

Last edited by MasterMind420; 03-23-2018 at 13:00.
MasterMind420 is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 03-23-2018 , 19:06   Re: [L4D & L4D2] Difficulty Adjustment System (v9.0, 01-23-2018)
Reply With Quote #47

Here's a test version with the following changes:

- Implemented all the changes that MasterMind420 suggested
- Added checks for OnMapStart() and OnMapEnd() to reset some bools.
- Idle players are no longer counted.

Anyone who wants to test v10.0 can grab the source code from this post.
__________________

Last edited by Psyk0tik; 03-28-2018 at 23:48. Reason: Updated plugin on the main post.
Psyk0tik is offline
Mi.Cura
Veteran Member
Join Date: Dec 2016
Location: Brazil
Old 03-23-2018 , 19:41   Re: [L4D & L4D2] Difficulty Adjustment System (v9.0, 01-23-2018)
Reply With Quote #48

I'll test this
Mi.Cura is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 03-23-2018 , 19:46   Re: [L4D & L4D2] Difficulty Adjustment System (v9.0, 01-23-2018)
Reply With Quote #49

yah i wont actually test this myself but vUpdatePlayerCount(iGetPlayerCount()); passing the player count thru like this may not work, i tested it early with my plugin and got mixed results, if it doesn't no big deal just re-add iPlayerCount = iGetPlayerCount(); and change this to vUpdatePlayerCount(); in the nextframe function that should fix it....other than that the nextframe function should help no need to pass anything thru

Last edited by MasterMind420; 03-23-2018 at 19:50.
MasterMind420 is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 03-23-2018 , 22:38   Re: [L4D & L4D2] Difficulty Adjustment System (v9.0, 01-23-2018)
Reply With Quote #50

This would be a better solution than having to call the function repeatedly.

I already tested it and it works efficiently but can't post the plugin because the code is merged into one of my private plugins.

Last edited by cravenge; 03-23-2018 at 22:39.
cravenge is offline
Reply



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 17:39.


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