Raised This Month: $276 Target: $400
 69% 

[Any] Prevent Fast Ladder Climb


Post New Thread Reply   
 
Thread Tools Display Modes
Author
RedSword
SourceMod Plugin Approver
Join Date: Mar 2006
Location: Quebec, Canada
Plugin ID:
2880
Plugin Version:
1.0.3
Plugin Category:
Gameplay
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
    2 
    Plugin Description:
    Prevent people from quickly climbing the ladders
    Old 04-06-2012 , 02:16   [Any] Prevent Fast Ladder Climb
    Reply With Quote #1

    Prevent Fast Ladder Climb

    v. 1.0.3

    Features :
    • Prevent players from climbing ladders quickly (using two directions movement to climb faster; i.e. 'wa', 'wd', 'as' or 'sd'). This is done by disabling left (a) and right (d) keys when people are climbing a ladder while using UP (w)and DOWN (s).

    Why I made this plugin :
    • Just saw that other plugin here which adressed that problem, but was for L4D only and aimed at other different fixes. So this one is for any mod that has ladders. It uses almost the same method (mine corrected a bug that I'm reporting as I write these lines).
    • It can be annoying when people climb at different speed (like when you move too quickly, and you are blocked by a noob who doesn't know how to climb quickly; or when you climb a ladder too quickly and do a little jump in the air and get stuck on someone's head). I believe this solve (ungracefully :/) the problem.

    CVars :
    • preventfastladderclimbversion: Gives version -_-'
    • ----------
    • preventfastladderclimb : Is the plugin enabled ? 1=Yes (Default), 0=No.

    --------------

    Changelog :
    • 1.0.0 Initial release. (06-04-2012)
    • 1.0.1 Optimized plugin. Thanks to thetwistedpanda for pointing out that I should cache things besides only ConVar values. (06-04-2012)
    • 1.0.1b Reuploaded (forgot to update something that I thought I done). (06-04-2012)
    • 1.0.2 Corrected error that made the plugin unable to compile . Also potentially optimized a case where someone that just connected would be running commands while being considered alive without spawning (so one less check in bools). Thanks to Powerlord for pointing out a different thing slightly related to that. (06-04-2012)
    • 1.0.3 Optimization : ConVarChange now uses "convar" parameter rather than global variable (I read once somewhere that passing throught registers is faster than global variables; don't know for this scenario thought; but I believe it still apply). (06-04-2012)
    • Approved by Dr!fter. Thanks! (13-04-2012)

    Notes :
    • Tested only in CS: Source, but code is taken from a L4D plugin (and I see no reason to not work in a Source game that has ladders).
    • Credits to "disawar1" for the way to prevent people from climbing quickly the ladders.
    Attached Files
    File Type: sp Get Plugin or Get Source (preventfastladderclimb.sp - 858 views - 2.0 KB)
    __________________
    My plugins :
    Red Maze
    Afk Bomb
    RAWR (per player/rounds Awp Restrict.)
    Kill Assist
    Be Medic

    You can also Donate if you appreciate my work

    Last edited by RedSword; 11-06-2012 at 00:51. Reason: some optimizations; wtf15dl
    RedSword is offline
    thetwistedpanda
    Good Little Panda
    Join Date: Sep 2008
    Old 04-06-2012 , 09:39   Re: [Any] Prevent Fast Ladder Climb
    Reply With Quote #2

    PHP Code:
    public ConVarChange_On(Handle:convar, const String:oldValue[], const String:newValue[])
    {
        
    g_bOn GetConVarBoolg_on );

    should be:
    PHP Code:
    public ConVarChange_On(Handle:convar, const String:oldValue[], const String:newValue[])
    {
        
    g_bOn StringToInt(newValue) ? true false;

    And since OnPlayerRunCmd runs quite often, you should consider optimizing the plugin and caching a player's IsPlayerAlive and IsFakeClient into boolean variables.
    __________________
    thetwistedpanda is offline
    RedSword
    SourceMod Plugin Approver
    Join Date: Mar 2006
    Location: Quebec, Canada
    Old 04-06-2012 , 13:19   Re: [Any] Prevent Fast Ladder Climb
    Reply With Quote #3

    Quote:
    Originally Posted by thetwistedpanda View Post
    PHP Code:
    public ConVarChange_On(Handle:convar, const String:oldValue[], const String:newValue[])
    {
        
    g_bOn GetConVarBoolg_on );

    should be:
    PHP Code:
    public ConVarChange_On(Handle:convar, const String:oldValue[], const String:newValue[])
    {
        
    g_bOn StringToInt(newValue) ? true false;

    And since OnPlayerRunCmd runs quite often, you should consider optimizing the plugin and caching a player's IsPlayerAlive and IsFakeClient into boolean variables.
    Good idea !

    I understand how I should cache IsPlayerAlive (spawn/death); but IsFakeClient ? Would only checking that on player_connect be enough; when is a player considered a bot or not :/ (testing it currently)?

    Thanks,

    Red

    EDIT : Anyway to hook OnMoveTypeChange or something like xD ?

    RE-EDIT : 1.0.1 is out; did the optimization; I doubt I could optimize more at this point.
    __________________
    My plugins :
    Red Maze
    Afk Bomb
    RAWR (per player/rounds Awp Restrict.)
    Kill Assist
    Be Medic

    You can also Donate if you appreciate my work

    Last edited by RedSword; 04-06-2012 at 14:16.
    RedSword is offline
    Powerlord
    AlliedModders Donor
    Join Date: Jun 2008
    Location: Seduce Me!
    Old 04-06-2012 , 16:03   Re: [Any] Prevent Fast Ladder Climb
    Reply With Quote #4

    Quote:
    Originally Posted by thetwistedpanda View Post
    PHP Code:
    public ConVarChange_On(Handle:convar, const String:oldValue[], const String:newValue[])
    {
        
    g_bOn GetConVarBoolg_on );

    should be:
    PHP Code:
    public ConVarChange_On(Handle:convar, const String:oldValue[], const String:newValue[])
    {
        
    g_bOn StringToInt(newValue) ? true false;

    And since OnPlayerRunCmd runs quite often, you should consider optimizing the plugin and caching a player's IsPlayerAlive and IsFakeClient into boolean variables.
    SourceMod's own base plugins tend to check cvar values in change hooks using GetConVar[Type] methods, so I consider it the official recommended way of doing it.

    Quote:
    Originally Posted by RedSword View Post
    Good idea !

    I understand how I should cache IsPlayerAlive (spawn/death); but IsFakeClient ? Would only checking that on player_connect be enough; when is a player considered a bot or not :/ (testing it currently)?

    Thanks,

    Red

    EDIT : Anyway to hook OnMoveTypeChange or something like xD ?

    RE-EDIT : 1.0.1 is out; did the optimization; I doubt I could optimize more at this point.
    For optimization reasons, I'd recommend using OnClientPutInServer to set the fake client value and OnClientDisconnected to set it back to fake. Something like this:

    PHP Code:
    new bool:g_bRealClient[MAXPLAYERS+1];

    public 
    OnClientPutInServer(client)
    {
        
    g_bRealClient[client] = !IsFakeClient(client);
    }

    public 
    OnClientDisconnect(client)
    {
        
    g_bRealClient[client] = false;

    IsPlayerAlive would have to be tracked a bit differently... and I'm not sure how many resources you'd actually save in tracking it manually.
    __________________
    Am I back? Well, we'll see.
    Powerlord is offline
    RedSword
    SourceMod Plugin Approver
    Join Date: Mar 2006
    Location: Quebec, Canada
    Old 04-06-2012 , 16:41   Re: [Any] Prevent Fast Ladder Climb
    Reply With Quote #5

    Quote:
    Originally Posted by Powerlord View Post
    For optimization reasons, I'd recommend using OnClientPutInServer to set the fake client value and OnClientDisconnected to set it back to fake.
    OnClientPutInServer() rather than OnClientAuthorized() ? Why and how do you know it is faster ?

    I re-uploaded the .sp; since I did cache IsFakeClient without using it :$. Didn't changed to OnClientPutInServer yet; since I'd like to know how/why it is faster :$.

    Also I do not need to set it back to false, since anyway no disconnected client will trigger OnPlayerRunCmd().
    __________________
    My plugins :
    Red Maze
    Afk Bomb
    RAWR (per player/rounds Awp Restrict.)
    Kill Assist
    Be Medic

    You can also Donate if you appreciate my work

    Last edited by RedSword; 04-06-2012 at 16:42.
    RedSword is offline
    Powerlord
    AlliedModders Donor
    Join Date: Jun 2008
    Location: Seduce Me!
    Old 04-06-2012 , 16:58   Re: [Any] Prevent Fast Ladder Climb
    Reply With Quote #6

    Quote:
    Originally Posted by RedSword View Post
    OnClientPutInServer() rather than OnClientAuthorized() ? Why and how do you know it is faster ?
    Having looked through the SourceMod code, m_bFakeClient (the internal value for storing whether a client is fake or not) is assigned in void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername). Which means if OnClientAuthorized is called first, IsFakeClient may return the wrong value.

    Quote:
    Originally Posted by RedSword View Post
    Also I do not need to set it back to false, since anyway no disconnected client will trigger OnPlayerRunCmd().
    It's a safety mechanism in case newly connecting clients somehow have OnPlayerRunCmd called for them prior to OnClientAuthorized.

    Of course, in this case, you might want it to be true until a client is demonstrated to be a fake, whereas my code assumed the opposite.
    __________________
    Am I back? Well, we'll see.

    Last edited by Powerlord; 04-06-2012 at 17:04.
    Powerlord is offline
    RedSword
    SourceMod Plugin Approver
    Join Date: Mar 2006
    Location: Quebec, Canada
    Old 04-06-2012 , 18:13   Re: [Any] Prevent Fast Ladder Climb
    Reply With Quote #7

    Quote:
    Originally Posted by Powerlord View Post
    Having looked through the SourceMod code, m_bFakeClient (the internal value for storing whether a client is fake or not) is assigned in void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername). Which means if OnClientAuthorized is called first, IsFakeClient may return the wrong value.
    As I look throught the SM code, it seems that it is impossible; since the OnClientAuthorized for the bot is called in the OnClientPutInServer that you refer to; and after m_bFakeClient = true.

    IsFakeClient = false, when a client leave (CPlayer:isconnect(), which is called from PlayerManager::InvalidatePlayer(), which is called from PlayerManager::OnClientDisconnect()) and when a client is created (constructor).

    Since a client needs to be a bot to get his IsFakeClient = true and get his OnClientAuthorized executed; the danger which you refer to (OnClientAuthorized called before OnClientPutInServer) seems to be impossible to happen. Correct me if I'm wrong.

    Quote:
    Originally Posted by Powerlord View Post
    It's a safety mechanism in case newly connecting clients somehow have OnPlayerRunCmd called for them prior to OnClientAuthorized.
    Mmmm... did you check if that was possible ? Because I don't believe it would be possible. Anyway I do now make the player considered dead when disconnecting, meaning the check for player being fake or not is no longer needed. I do take for granted that in every source game you do spawn after OnClientAuth() thought.

    ========

    Meanwhile I Updated to 1.0.2 and corrected not compiling plugin .

    EDIT : Also, why should I track "IsPlayerAlive" differently ?

    RE-EDIT :
    • 1.0.3 Optimization : ConVarChange now uses "convar" parameter rather than global variable (I read once somewhere that passing throught registers is faster than global variables; don't know for this scenario thought; but I believe it still apply).
    __________________
    My plugins :
    Red Maze
    Afk Bomb
    RAWR (per player/rounds Awp Restrict.)
    Kill Assist
    Be Medic

    You can also Donate if you appreciate my work

    Last edited by RedSword; 04-06-2012 at 18:25.
    RedSword 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 01:10.


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