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

Plugin request


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Diggingwolf2605
Junior Member
Join Date: Apr 2020
Old 04-21-2022 , 06:02   Plugin request
Reply With Quote #1

Plugin that automatically kicks a player if a vote kick has passed. I'm currently using a plugin that only bans player's but since vote-kicks do not work correctly in L4D1, the player remains in the game if a vote kick has passed.
Diggingwolf2605 is offline
`666
AlliedModders Donor
Join Date: Jan 2006
Old 04-21-2022 , 09:11   Re: Plugin request
Reply With Quote #2

https://forums.alliedmods.net/showthread.php?t=193643
`666 is offline
Diggingwolf2605
Junior Member
Join Date: Apr 2020
Old 04-22-2022 , 07:02   Re: Plugin request
Reply With Quote #3

Will this plugin support the voting events in L4D1? Since this plugin was compiled using 1.10 and all of my servers are running 1.9, I would need to re-compile it using 1.9. I have tried using the vote kick auto ban plugin but it doesn't work very well. I'm looking for a simple plugin that uses the sm_ban command once a vote-kick has passed. So far I haven't seen any plugin that does it.
Diggingwolf2605 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-22-2022 , 15:22   Re: Plugin request
Reply With Quote #4

...not sure how this should work.
But from server, I used mp_disable_autokick userid to myself and I called votekick to myself, it works.
But not work other way.

When using rcon (or server set mp_disable_autokick to player), it grant player as "admin", in SRCDS. Not SourceMod.

*edit
Thats odd... now it works without "disable autokick" feature. But I had virtual servers LAN connections before, disturbing my rcon connection to SRCDS.
Maybe if you have same IP as SRCDS it works.

*edit
This problem happen in same LAN ?

*edit
Something odd happened, and I can't re-process that again... now it works fine.


*edit
Try this
PHP Code:



public void OnPluginStart()
{
    
// When vote start, vote starter and target made vote in same tick.
    
HookEvent("vote_started"vote_started); // issue #L4D_vote_kick_player
    
HookEvent("vote_cast_yes"vote_started);
    
HookEvent("vote_cast_no"vote_started);
    
HookEvent("vote_failed"vote_started);
    
HookEvent("vote_passed"vote_started); // details #L4D_vote_passed_kick_player
}

public 
void vote_started(Event event, const char[] namebool dontBroadcast)
{
    static 
int tick 0;
    static 
int target 0;


    if(
StrEqual(name"vote_started"false))
    {
        
char buffer[30];
        
event.GetString("issue"buffersizeof(buffer), " ");

        if(
StrEqual(buffer"#L4D_vote_kick_player"false))
        {
            
tick GetGameTickCount();
        }
        return;
    }
    else if(
StrEqual(name"vote_passed"false))
    {
        
char buffer[30];
        
event.GetString("details"buffersizeof(buffer), " ");

        if(
StrEqual(buffer"#L4D_vote_passed_kick_player"false))
        {
            
//KickClient(GetClientOfUserId(target), "You have been voted off");
            
CreateTimer(10.0delaytarget);
        }

        
//return;
    
}
    else if(
StrEqual(name"vote_cast_yes"false))
    {
        if(
GetGameTickCount() == tick)
        {
            
target GetClientUserId(event.GetInt("entityid")); // If vote starter vote itself
        
}

        return;
    }
    else if(
StrEqual(name"vote_cast_no"false))
    {
        if(
GetGameTickCount() == tick)
        {
            
target GetClientUserId(event.GetInt("entityid"));
        }

        return;
    }

    
target 0;
}


public 
Action delay(Handle timerany userid)
{
    
int target GetClientOfUserId(userid);

    
// Works only if client is still in server
    
if(target && IsClientConnected(target) && !IsClientInKickQueue(target))
    {
        
KickClient(target"You have been voted off");
    }

    return 
Plugin_Continue;

__________________
Do not Private Message @me

Last edited by Bacardi; 04-22-2022 at 20:38.
Bacardi is offline
Diggingwolf2605
Junior Member
Join Date: Apr 2020
Old 04-23-2022 , 06:19   Re: Plugin request
Reply With Quote #5

Thank you. I will give it a test and see how it works.
Diggingwolf2605 is offline
Diggingwolf2605
Junior Member
Join Date: Apr 2020
Old 04-24-2022 , 09:16   Re: Plugin request
Reply With Quote #6

Edit: Seems to be working fine to kick players off the server, but is it possible that the banid command can be added? This way I can just use one plugin instead.
Diggingwolf2605 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-24-2022 , 10:15   Re: Plugin request
Reply With Quote #7

Yes. But I wonder why your server not kick or ban player by default. Does some plugin block it ?
__________________
Do not Private Message @me
Bacardi is offline
Diggingwolf2605
Junior Member
Join Date: Apr 2020
Old 04-24-2022 , 18:29   Re: Plugin request
Reply With Quote #8

This issue affects all dedicated server's including official dedicated ones ran by Valve. No plugin that I'm using would be causing this issue. Hopefully Valve will fix the voting system soon with an update to the game.
Diggingwolf2605 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-24-2022 , 19:50   Re: Plugin request
Reply With Quote #9

...but it works fine on my test server (SRCDS windows). Server use kickid and banid commands after vote.

Don't know.

Check you not have this cvar disabled
sv_banid_enabled
It will stop all ban actions
Code:
banid: disabled on server (sv_banid_enabled = 0)



But here is another version of plugin.
- I have only tested with bots...
- I made big change, use game log system: "log on"


It use game cvars:
sv_vote_kick_ban_duration
sv_vote_command_delay

- These are hidden cvars, you can check cvar using cmd help.
But you can only change cvar value with cmd sm_cvar

Code:
] help sv_vote_kick_ban_duration; help sv_vote_command_delay
"sv_vote_kick_ban_duration" = "5"
 game
 - How long should a kick vote ban someone from the server? (in minutes)
"sv_vote_command_delay" = "2" max. 4.500000
 game
 - How long after a vote passes until the action happens
...and plugin own kick will take action, 1 second later of server normal vote kick, if player is still in server.
PHP Code:

// Plugin works with game log: "log on"


ConVar sv_vote_kick_ban_duration;
ConVar sv_vote_command_delay;

ArrayList VoteKickData;

#include <regex>

Regex regex;


public 
void OnPluginStart()
{
    
//regex = new Regex("^\"\\w+<(\\d+)>.*>\" called vote \"kick (\\d+)\"$");
    
regex = new Regex("^\".*<(\\d+)><STEAM_\\d:\\d:\\d+>(?:<Survivor>|<Infected>).*>\" called vote \"kick (\\d+)\"$");



    
VoteKickData = new ArrayList(ByteCountToCells(60));

    
sv_vote_kick_ban_duration FindConVar("sv_vote_kick_ban_duration");
    
sv_vote_command_delay FindConVar("sv_vote_command_delay");

    
HookEvent("vote_failed"vote_started);
    
HookEvent("vote_passed"vote_started); // details #L4D_vote_passed_kick_player

    
HookEvent("player_disconnect"vote_started);

    
AddGameLogHook(gameloghook);
}


public 
Action gameloghook(const char[] message)
{
    if(
regex.Match(message) == 3)
    {
        
VoteKickData.Clear();

        
char buffer[20];
        
regex.GetSubString(1buffersizeof(buffer));
        
VoteKickData.Push(StringToInt(buffer));

        
regex.GetSubString(2buffersizeof(buffer));
        
VoteKickData.Push(StringToInt(buffer));

        
int target GetClientOfUserId(VoteKickData.Get(1));
        
        if(
target)
        {
            
char identity[60];
            if(
GetClientAuthId(targetAuthId_Engineidentitysizeof(identity)))
            {
                
VoteKickData.PushString(identity);
                
                
PrintToChatAll("[SM] Vote Kick will be successful, if player %N choose to disconnect from server before vote ends."target);
            }
        }
    }

    return 
Plugin_Continue;
}


public 
void vote_started(Event event, const char[] namebool dontBroadcast)
{
    if(
StrEqual(name"player_disconnect"false))
    {
        if(
VoteKickData.Length == 3)
        {
            
// If player disconnect during vote
            
int userid event.GetInt("userid");

            if(
userid == VoteKickData.Get(1))
            {
                
ActivateBan(VoteKickDatatrue);
            }
        }

        
// every player_disconnect events stop here
        
return;
    }
    else if(
StrEqual(name"vote_failed"false))
    {
        
// not needed...
    
}
    else if(
StrEqual(name"vote_passed"false))
    {
        
char buffer[30];
        
event.GetString("details"buffersizeof(buffer), " ");

        if(
StrEqual(buffer"#L4D_vote_passed_kick_player"false)
          && 
VoteKickData.Length == 3)
        {
            
// Final step - vote passed: ban and kick player
            
float delay 3.0;

            if(
sv_vote_command_delay != null)
            {
                
delay sv_vote_command_delay.FloatValue 1.0;
            }
            
            
CreateTimer(delaycommand_delayVoteKickData.Get(1));

            
ActivateBan(VoteKickDatafalse);
        }
    }

    
VoteKickData.Clear();
}

public 
Action command_delay(Handle timerany userid)
{
    
int target GetClientOfUserId(userid);

    
// Works only if client is still in server
    
if(target && IsClientConnected(target) && !IsClientInKickQueue(target))
    {
        
KickClient(target"You have been voted off");
    }

    return 
Plugin_Continue;
}


void ActivateBan(ArrayList &list, bool playerdisconnect)
{
    if(list == 
null || list.Length != 3)
        return;

    
int ban_duration 5;

    
int target = list.Get(1);
    
int source = list.Get(0);

    if(
sv_vote_kick_ban_duration != null)
    {
        
ban_duration sv_vote_kick_ban_duration.IntValue;
        
        if(
ban_duration <= 0)
            
ban_duration 1;
        
        if(
ban_duration 300)
            
ban_duration 300;
    }

    
char identity[60];
    list.
GetString(2identitysizeof(identity));

    
BanIdentity(identityban_durationBANFLAG_AUTHID"You have been voted off""callvote kick"source);

    
// Show players ids as userid, don't know are they in server currently. Use game log files to track they actions on server.
    
LogAction(-1, -1"L4D Vote Kick Passed: Player #%i vote kick #%i.    Ban %s for %i minutes"sourcetargetidentityban_duration);

    if(
playerdisconnect)
    {
        
LogAction(-1, -1"L4D Vote Kick Passed: Player #%i disconnected during vote kick"target);
    }

__________________
Do not Private Message @me

Last edited by Bacardi; 04-25-2022 at 15:32. Reason: update
Bacardi is offline
Diggingwolf2605
Junior Member
Join Date: Apr 2020
Old 04-25-2022 , 09:33   Re: Plugin request
Reply With Quote #10

I will do some more testing on my end. Thanks for the help, I appreciate it.
Diggingwolf2605 is offline
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 17:24.


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