AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [INC] loghelper (updated 2010-05-27) (https://forums.alliedmods.net/showthread.php?t=100084)

psychonic 08-12-2009 09:27

[INC] loghelper (updated 2010-05-27)
 
1 Attachment(s)
This is an include I wrote for use with my SuperLogs plugin set. It has stocks for many HL Standard log line formats, and also gets around the current limitations of Sourcemod's %L format operator and FormatUserLogText() function (not including team name on log line). This makes it very easy to add HLstatsX(:CE) or Psychostats support to a plugin.

All included functions are stocks so they are only compiled in with the plugin if uses, or feel free to copy individual functions so as to not create a dependency on the include.

Note: you must call the GetTeams() function during OnMapStart() to correctly cache team names.

PHP Code:

// Caches team names. Run during OnMapStart()
stock GetTeams(bool:insmod false)

// Player Event (Ex. "player<userid><steamid><team>" triggered "something" (position "55 -23 0") (property1 "value1")
stock LogPlayerEvent(client, const String:verb[], const String:event[], bool:display_location false, const String:properties[] = "")

// Player-Player Event (similar to player event, ex. "player" triggered "something" against "player2")
stock LogPlyrPlyrEvent(clientvictim, const String:verb[], const String:event[], bool:display_location false, const String:properties[] = "")

// Kill (logs a kills in regular format, ex. "player1" killed "player2" with "weapon")
stock LogKill(attackervictim, const String:weapon[], bool:display_location false, const String:properties[] = "")

// Suicide (logs a suicide in regular format, ex. "player" commited suicide with "weapon")
stock LogSuicide(victim, const String:weapon[], bool:display_location false, const String:properties[] = "")

// Team Event (Ex. Team "teamname" triggered "something")
stock LogTeamEvent(team, const String:verb[], const String:event[], const String:properties[] = "")

// Team change (Ex. "player" joined team "teamname")
stock LogTeamChange(clientnewteam, const String:properties[] = "")

// Role/Class change (Ex. "player" changed role to "class1")
stock LogRoleChange(client, const String:role[], const String:properties[] = "")

// Psychostats "KTRAJ" location log line
stock LogPSKillTraj(attackervictim, const String:weapon[])

stock LogKillLoc(attackervictim)
stock LogMapLoad()
stock IsValidPlayer(client

Updated 2015-12-21
- Replaced instances of deprecated GetClientAuthString
- Converted to use SourcePawn 1.7 Transitional Syntax
- Changed IsValidPlayer function to be static to avoid conflict when included in a plugin with function of same name.

Updated 2009-11-09
- Fixed formatting of position logging for plyrplyr events
- Added version define (starting with "#define LOGHELPER_VERSION 2")

Updated 2010-2-13
- Added Psychostats KTRAJ logging

nightrider 09-23-2009 20:36

Re: [INC] loghelper
 
I can't wait to try this and the SuperLogs plugin

Thank You :)

Nicolayka 10-12-2011 14:53

Re: [INC] loghelper (updated 2010-05-27)
 
Thank You :)

Peace-Maker 12-22-2011 02:20

Re: [INC] loghelper (updated 2010-05-27)
 
Seeing lots of error spam like that lately in css.
Code:

L 12/22/2011 - 03:17:50: [SM] Native "GetTeamName" reported: Team index 0 is invalid
L 12/22/2011 - 03:17:50: [SM] Displaying call stack trace for plugin "superlogs-css.smx":
L 12/22/2011 - 03:17:50: [SM]  [0]  Line 18, C:\Users\nshastings\Desktop\sm\11scripting\13scripting\include\loghelper.inc::GetTeams()
L 12/22/2011 - 03:17:50: [SM]  [1]  Line 160, superlogs-css.sp::OnMapStart()


Peace-Maker 08-18-2013 13:22

Re: [INC] loghelper (updated 2010-05-27)
 
1 Attachment(s)
Quote:

Originally Posted by Peace-Maker (Post 1617527)
Seeing lots of error spam like that lately in css.
Code:

L 12/22/2011 - 03:17:50: [SM] Native "GetTeamName" reported: Team index 0 is invalid
L 12/22/2011 - 03:17:50: [SM] Displaying call stack trace for plugin "superlogs-css.smx":
L 12/22/2011 - 03:17:50: [SM]  [0]  Line 18,  C:\Users\nshastings\Desktop\sm\11scripting\13scripting\include\loghelper.inc::GetTeams()
L 12/22/2011 - 03:17:50: [SM]  [1]  Line 160, superlogs-css.sp::OnMapStart()


Here's a version, which doesn't call GetTeamName on index 0 and just statically names team 0 "Unassigned".

psychonic 08-18-2013 13:23

Re: [INC] loghelper (updated 2010-05-27)
 
Quote:

Originally Posted by Peace-Maker (Post 2016398)
Here's a version, which doesn't call GetTeamName on index 0 and just statically names team 0 "Unassigned".

That sounds like a regression in SDKTools. GetTeamName with an index of 0 should be fine.

Rippii 01-21-2015 18:03

Re: [INC] loghelper (updated 2010-05-27)
 
where do i put the .inc file

Drixevel 01-21-2015 18:05

Re: [INC] loghelper (updated 2010-05-27)
 
Quote:

Originally Posted by Rippii (Post 2252111)
where do i put the .inc file

...Inside of the include folder under scripting?

Sunnych 03-10-2015 20:21

[INC] loghelper (updated 2010-05-27) ? Help!
 
CS:GO server version 171, instance idx 1
sm version
SourceMod Version Information:
SourceMod Version: 1.6.3-dev+4577
SourcePawn Engine: SourcePawn 1.2, jit-x86 (build 1.6.3-dev+4577)
SourcePawn API: v1 = 4, v2 = 6
Compiled on: Sep 20 2014 10:36:45
Built from: https://github.com/alliedmodders/sou...commit/5c13a0b
Build ID: 4577:5c13a0b
http://www.sourcemod.net/
meta list
Listing 4 plugins:
[01] SourceMod (1.6.3-dev+4577) by AlliedModders LLC
[02] CS Tools (1.6.3-dev+4577) by AlliedModders LLC
[03] SDK Tools (1.6.3-dev+4577) by AlliedModders LLC
[04] SDK Hooks (1.6.3-dev+4577) by AlliedModders LLC
sm exts list
[SM] Displaying 14 extensions:
[01] Automatic Updater (1.6.3-dev+4577): Updates SourceMod gamedata files
[02] Webternet (1.6.3-dev+4577): Extension for interacting with URLs
[03] CS Tools (1.6.3-dev+4577): CS extended functionality
[04] BinTools (1.6.3-dev+4577): Low-level C/C++ Calling API
[05] SDK Tools (1.6.3-dev+4577): Source SDK Tools
[06] Top Menus (1.6.3-dev+4577): Creates sorted nested menus
[07] GeoIP (1.6.3-dev+4577): Geographical IP information
[08] Client Preferences (1.6.3-dev+4577): Saves client preference settings
[09] SQLite (1.6.3-dev+4577): SQLite Driver
[10] SDK Hooks (1.6.3-dev+4577): Source SDK Hooks
[11] cURL Extension (1.3.0.0): cURL Extension
[12] Regex (1.6.3-dev+4577): Provides regex natives for plugins
[13] Socket (3.0.1): Socket extension for SourceMod
[14] <FAILED> file "steamtools.ext.dll": ═х эрщфхэ єърчрээ√щ ьюфєы№.
sm plugins list
[SM] Listing 31 plugins:
01 "Admin File Reader" (1.6.3-dev+4577) by AlliedModders LLC
02 "Admin Help" (1.6.3-dev+4577) by AlliedModders LLC
03 "Admin Menu" (1.6.3-dev+4577) by AlliedModders LLC
04 "Advertisements" (0.6 CSGO-1.1) by Tsunami (CSGO FIX ╨д╨╡╨╜╨╕╨║╤Б)
05 "Anti-Flood" (1.6.3-dev+4577) by AlliedModders LLC
06 "Basic Ban Commands" (1.6.3-dev+4577) by AlliedModders LLC
07 "Basic Chat" (1.6.3-dev+4577) by AlliedModders LLC
08 "Basic Comm Control" (1.6.3-dev+4577) by AlliedModders LLC
09 "Basic Commands" (1.6.3-dev+4577) by AlliedModders LLC
10 "Basic Info Triggers" (1.6.3-dev+4577) by AlliedModders LLC
11 "Basic Votes" (1.6.3-dev+4577) by AlliedModders LLC
12 "CD Announcer" (2.9) by Fredd, gH0sTy, MOPO3KO
13 "Client Preferences" (1.6.3-dev+4577) by AlliedModders LLC
14 "CS:GO Admin ESP" (2.1) by Root
15 "cURL self test" (1.1.0.0) by Raydan
16 "Custom Player Skins (Core)" (1.2.0) by Mitchell, Root
17 "Fun Commands" (1.6.3-dev+4577) by AlliedModders LLC
18 "Fun Votes" (1.6.3-dev+4577) by AlliedModders LLC
19 "HLstatsX CE Ingame Plugin" (1.6.19) by psychonic
20 <Error> "[INS] Logger" (1.2.0) by Jared Ballou
21 "listen socket example" (1.0.1) by Player
22 "Player Commands" (1.6.3-dev+4577) by AlliedModders LLC
23 "Reserved Slots" (1.6.3-dev+4577) by AlliedModders LLC
24 "Resetscore+" (1.4.1) by AlmazON
25 "socket extension selftest" (1.1.0) by Player
26 "Knife Upgrade" (2.5.2) by Klexen
27 "socket example" (1.1.0) by Player
28 "Sound Commands" (1.6.3-dev+4577) by AlliedModders LLC
29 "SuperLogs: CSS" (1.2.4) by psychonic
30 "SwapTeam" (1.2.6) by Rogue - Originally by MistaGee
31 "Updater" (1.2.1) by GoD-Tony
Load Errors:
[INS] Logger: Error detected in plugin startup (see error logs)
how to fix it

psychonic 03-10-2015 20:59

Re: [INC] loghelper (updated 2010-05-27) ? Help!
 
Quote:

Originally Posted by Sunnych (Post 2272386)
Load Errors:
[INS] Logger: Error detected in plugin startup (see error logs)
how to fix it

Try posting in the thread of that [INS] Logger plugin.

Nerus 12-21-2015 04:54

Re: [INC] loghelper (updated 2010-05-27)
 
1 Attachment(s)
Hi, I attached new fixed version working correct with SM 1.7.3.

Changes: deprecated GetClientAuthString to GetClientAuthId.

Regards,
Nerus.

psychonic 12-21-2015 07:46

Re: [INC] loghelper (updated 2010-05-27)
 
Quote:

Originally Posted by Nerus (Post 2374722)
Hi, I attached new fixed version working correct with SM 1.7.3.

Changes: deprecated GetClientAuthString to GetClientAuthId.

Code:

        //if (!GetClientAuthString(client, player_authid, sizeof(player_authid)))
        if(GetClientAuthId(client, AuthId_Steam3, player_authid, sizeof(player_authid)))

It looks like you negated the check here, so everyone's auth string in the log will be "UNKNOWN" (or whatever is in the uninitialized buffer on failure). Also, to match the game's own logging on every game, it should be AuthId_Engine instead of AuthId_Steam3.

There are 10 other instances to change as well, not just that one. If it wasn't throwing warnings, it's because stock functions are only compiled in if used, else the compiler ignores them.

psychonic 12-21-2015 11:28

Re: [INC] loghelper (updated 2010-05-27)
 
Quote:

Originally Posted by psychonic (Post 2374760)
Code:

        //if (!GetClientAuthString(client, player_authid, sizeof(player_authid)))
        if(GetClientAuthId(client, AuthId_Steam3, player_authid, sizeof(player_authid)))

It looks like you negated the check here, so everyone's auth string in the log will be "UNKNOWN" (or whatever is in the uninitialized buffer on failure). Also, to match the game's own logging on every game, it should be AuthId_Engine instead of AuthId_Steam3.

There are 10 other instances to change as well, not just that one. If it wasn't throwing warnings, it's because stock functions are only compiled in if used, else the compiler ignores them.

I've updated the first post now with all of the GetClientAuthString instances replaced properly.

mrkos9i4ok 04-14-2017 14:09

Re: [INC] loghelper (updated 2010-05-27)
 
help pls
Error:
//// smctf.sp
// C:\Users\Faust-PC\Desktop\═ютр* яряър\include\loghelper.inc(6) : error 010: invalid function or declaration
// C:\Users\Faust-PC\Desktop\═ютр* яряър\include\loghelper.inc(10) : error 001: expected token: ";", but found "-identifier-"
// C:\Users\Faust-PC\Desktop\═ютр* яряър\include\loghelper.inc(10) : error 017: undefined symbol "insmod"
// C:\Users\Faust-PC\Desktop\═ютр* яряър\include\loghelper.inc(10) : error 010: invalid function or declaration
// C:\Users\Faust-PC\Desktop\═ютр* яряър\include\loghelper.inc(10 -- 12) : fatal error 127: too many error messages on one line
//
// Compilation aborted.
// 5 Errors.
//
// Compilation Time: 0,8 sec
// ----------------------------------------


All times are GMT -4. The time now is 11:56.

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