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

Help with using Strings/LogToFile


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Roachy
Member
Join Date: Feb 2008
Old 02-27-2008 , 03:18   Help with using Strings/LogToFile
Reply With Quote #1

Hi everyone, I just recently got into Sourcemod scripting to try to help keep out hackers. I've just got a few syntax questions, and a couple overall knowledge questions.

First off, I want to use the LogToFile function, but I don't fully understand its syntax. Here is the code I'm working with:

Code:
#include <sourcemod>

public Plugin:myinfo = {
        name = "Cyber-Cafe Kicker",
        author = "adapted by [GA] Roachy",
        description = "Kicks all players using steam cyber cafe accounts, which are supposedly of this format: STEAM_x:x:7xxxxxx",
        version = "1.0",
        url = "http://www.goochassassins.org/"
}

// STEAM_x:x:7xxxxxx http://en.wikipedia.org/wiki/Steamid#Caveat_about_Cyber_Caf.C3.A9_Account
public OnClientAuthorized(client, const String:auth[]) {

        // If SteamID is 17 characters long (a.k.a. if number section is 7 characters long (because STEAM_x:x: is 10 characters))
        if (strlen(auth) == 17) {

                // If the first two numbers are 7s (STEAM_x:x:XXxxxxx)
                // The above wikipedia article says 7xxxxxx, but we've found that almost all of our hackers are using 77xxxxx
                if ((auth[10] == '7') && (auth[11] == '7')) {

                        // Custom exceptions
                        if StrEqual(auth[], 'STEAM_0:0:7759438') {
                                // User = Falcon, do nothing
                                LogToFile('/home/gooch/games/srcds/dod/cafekicker.log', FORMAT???, "auth[] was allowed as an exception");
                        }

                        // Everyone else
                        else {
                                KickClient(client, "%s", "Steam Cyber-Cafe accounts are not allowed here.");
                                LogToFile('/home/gooch/games/srcds/dod/cafekicker.log', FORMAT???, "auth[] was disallowed.");
                        }
                }
        }
}
So, what do I use for the format in the LogToFile function above in red? The API defines it as:

Quote:
LogToFile
Syntax:
native LogToFile(const String:file[], const String:format[], any:...);

Usage:

file File to write the log message in.
format String format.
... Format arguments.

Notes:
Logs a message to any file. The log message will be in the normal SourceMod format, with the plugin logtag prepended.

Return:
No return.

On error / Errors:
File could not be opened/written.
Secondly, will the above auth[] variable work like that, or do I need a $ or something?

Thirdly, does this script look at least half-way decent to you readers? Not only is this my first time scripting in SourcePawn (though I'm pretty good at most similar languages), I've heavily modified this, and I don't even know where it came from. It was working alright (or so it seemed) until I edited it again to add in the exceptions. After I did that the exceptions seemed to work, but the rest of it seemed to fail. And I've edited it again since that to try to make it easier to read and more sensible. Anyway the above is what I've come up with, and I'm just hoping for a once over by a few more experienced SourcePawners.

Oh, and one last thing, We really have noticed a solid pattern of hackers using STEAM_X:X:77XXXXX IDs, and in conjunction with the wikipedia article cited in the code, I'm strongly of the opinion that this is the right way to go. We've already noticed a pretty big drop (until I broke it again) in hacker/troublemaker activity using this script. But does anyone have any more info on this Steam caveat? Any more specifics on the supposed Cafe Account ID scheme? Just wondering...

Thanks for any input guys,
== Roachy
Roachy is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 02-27-2008 , 04:51   Re: Help with using Strings/LogToFile
Reply With Quote #2

1. Format is what the string is that is to be logged.

Code:
LogToFile('/home/gooch/games/srcds/dod/cafekicker.log', "%s was allowed as an exception", auth);
2. No, look at the example I provided.
3. The script looks decent. It's pretty basic, and could be improved a bit to be more formal, but it's good enough to get the job done.
bl4nk is offline
sfPlayer
Senior Member
Join Date: Dec 2007
Location: Germany
Old 02-27-2008 , 07:48   Re: Help with using Strings/LogToFile
Reply With Quote #3

The Wikipedia article is wrong, many active players' SteamIDs including mine are within the range 7M-8M and are definitely no cyber cafe accounts.
sfPlayer is offline
BAILOPAN
Join Date: Jan 2004
Old 02-27-2008 , 07:57   Re: Help with using Strings/LogToFile
Reply With Quote #4

That sounds like random nonsense to me as well, I wouldn't trust Wikipedia there
__________________
egg
BAILOPAN is offline
Roachy
Member
Join Date: Feb 2008
Old 02-27-2008 , 22:30   Re: Help with using Strings/LogToFile
Reply With Quote #5

Thanks, that coupled with a few syntax corrections seemed to get me going.

Yeah, we've always been skeptical about the legitimacy of the claim about cyber cafe accounts being 7xxxxxx. However, truly the last onslaught of hackers we saw recently (which has been the worst to date, probably attributed to some breakthroughs in mygot-related hacking softwares) really proved to us that the vast majority of offending steam accounts were 7-digit SteamIDs starting with two 7s. So we'll probably keep this up. And we can always add in exceptions for the others.

Honestly, I don't like doing it, but given Valve's incompetency in anti-hacking solutions, coupled with the VAC-unbannable cybercafe account crap, we absolutely need a solution, and this certainly stopped a huge wave of mygotters in their tracks.

Oh well. Thanks again.
Roachy is offline
Saxywolf
Junior Member
Join Date: Feb 2008
Old 02-27-2008 , 23:10   Re: Help with using Strings/LogToFile
Reply With Quote #6

We've recently had the 7xxx discussion in the Sourceforts forums too. Quite a few of the regular players start with 7, however I did see someone mention that the IPs are available for many cafes. What if you make a list of cyber cafe IPs and block their ranges instead of 7xxx Steam IDs?
Saxywolf is offline
sfPlayer
Senior Member
Join Date: Dec 2007
Location: Germany
Old 02-28-2008 , 07:10   Re: Help with using Strings/LogToFile
Reply With Quote #7

1.7% of the SteamIDs in my SUM-DB match STEAM_x:x:77xxxxx including an admin.
6.9% and 6 admins match STEAM_x:x:7xxxxxx

Last edited by sfPlayer; 02-28-2008 at 07:15.
sfPlayer 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 05:19.


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