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

[REQ] Port of ES Ragequit Plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
StrikerMan780
AlliedModders Donor
Join Date: Jul 2009
Location: Canada
Old 12-01-2009 , 17:22   [REQ] Port of ES Ragequit Plugin
Reply With Quote #1

I'm trying to cut down on the number of Server Plugins installed to my Dedicated server, and trying to drop using Matties Eventscripts completely, due to instability. So far, I've dropped Mani Admin Plugin, and things work a little better. But, I haven't dropped ES yet, as there are some eventscripts that I just can't live without. The ES Ragequit plugin is one of them, and one of the only ragequit plugins that work with every game.

The ones I searched on sourcemod.net, only work with TF2 or Left 4 Dead... Not what I need. I need something that will work with anything, like HL2DM.

The plugin checks for time between death, and conditions of quitting. If a person quits within a certain amount of time, it plays the sound "R-R-R-R-Ragequit!" The only CVar for this is ragequit_max_delay. Defaults to 10. This basically sets the amount of time between dying, and quitting to have it register as a ragequit. Oh, btw, timeouts and crashes do not count as ragequits in this plugin at all.

Here is the code of the plugin, if anyone is interested: Credit goes to ojii, the original creator of the plugin.
Code:
#===============================================================================
# Config Start
#===============================================================================

ragequit_max_delay = 10.0 # this is a server var now!

#===============================================================================
# Config End
#===============================================================================

__version__ = '1.3'

import es
import gamethread
import time

debug = lambda x: es.dbgmsg(1, '[RQ] %s' % x)

max_delay = es.ServerVar('ragequit_max_delay',
                         ragequit_max_delay,
                         "Amount of seconds between death and disconnect.")

es.ServerVar('ragequit_ver', __version__).makepublic()

class RageQueue(dict):
    """
    A self-emptying dictionary :D
    """
    def __setitem__(self, victim, killer):
        debug('setting item %s in RageQueue' % victim)
        if dict.__contains__(self, victim):
            gamethread.cancelDelayed('ragequit_%s' % victim)
        else:
            dict.__setitem__(self, victim, killer)
        gamethread.delayedname(float(max_delay),
                               'ragequit_%s' % victim,
                               self.__delitem__,
                               (victim,))
                               
    def __delitem__(self, item):
        debug('deleting item %s from RageQueue' % item)
        if dict.__contains__(self, item):
            dict.__delitem__(self, item)
rage_queue = RageQueue()

names = {}

def load():
    """
    w00t we get loaded! 
    """
    es.loadevents('declare', 'addons/eventscripts/ragequit/events.res')
    downloadables()
    debug("loaded (v %s)" % __version__)
    
def es_map_start(ev):
    """
    New map! Let's hope this gonna be fun!
    """
    es.loadevents('declare', 'addons/eventscripts/ragequit/events.res')
    downloadables()
    
def downloadables():
    """
    Add downloadables
    """
    debug("added sound/ragequit/ragequit.mp3 to downloadables")
    es.stringtable('downloadables', 'sound/ragequit/ragequit.mp3')

def player_connect(ev):
    """
    A new player connected! Let's remember their names!
    """
    names[ev['userid']] = ev['name']
    
def player_changename(ev):
    """
    A player changed their name! Let's not forget it!
    """
    names[ev['userid']] = ev['newname']

def player_death(ev):
    """
    Oh no! Looks like this poor little guy died! Let's hope he stays calm and
    doesn't rush out of here in rage!
    """
    debug('a player died: %s' % ev['userid'])
    rage_queue[ev['userid']] = [('string', 'victimsteamid', ev['es_steamid']),
                                ('string', 'attackersteamid', ev['es_attackersteamid']),
                                ('int', 'attackeruserid', ev['attacker']),
                                ('string', 'weapon', ev['weapon']),
                                ('int', 'headshot', ev['headshot']),
                                ('float', 'timestamp', time.time())]
    
def player_disconnect(ev):
    """
    Hmm, looks like someone doesn't want to play anymore... Let's find out why!
    """
    debug('a player disconnected: %s' % ev['userid'])
    if ev['userid'] in rage_queue:
        debug('player in rage queue')
        if ev['reason'].lower().startswith('disconnect by user'):
            debug('disconnect by user')
            info = rage_queue[ev['userid']]
            del rage_queue[ev['userid']]
            ragequit(names[ev['userid']], info)
        else:
            debug('ragequit, but not by user')
    else:
        debug('player left calmly')
        
def ragequit(name, info):
    """
    Some people just can't stay calm... That guy just left in rage!
    """
    debug('ragequit')
    users = es.getUseridList()
    if users:
        debug(" %s has left in rage" % name)
        es.msg('#multi', '#lightgreen%s#default has left in #lightgreenrage!' % name)
        es.emitsound('player', users[0], 'ragequit/ragequit.mp3', 1.0, 0.0)
    else:
        debug("%s has left in rage, but there's noone here to care about it." % name)
    # fire event, we fire the event in any case, for addons which wanna track it
    debug('firing event')
    es.event('initialize', 'ragequit')
    for evtype, key, value in info:
        es.event('set%s' % evtype, 'ragequit', key, value)
    es.event('fire', 'ragequit')
I can understand what the code does by reading it, but I just simply do not have the skill or knowledge to create sourcemod plugins. Goes right over my head, and I'm always short on time, so I hadn't got the chance yet to learn sourcemod coding. The extent of my scripting knowledge is limited to making scripts for a far simpler game. (Skulltag/ZDoom).

Last edited by StrikerMan780; 12-04-2009 at 20:44.
StrikerMan780 is offline
AtomicStryker
Veteran Member
Join Date: Apr 2009
Location: Teutonia!!
Old 12-03-2009 , 17:43   Re: [REQ] Port of ES Ragequit Plugin
Reply With Quote #2

I was bored and had 10 minutes to waste ;)

This doesn't use any "dictionary" or data storage, simply Timers on each Client-Id

PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "1.0.0"
#define DEBUG 0

public Plugin:myinfo =
{
    
name "Rage Quit",
    
author "AtomicStryker",
    
description "Plays a sound if someone leaves within short time after death",
    
version PLUGIN_VERSION,
    
url ""
}

new 
Handle:DeathTimer[MAXPLAYERS+1];
new 
Handle:varTime;
new 
Handle:varSound;

public 
OnPluginStart()
{
    
CreateConVar("sm_ragequit_version"PLUGIN_VERSION"Rage Quit Version on this server"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD);

    
HookEvent("player_death"Event_Death);
    
    
varTime CreateConVar("sm_ragequit_timesetting""10""How long after death a disconnect is treated as ragequit"FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_SPONLY);
    
varSound CreateConVar("sm_ragequit_sound""ragequit/ragequit.mp3""Path to the rage quit sound file"FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_SPONLY);

    
AutoExecConfig(true,"ragequit");
}

public 
OnMapStart()
{
    
decl String:sound[256];
    
GetConVarString(varSoundsoundsizeof(sound));
    
PrecacheSound(soundtrue);
    
PrefetchSound(sound);
}

public 
OnMapEnd()
{
    for (new 
1<= MaxClientsi++)
    {
        if (
DeathTimer[i] != INVALID_HANDLE)
        {
            
KillTimer(DeathTimer[i]);
            
DeathTimer[i] = INVALID_HANDLE;
        }
    }
}

public 
Action:Event_Death(Handle:eventString:event_name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));    
    if(!
client || !IsClientInGame(client) || IsFakeClient(client)) return;
        
    if (
DeathTimer[client] != INVALID_HANDLE)
    {
        
KillTimer(DeathTimer[client]);
        
DeathTimer[client] = INVALID_HANDLE;
    }
    
DeathTimer[client] = CreateTimer(GetConVarFloat(varTime), RemovePlayerTimerclient);
}

public 
Action:RemovePlayerTimer(Handle:timerany:client)
{
    
DeathTimer[client] = INVALID_HANDLE;
}

public 
OnClientDisconnect(client)
{
    if (
DeathTimer[client] != INVALID_HANDLE// if he has a timer running on him, he died recently enough
    
{
        
KillTimer(DeathTimer[client]);
        
DeathTimer[client] = INVALID_HANDLE;
        
        
GotARager(client);
    }
}

GotARager(client)
{
    
decl String:sound[256];
    
GetConVarString(varSoundsoundsizeof(sound));
    
    
PrintToChatAll("%N left in tears and rage, oh well, who cares."client);
    
EmitSoundToAll(sound);

AtomicStryker is offline
StrikerMan780
AlliedModders Donor
Join Date: Jul 2009
Location: Canada
Old 12-03-2009 , 17:52   Re: [REQ] Port of ES Ragequit Plugin
Reply With Quote #3

Thanks man! Much appreciated.
StrikerMan780 is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 12-03-2009 , 22:57   Re: [REQ] Port of ES Ragequit Plugin
Reply With Quote #4

I did my own version of this and released it here:

http://forums.alliedmods.net/showthread.php?t=110876

I don't mean to talk bad about AtomicStryker's version, but I think mine's a bit better (doesn't use timers for counting disconnect time, uses a translation file for easy reconfiguration of the phrase, and adds the sound to the download table).
bl4nk is offline
StrikerMan780
AlliedModders Donor
Join Date: Jul 2009
Location: Canada
Old 12-03-2009 , 23:08   Re: [REQ] Port of ES Ragequit Plugin
Reply With Quote #5

Either way, this is all great. Thanks guys. I've sent a small $2 donation to sourcemod as thanks.

Oh, btw, no rush or pressure, but if anyone is interested, I've come up with a more ambitious idea for a plugin here: https://forums.alliedmods.net/showthread.php?t=109186
StrikerMan780 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 10:34.


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