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