Raised This Month: $ Target: $400
 0% 

[HL2DM] Spectate delay


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nomarky
SourceMod Donor
Join Date: Sep 2007
Old 04-02-2011 , 07:04   [HL2DM] Spectate delay
Reply With Quote #1

Hi

In HL2DM some players abuse spectate to avoid death by switching to spec just before they die and then quickly back again using key binds. This can be very annoying!

I don't want to block spectate completely so what I would like to see is a plugin that creates a configurable delay (say 2 seconds) before switching the player to spectate, so these players can't abuse spectate to improve their score.

Would anyone be interested in making something like that?

Thanks
Nomarky is offline
Samantha
SourceMod Donor
Join Date: Feb 2010
Location: Madagascar
Old 04-02-2011 , 09:49   Re: [HL2DM] Spectate delay
Reply With Quote #2

mp_allowspectators 0
__________________
"I give sopport and knolage in making extractions"
"MASTER(D) - dun0: are you mocing me?" -Master the grate

Plugins
Godmode Until Attack | No Block Team Filter
Extensions
Rcon Hooks
Samantha is offline
Nomarky
SourceMod Donor
Join Date: Sep 2007
Old 04-02-2011 , 10:53   Re: [HL2DM] Spectate delay
Reply With Quote #3

Quote:
Originally Posted by Samantha View Post
mp_allowspectators 0
But I guess that blocks spectate completely? Like I said I don't want to do that, just introduce a small delay before switching to spectate. I'm not sure if this is possible with sourcemod?
Nomarky is offline
Zephyrus
Cool Pig B)
Join Date: Jun 2010
Location: Hungary
Old 04-03-2011 , 05:41   Re: [HL2DM] Spectate delay
Reply With Quote #4

you could hook the spectate command
Zephyrus is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-03-2011 , 09:55   Re: [HL2DM] Spectate delay
Reply With Quote #5

Here for test if you like.
This however block player to join team spectators when alive.
PHP Code:
#include <sourcemod>

public Plugin:myinfo =
{
    
name "Die before join spec",
    
author "Bacardi",
    
description "Prevent players join spec when alive",
    
version "0.2",
    
url "www.sourcemod.net"
}

public 
OnPluginStart()
{
    
AddCommandListener(cmd_jointeam"jointeam");
}

public 
Action:cmd_jointeam(client, const String:command[], argc)
{
    if(
client != && argc && IsPlayerAlive(client))
    {
        
decl String:arg[10], team;
        
arg[0] = '\0';
        
GetCmdArg(1argsizeof(arg))
        
team StringToInt(arg);

        if(
team == 1)
        {
            
PrintToChat(client"[SM] You must be dead before join spectators");
            return 
Plugin_Handled;
        }
    }
    return 
Plugin_Continue;

I'm figure that delay thing, I didn't understand completely... switch player to team spec, after that many seconds when player use command "jointeam 1".
Hhhmmmmmmmm...

*edit
web compiler
http://www.sourcemod.net/compiler.php

*edit edit
Is it better slay player who join spec when alive ?
Seems it done already in "mp_teamplay 1" but not 0 ...

*edit
Change RegConsoleCmd to AddCommandListener

Last edited by Bacardi; 04-04-2011 at 18:41. Reason: let's fix here aöso.. right team 1, 0 not exist. Filter server client = 0
Bacardi is offline
Nomarky
SourceMod Donor
Join Date: Sep 2007
Old 04-03-2011 , 12:28   Re: [HL2DM] Spectate delay
Reply With Quote #6

Thanks Bacardi, stopping alive players from joining spectate would do the same thing. I will test it thank you
Nomarky is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-03-2011 , 17:55   Re: [HL2DM] Spectate delay
Reply With Quote #7

Quote:
Originally Posted by Nomarky View Post
I don't want to block spectate completely so what I would like to see is a plugin that creates a configurable delay (say 2 seconds) before switching the player to spectate, so these players can't abuse spectate to improve their score.

Would anyone be interested in making something like that?

Thanks
Here another example
PHP Code:
#include <sourcemod>

public Plugin:myinfo =
{
    
name "Delay alive player move spec",
    
author "Bacardi",
    
description "Delay player to move spectators when alive",
    
version "0.2",
    
url "www.sourcemod.net"
}

new 
Handle:movespec[MAXPLAYERS] = INVALID_HANDLE;
new 
Handle:sm_movespec_delay INVALID_HANDLE;
new 
Float:movespec_delay;

public 
OnPluginStart()
{
    
AddCommandListener(cmd_jointeam"jointeam");
    
HookEvent("player_disconnect"PlayerDisconnectEventHookMode_Post);
    
sm_movespec_delay CreateConVar("sm_movespec_delay""5.0""Delay player to move spectators when alive in seconds"FCVAR_NONEtrue0.0true10.0);
    
movespec_delay GetConVarFloat(sm_movespec_delay);
    
HookConVarChange(sm_movespec_delayConVarChanged);
}

public 
ConVarChanged(Handle:convar, const String:oldValue[], const String:newValue[])
{
    if(
convar == sm_movespec_delay)
    {
        
movespec_delay StringToFloat(newValue);
    }
}

public 
Action:cmd_jointeam(client, const String:command[], argc)
{
    if(
movespec_delay 1.0 && client != && argc 0)
    {
        
decl String:arg[3], team;
        
arg[0] = '\0';
        
GetCmdArg(1argsizeof(arg))
        
team StringToInt(arg);

        if(
team == 1)
        {
            if(
IsPlayerAlive(client))
            {
                if(
movespec[client] == INVALID_HANDLE)
                {
                    
movespec[client] = CreateTimer(movespec_delayTimerMoveSpecclient);
                    
movespec_delay 2.0 PrintToChat(client"[SM] You will be move to spectators within %0.1f seconds"movespec_delay):0;
                }
                return 
Plugin_Handled;
            }
            else
            {
                if(
movespec[client] != INVALID_HANDLE)
                {
                    
KillTimer(movespec[client]);
                    
movespec[client] = INVALID_HANDLE;
                }
            }
        }
    }
    return 
Plugin_Continue;
}

public 
Action:TimerMoveSpec(Handle:timerany:client)
{
    if(
IsClientInGame(client))
    {
        
ChangeClientTeam(client1);
    }
    
movespec[client] = INVALID_HANDLE;
}

public 
Action:PlayerDisconnect(Handle:event, const String:name[], bool:dontBroadcast)
{
    
decl client;
    
client GetClientOfUserId(GetEventInt(event"userid"));
    if(
movespec[client] != INVALID_HANDLE)
    {
        
KillTimer(movespec[client]);
        
movespec[client] = INVALID_HANDLE;
    }

- When delay set less than 1 second, it's disabled. Above that it delay players to move spectator team when alive.
- Player can join faster to spec when he is dead.
- Above 2 seconds delay, it print in player chat
"[SM] You will be move to spectators within x.x seconds"
- Maximum delay is 10 seconds.

Maybe that was all...
Haven't use timers with handles before, hope I read right from scripting sections.
But I didn't get any errors.

*edit
Could someone who have start using this example, confirm that this works flawless ?
If not, then show errors.

*edit
update, change RegConsoleCmd to AddCommandListener

Last edited by Bacardi; 04-04-2011 at 18:38. Reason: ok.. just add right team 1, 0 not exist
Bacardi 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 13:48.


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