• SteamTeam
    3 replies, posted
SteamTeam - Steam Group Membership Award System Written by Buzzkill -- thehundredacrebloodbath.com [url]https://github.com/100acrebb/thab_tools[/url] (I apologize for the name. It's stupid, but it stuck) SteamTeam is a framework for detecting player membership to a Steam group and awarding in-game bonuses as a result. It is currently a work in progress, and support for multiple groups and multiple bonus types is forthcoming, as well as separating out and improving the configuration of groups/bonuses. An example configuration is included in source, with notes on important values. This is probably the best approach to configuration documentation for now. Membership is checked upon user initial spawn as well as every 10 mins. NOTE: IT CURRENTLY ONLY SUPPORTS A SINGLE GROUP AND A SINGLE BONUS (Pointshop 1 points as well as a configurable callback -- see inline notes in source below). [CODE] -- One group for now STEAMTEAM.Groups[1] = {} -- URL of the target group STEAMTEAM.Groups[1].URL = "http://steamcommunity.com/groups/100acrebb" -- A configurable callback. In this example, I set a networked boolean if the user is a member of the above group. -- I'm using this in other areas - for example, a custom icon in HatsChat STEAMTEAM.Groups[1].OnIsMember = function(self, ply) ply:SetNWBool( "THABMember", true ) end STEAMTEAM.Groups[1].Bonus = {} -- One bonus for now STEAMTEAM.Groups[1].Bonus[1] = {} -- The bonus type (PSPOINTS only, for now) STEAMTEAM.Groups[1].Bonus[1].Type = "PS1POINTS" -- The number of points STEAMTEAM.Groups[1].Bonus[1].Amount = 10000[/CODE] [url]https://github.com/100acrebb/thab_tools/blob/master/lua/autorun/server/steamteam.lua[/url]
Great job, however it seems that the block on getting the total pages and the SteamID64s looks very inefficient and looks like it could cause some bugs. Maybe you should read up on [URL="http://wiki.garrysmod.com/page/Patterns"]Lua patterns[/URL], they are very useful. For example, this is how I'm getting the total pages and the SteamID64s while utilising Lua patterns: [lua]local str2 = [[ <memberCount>497</memberCount> <totalPages>1</totalPages> <currentPage>1</currentPage> <startingMember>0</startingMember> ]] print(tonumber(str2:sub(str2:find("<totalPages>(%d-)</totalPages>")):gsub("</?totalPages>",""))) local str = [[ <steamID64>76561198083092162</steamID64> <steamID64>76561198083092162</steamID64> <steamID64>76561198083092162</steamID64> <steamID64>76561198083092162</steamID64> ]] for i in str:gmatch("<steamID64>(.-)</steamID64>") do print(i) end[/lua] [quote=Output] 1 76561198083092162 76561198083092162 76561198083092162 76561198083092162 [/quote]
Yeah, it definitely takes some liberties. Part of that was borne from 3am frustration at the Steam API and it's kind of damned if you do, damned if you don't options for getting player membership to a group. I blew through some of the parsing just to get it done, but it could have been smarter. I'll definitely be revising, and will include your direction here. Thanks.
Commits on May 25, 2016 @THABBuzzkill Unf*cked the parsing logic. THABBuzzkill committed a minute ago
Sorry, you need to Log In to post a reply to this thread.