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

Scripting for first time, have some questions.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jstn7477
Senior Member
Join Date: Mar 2011
Location: Florida, USA
Old 09-22-2011 , 11:48   Scripting for first time, have some questions.
Reply With Quote #1

Hey guys, I figured I would try to start learning how to script and make something that I deem useful for my servers. Basically, most hackers that come on seem to use the same retarded hacks nowadays (basically a speedhack and a fast name changing script to rename themselves every second to a legitimate player and try to avoid being banned). So, I'm looking to write something that either: 1) keeps track of all the the clientname, clientauthid, clientuserid (is that the one displayed in the ban menu next to client names?) and maybe even the player ips, then when a client changes their name or something else, it compares the new data to the existing data and acknowledges a discrepancy and prints to chat or 2) directly detects name changes and PrintToChatAll the clientname, clientauthid and clientuserid of the name changing client for easy banning of the right player.

Am I trying to do something overly complex with this? I already have some basic code down that prints the user's name and SteamID upon OnClientSettingsChanged() but that fires a ton of times on each map change and doesn't always mean their name changed.

If option 1 is the right thing to do, how would I store the data? I would think that OnMapStart() I would need to collect every client's data, as well as when a new player enters the server mid-round, and purge all the data OnMapEnd() or selectively when a player disconnects.

Sorry if some of this seems stupid, wrong, etc. but I really want to learn how to get some basic scripting down so I can make some cool or useful plugins.

Initial plugin code so far:

PHP Code:
#include <sourcemod>

#pragma semicolon 1

#define PLUGIN_VERSION "1.0"

// Plugin definitions
public Plugin:myinfo 
{
    
name "My First Plugin",
    
author "Jstn7477",
    
description "Test lol",
    
version PLUGIN_VERSION,
    
url "http://trashedgamers.org/"
};

new 
MAX_PLAYERS;

public 
OnMapStart(){
    
MAX_PLAYERS GetMaxClients();
}


public 
OnClientSettingsChanged(client){
        if(
client != 0){
            
decl String:clientName[64];
            
GetClientName(client,clientName,64);
            
            
decl String:clientAuthId[64];
            
GetClientAuthString(client,clientAuthId,64);
            
            
PrintToChatAll("%s [%s] changed their name."clientNameclientAuthId);    
    }

__________________
Yo , I heard you like , so I put a in your so you can while you .
Jstn7477 is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 09-22-2011 , 12:12   Re: Scripting for first time, have some questions.
Reply With Quote #2

This should give you an idea.
PHP Code:
public OnClientSettingsChanged(client)
{
    if (!
IsClientInGame(client))
        return;

    static 
String:oldName[MaxClients 1][32];
    static 
String:newName[32]; // Felt like using static rather than decl
    
GetClientName(clientnewNamesizeof newName);

    if (
StrEqual(newNameoldName[client]))
        return;

    
oldName[client] = newName;

    
// Name changed

__________________

Last edited by hleV; 09-22-2011 at 14:06.
hleV is offline
pheadxdll
AlliedModders Donor
Join Date: Jun 2008
Old 09-22-2011 , 12:17   Re: Scripting for first time, have some questions.
Reply With Quote #3

There's tons of name change plugins, check them out for reference.
__________________
pheadxdll is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-22-2011 , 12:18   Re: Scripting for first time, have some questions.
Reply With Quote #4

If you just want to track when they change names, hook the player_changename event, which the server fires every time a person changes names.

Having said that, there are (at least) three plugins out there already to deal with people who change names quickly. The first is twistedpanda's [OB] Hide Name. The second is my Name Change Punisher. The third is SourceMod Anti-Cheat's recent dev builds, r222 and later.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Jstn7477
Senior Member
Join Date: Mar 2011
Location: Florida, USA
Old 09-22-2011 , 12:31   Re: Scripting for first time, have some questions.
Reply With Quote #5

Thanks for the quick responses everyone.

It looks like Powerlord's Name Change Punisher is the closest thing I wanted, and I'm surprised I didn't even see it before. Also, thanks for finding the event for player namechanges, as I was wondering how the heck the game kept track of those.

I think I'll look at the source code for NCP and see how it works so maybe I can experiment with some other stuff. Thanks again!
__________________
Yo , I heard you like , so I put a in your so you can while you .
Jstn7477 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 08:11.


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