Raised This Month: $32 Target: $400
 8% 

[L4D2]Ask for help


Post New Thread Reply   
 
Thread Tools Display Modes
phoenix0001
Senior Member
Join Date: Apr 2010
Location: China
Old 11-20-2017 , 03:17   Re: [L4D2]Ask for help
Reply With Quote #11

thank you all! Tonight I test it.
__________________
I like this BBS sharing of spirit

I come from China, my English is poor
phoenix0001 is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 11-20-2017 , 04:14   Re: [L4D2]Ask for help
Reply With Quote #12

Quote:
Originally Posted by phoenix0001 View Post
thank you all! Tonight I test it.
With Lux's revision, I noticed that when a client disconnects, it gets counted as a client count instead of the client count being reduced by 1.

For example, when X joins, + 1 client count. When X leaves, another +1 client count.
__________________
Psyk0tik is offline
phoenix0001
Senior Member
Join Date: Apr 2010
Location: China
Old 11-20-2017 , 05:01   Re: [L4D2]Ask for help
Reply With Quote #13

Quote:
Originally Posted by Lux View Post
PHP Code:
#include <sourcemod>

#pragma semicolon 1
#define PLUGIN_VERSION "1.0"
#pragma newdecls required

ConVar g_cDifficulty;

public 
Plugin myinfo =
{
    
name "[L4D2] Difficulty Adjuster",
    
author "Tak (Chaosxk)",
    
description "Adjusts difficulty based on number of clients in server.",
    
version PLUGIN_VERSION,
    
url "https://forums.alliedmods.net/showthread.php?t=297009"
}

public 
void OnPluginStart()
{
    if ((
g_cDifficulty FindConVar("z_difficulty")) == null)
    {
        
LogError("[SM] Can not find convar z_difficulty");
        
SetFailState("Can not find convar z_difficulty");
    }
    
UpdateClientCount(GetSurvivorCount());
}

public 
void OnClientPostAdminCheck(int client)
{
    if (
IsFakeClient(client))
        return;
    
    
UpdateClientCount(GetSurvivorCount());
}

public 
void OnClientDisconnect(int client)
{
    if (
IsFakeClient(client))
        return;
    
    
UpdateClientCount(GetSurvivorCount());
}

void UpdateClientCount(int count)
{
    switch (
count)
    {
        case 
4:
        
g_cDifficulty.SetString("easy");
        case 
8:
        
g_cDifficulty.SetString("normal");
        case 
12:
        
g_cDifficulty.SetString("hard");
        case 
16:
        
g_cDifficulty.SetString("impossible");
    }
}

int GetSurvivorCount()
{
    
int iCount 0;
    
    for(
int iClient 1iClient <= MaxClientsiClient++) {
        if(!
IsClientInGame(iClient) || IsFakeClient(iClient) || GetClientTeam(iClient) != 2)
            continue;
        
        
iCount++;
    }
    return 
iCount;

Maybe work? :O
Sometimes it seems to work, and sometimes do not work, I test it for a while to see more

------------------------------------------------------------
The test is completed, he can not work properly.
__________________
I like this BBS sharing of spirit

I come from China, my English is poor

Last edited by phoenix0001; 11-20-2017 at 05:51.
phoenix0001 is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 11-22-2017 , 18:45   Re: [L4D2]Ask for help
Reply With Quote #14

Quote:
Originally Posted by phoenix0001 View Post
Sometimes it seems to work, and sometimes do not work, I test it for a while to see more

------------------------------------------------------------
The test is completed, he can not work properly.
I'm revising the code to make it work properly. I'll post the link here once I release it.
__________________
Psyk0tik is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 11-22-2017 , 22:45   Re: [L4D2]Ask for help
Reply With Quote #15

Here you go: https://forums.alliedmods.net/showthread.php?t=303117
__________________
Psyk0tik 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 04:05.


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