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

[CS:S] No Spec Hop Cash


Post New Thread Reply   
 
Thread Tools Display Modes
Author
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Plugin ID:
2354
Plugin Version:
1.6
Plugin Category:
Fun Stuff
Plugin Game:
Counter-Strike: Source
Plugin Dependencies:
    Servers with this Plugin:
    5 
    Plugin Description:
    Prevent players from increasing their cash amount by spectate hopping
    Old 05-23-2011 , 21:27   [CS:S] No Spec Hop Cash
    Reply With Quote #1

    Okay, so there are two other plugins that do kinda the same thing as this one, but not really. I'll explain in this thread the differences

    This plugin will keep track of player's cash when they join spectate, or disconnect, and ensure that when they join back to a team, they have the same cash they left with (on a per map basis only, map change will reset their cash to default).

    How this works is if they join spectate with less money than mp_startmoney, or simply disconnect and reconnect before the map changes, this plugin will reapply the amount of money the had before leaving the team. This is to thwart what is knows as, "spectate hopping" to increase their cash when they fall below mp_startmoney.

    If mp_startmoney is 1000, and the player has 300 when they enter spectate, after they join back to a team and spawn, their money will be changed back to 300. If a player joins spectate with more cash than mp_startmoney, this plugin will leave their cash alone.

    If a player disconnects (for whatever reason), if they reconnect before the map changes, their cash will be restored to what it was when they disconnected.

    Messages are displayed to the players when they enter spectate and when they join back to a team - you can modify it a bit in the translations file, just keep the format the same.
    example:

    [SpecHopCash] When you join your team again, your cash will be restored to $<amount>

    [SpecHopCash] Your cash has been restored to $<amount>
    ----------------------
    How this plugin differs from ^BuGs^ Disable Spec For Cash is his plugin has been reported as not working, and he hasn't been showing that he's still supporting that plugin. Also, his plugin would just subtract the entire mp_startmoney amount from a player after they joined spectate and back.

    How this plugin differs from FlyingMongoose's Spectate Hop For Money Prevention is that his plugin hard sets the player's cash in such a way that team money is not given to a player when they spawn. Example: When a player goes into spectate with 300, and then back into a team, when they spawn, their money is set to 300 and the player doesn't get the amount of money given to the team at the beginning of the round like every other player gets. Reported here. Also, his plugin was giving timer errors.
    ----------------------

    So, this is why I am publishing this plugin. It is basically a combo of the above two plugins without options. It simply restores a player's cash when they join spectate and go back to a team. I've tested this as best I can and am 98% sure it will work w/o issue, but please reply if you discover any issues and I'll jump on it as soon as I can.

    CREDITS:
    FlyingMongoose
    ^BuGs^
    databomb
    KyleS
    Thank you guys for the basic ideas and help to make this a better plugin

    Also, there is a plugin called Save Scores that will save a players scores as well as their cash amount. If you're looking for that additional functionality, you might want to take a look at that one.

    CHANGE LOG:
    Version 1.0
    - Initial release

    Version 1.1 - 1.3
    - Internal changes including translation file, cleaner code, and use of array.

    Version 1.4
    - Fixed the retrieval of saved cash amount from array and annotated code a bit.
    - Added translation file

    Version 1.4a
    - Removed handle for timer, not needed (thanks for suggestion databomb)

    Version 1.5
    - Changed from using array's to using a Trie - thanks for the heads up on that KyleS - it's a better suited data structure

    Version 1.6
    - Fixed possible bug where player could retain cash across map changes.

    INSTALLATION
    - Download the plugin and translation file. Place the NoSpecHopCash.smx into your sourcemod plugins folder - place the NoSPecHopCash.phrases.txt in your sourcemod translations folder
    Attached Files
    File Type: txt NoSpecHopCash.phrases.txt (221 Bytes, 655 views)
    File Type: sp Get Plugin or Get Source (NoSpecHopCash.sp - 1187 views - 6.7 KB)
    __________________
    View my Plugins | Donate

    Last edited by TnTSCS; 05-01-2013 at 10:43. Reason: Update from 1.5 to 1.6
    TnTSCS is offline
    sinblaster
    Grim Reaper
    Join Date: Feb 2010
    Location: Australia
    Old 05-24-2011 , 10:54   Re: [CS:S] No Spec Hop Cash
    Reply With Quote #2

    I could use this thanks man. I just need to find the time to try it. I'm so plugged in Im suffocating
    __________________
    Happy Happy Joy Joy

    sinblaster is offline
    fifipaldi
    Member
    Join Date: Apr 2011
    Old 05-28-2011 , 04:49   Re: [CS:S] No Spec Hop Cash
    Reply With Quote #3

    Hi. Nice plugin. I was looking exactly for the same thing, but i have one question. You said that the money will not change only if they are less than mp_startmoney. So my question is, if somebody go spec with 5000 lets say is he going to get money for the spec hop or no ?
    fifipaldi is offline
    TnTSCS
    AlliedModders Donor
    Join Date: Oct 2010
    Location: Undisclosed...
    Old 05-28-2011 , 11:16   Re: [CS:S] No Spec Hop Cash
    Reply With Quote #4

    if someone goes into spec with 5000, he will rejoin his team with 5000, but he'll get the team winning amount just like everyone else does. He won't get extra money than anyone else
    TnTSCS is offline
    databomb
    Veteran Member
    Join Date: Jun 2009
    Location: california
    Old 07-24-2011 , 20:11   Re: [CS:S] No Spec Hop Cash
    Reply With Quote #5

    Here's my modification on your plugin to make sure that people can't just type 'retry' in console to avoid the same thing. I seem to recall seeing this somewhere already but in case you find it worthwhile too: (untested yet)

    PHP Code:
    /* Plugin Template generated by Pawn Studio */

    #pragma semicolon 1

    #include <sourcemod>

    #define SPEC_VERSION "1.0"
    #define BUILDD __DATE__
    #define BULLDT __TIME__

    public Plugin:myinfo 
    {
        
    name "No Spec Hop Cash",
        
    author "TnTSCS modified by databomb",
        
    description "Prevents players from receiving mp_startmoney by spectate hopping",
        
    version SPEC_VERSION,
        
    url "http://forums.alliedmods.net/showthread.php?t=157593"
    }

    new 
    g_MoneyOffset;
    new 
    Handle:g_hStartMoney INVALID_HANDLE;
    new 
    Handle:gH_SteamList INVALID_HANDLE;
    new 
    g_hPlayersMoney[MAXPLAYERS+1];
    new 
    g_hPlayersDiffMoney[MAXPLAYERS+1];
    new 
    bool:FirstJoined[MAXPLAYERS+1];
    new 
    bool:PlayerSpec[MAXPLAYERS+1];

    public 
    OnPluginStart()
    {
        
        
    CreateConVar("sm_nospeccash_buildversion",SOURCEMOD_VERSION"This version of 'No Spec Hop Cash' was built on "FCVAR_PLUGIN);
        
    CreateConVar("sm_nospeccash_version"SPEC_VERSION"This version of 'No Spec Hop Cash'  "FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
        
        
    g_hStartMoney FindConVar("mp_startmoney");
        
    g_MoneyOffset FindSendPropInfo("CCSPlayer""m_iAccount");
        
        if (
    g_MoneyOffset != -1)
        {
            
    HookEvent("player_team"TeamChanged);
        }
        else
        {
            
    SetFailState("* FATAL ERROR: Failed to obtain offset for CCSPlayer::m_iAccount");
        }
        
    gH_SteamList CreateArray(22);
    }

    public 
    OnClientDisconnect(client)
    {
        if (
    IsClientInGame(client))
        {
            
    decl String:authString[20];
            
    GetClientAuthString(clientauthString20);
            if (
    FindStringInArray(gH_SteamListauthString) == -1)
            {
                
    PushArrayString(gH_SteamListauthString);
                
    PushArrayCell(gH_SteamListGetPlayerCash(client));
            }
        }
    }

    public 
    TeamChanged(Handle:event, const String:name[], bool:dontBroadcast)
    {
        if(
    GetEventBool(event,"disconnect"))
        {
            return;
        }
        else
        {
            new 
    client GetClientOfUserId(GetEventInt(event,"userid"));
            new 
    clientteam GetEventInt(event,"team"); //get the TeamID of the player
            
    if(FirstJoined[client]) //Check to see if a player is joining the game and picking their first team
            
    {
                
    FirstJoined[client] = false//After a player joins for the first time and picks a team, they are marked as NOT FirstJoined
                
    return;
            }
            else 
    //if FirstJoined = false
            
    {
                if(
    clientteam != 0//ensure team is spectate, t, or ct
                
    {
                    
    g_hPlayersMoney[client] = GetPlayerCash(client); //find out what the player's current cash is
                    
    if(g_hPlayersMoney[client] < GetConVarInt(g_hStartMoney)) //if player's cash is less than mp_startmoney
                    
    {
                        
    g_hPlayersDiffMoney[client] = GetConVarInt(g_hStartMoney) - g_hPlayersMoney[client]; //figure out the difference between player's cash and mp_startmoney
                    
    }
                    else
                    {
                        
    g_hPlayersDiffMoney[client] = 0//set to 0 since player's money is greater than mp_startmoney
                    
    }
                    if(
    clientteam == 1//if player is on team 1 for spectate
                    
    {
                        
    PlayerSpec[client] = true//Set player as being in spectate
                        //PrintToChat(client,"\x04[\x03SpecHopCash\x04]\x01 When you join your team again, your cash will be restored to %i",g_hPlayersMoney[client]);
                        
    return;            
                    }
                    if(
    clientteam != 1//player joined t or ct
                    
    {
                        if(
    PlayerSpec[client]) //if player is marked as spectate
                        
    {
                            if(
    g_hPlayersDiffMoney[client] != 0//check if there is a PlayersDiffMoney value, if so, we will subtract that amount from the player's cash
                            
    {
                                
    //PrintToChat(client,"\x04[\x03SpecHopCash\x04]\x01 When you spawn, you will be fined for spectate hopping in the amount of %i",g_hPlayersDiffMoney[client]);
                                
    SetPlayerCash(client,g_hPlayersMoney[client] - g_hPlayersDiffMoney[client]); //subtract the difference from the player's cash to preserve the cash amount when they went into spectate
                            
    }
                            
    PlayerSpec[client] = false//player joined a team, mark as not in spectate
                        
    }
                    }
                }
            }
        }
    }


    public 
    OnMapEnd()
    {
        for(new 
    0MAXPLAYERS 1i++)
        {
            
    FirstJoined[i] = true;
            
    PlayerSpec[i] = false;
            
    g_hPlayersDiffMoney[i] = 0;
        }
    }

    public 
    OnMapStart()
    {
        for(new 
    0MAXPLAYERS 1i++)
        {
            
    FirstJoined[i] = true;
            
    PlayerSpec[i] = false;
            
    g_hPlayersDiffMoney[i] = 0;
        }
        
        
    ClearArray(gH_SteamList);
    }

    public 
    OnClientAuthorized(client,const String:auth[])
    {
        new 
    indexNum FindStringInArray(gH_SteamListauth);
        if (
    indexNum == -1)
        {
            
    FirstJoined[client] = true;
            
    g_hPlayersDiffMoney[client] = 0;
            
    PlayerSpec[client] = false;
        }
        else
        {
            
    FirstJoined[client] = false;
            
    PlayerSpec[client] = true;
            new 
    playerCash GetArrayCell(gH_SteamListindexNum20);
            
    g_hPlayersDiffMoney[client] = GetConVarInt(g_hStartMoney) - playerCash;
        }
    }

    public 
    GetPlayerCash(entity)
    {
        return 
    GetEntData(entityg_MoneyOffset);
    }

    public 
    SetPlayerCash(entityamount)
    {
        
    SetEntData(entityg_MoneyOffsetamount4true);

    __________________
    databomb is offline
    TnTSCS
    AlliedModders Donor
    Join Date: Oct 2010
    Location: Undisclosed...
    Old 07-25-2011 , 02:12   Re: [CS:S] No Spec Hop Cash
    Reply With Quote #6

    thank you for the improvement
    TnTSCS is offline
    SmackDaddy
    Veteran Member
    Join Date: Oct 2009
    Old 08-11-2011 , 00:03   Re: [CS:S] No Spec Hop Cash
    Reply With Quote #7

    Was databomb's code added to the plugin?

    Plus, I am being told it's not working on the current CSS Windows server .... I had one of my admins test it and he said he can still bhop spec and get cash....

    Last edited by SmackDaddy; 08-11-2011 at 00:23.
    SmackDaddy is offline
    TnTSCS
    AlliedModders Donor
    Join Date: Oct 2010
    Location: Undisclosed...
    Old 08-11-2011 , 01:24   Re: [CS:S] No Spec Hop Cash
    Reply With Quote #8

    I will work on this tomorrow... as I said in a different thread, the wife claimed the PC for the night - I don't have access to my stuffs

    But I'll implement databomb's code, test it, and post if it's working. I'm also going to fix the one bug I posted in OP under the NOTES

    in the meantime, exvel's plugin is a great one - http://forums.alliedmods.net/showthread.php?p=660327

    It does more than mine will, so if you don't want/need all that it does, wait until tomorrow and I'll have this one fixed

    Last edited by TnTSCS; 08-11-2011 at 01:27.
    TnTSCS is offline
    SmackDaddy
    Veteran Member
    Join Date: Oct 2009
    Old 08-11-2011 , 01:42   Re: [CS:S] No Spec Hop Cash
    Reply With Quote #9

    Will wait, thank you.
    SmackDaddy is offline
    TnTSCS
    AlliedModders Donor
    Join Date: Oct 2010
    Location: Undisclosed...
    Old 08-11-2011 , 18:41   Re: [CS:S] No Spec Hop Cash
    Reply With Quote #10

    okay... I'm not going to update the OP with this version because I think with the help of databomb, we can get the feature where when a player types retry they will have their old cash restored instead of getting the mp_startmoney...

    I tried the code that databomb posted above, but it didn't work... I don't know why

    The attached plugin works and was tested on a windows server. I fixed the issue where after you rejoined a team, it showed that you had the full mp_startmoney even though you went to spec with less than that. I utilized a timer

    Maybe databomb will help with the Array stuff to address those players that use "retry"... otherwise, the plugin SaveScores is a really good one

    Last edited by TnTSCS; 09-14-2011 at 02:51. Reason: removed attachment, see OP for latest version
    TnTSCS 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 07:14.


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