PDA

View Full Version : [IDEA] Allow only players with specific amount of time spent in game


Avaray
12-22-2011, 06:14
So idea is - Create a server for players with long internship.
Is it possible to create plugin which verifies time spent in a specific game?

If player have less than XXX hours in game - he will be rejected from server.
And he will receive message "You must have more than XXX hours in XXX game to play on this server"

If player have more than XXX hours - He will be connected.

Options to set:
- game name / ID
- required number of hours in this game

TnTSCS
12-22-2011, 10:39
hmm... it's possible, but how would I ever get XXX hours on your server if, on my first time being there I'm kicked for not having enough hours spent on your server ??

That's like trying to get a credit card, but the company says you have to first have a credit card with them to get a second one and they don't give a card to anyone unless they already have a card, so, no credit = no credit

Avaray
12-22-2011, 10:48
I mean XXX hours in specific game - like TF2, CSS... etc.

TnTSCS
12-22-2011, 10:51
oooohhhh... ya, that makes sense :)

That's a good idea... keep the noobs out and the hackers with new accounts :)

I wonder if using the steamtools extension would work... looking now

...:: TnT Edit ::...

Indeed, it appears it does...
native Steam_RequestGameplayStats();
forward Steam_GameplayStats(rank, totalConnects, totalMinutesPlayed);

if I find time, I'll work on it - if someone else has time available, maybe they'll post one first... but this sounds like a good idea and nice use of the SteamTools extension :)

Avaray
12-22-2011, 12:34
It would be beautifully :)

McFlurry
12-22-2011, 13:25
More info can be retrieved with sockets/curl by getting a players xml stats page for a game. Info here (https://partner.steamgames.com/documentation/community_data). Though it seems my play time for L4D2 is off by 300 hours. That might be because I play often when I'm offline, which means it could be inaccurate.

Dr. McKay
12-27-2011, 22:51
oooohhhh... ya, that makes sense :)

That's a good idea... keep the noobs out and the hackers with new accounts :)

I wonder if using the steamtools extension would work... looking now

...:: TnT Edit ::...

Indeed, it appears it does...
native Steam_RequestGameplayStats();
forward Steam_GameplayStats(rank, totalConnects, totalMinutesPlayed);

if I find time, I'll work on it - if someone else has time available, maybe they'll post one first... but this sounds like a good idea and nice use of the SteamTools extension :)

I just checked, and unfortunately, that requests the gameplay stats of the server, not a client. It gives the rank of the server, the total connects on the server, and probably the server's total uptime.

TnTSCS
12-27-2011, 23:10
ya, I was messing with it and couldn't get player stats from that extension... have you tried the method McFlurry posted about? The players would have to have a public profile though... mine is set to friends only so it doesn't show my time played.

public example:
http://steamcommunity.com/profiles/76561197968575517/?xml=1

my profile (friends only):
http://steamcommunity.com/profiles/76561197967464260/?xml=1

TnTSCS
01-04-2012, 11:11
I think I might delve into this... Not much experience with web or xml, much less using those two extensions... but it looks like a lot of information can be obtained... as long as the profiles are public

Avaray
02-11-2012, 08:55
Little Bump?

Phireman
02-11-2012, 09:11
this is good idea

TnTSCS
02-11-2012, 11:39
The only issue is when profiles are private you won't get the detailed info needed to effect the ban appropriately... maybe Dr McKay worked on it a bit?

Dr. McKay
02-11-2012, 14:10
The only issue is when profiles are private you won't get the detailed info needed to effect the ban appropriately... maybe Dr McKay worked on it a bit?

Nope. I don't see this happening at all. The only way that you can do this afaik is to parse their gameplay stats XML page, but they could just set their profile to private.

Blah91
02-17-2012, 16:51
If profile is set to private = rejected with message "You must set your profile public to play on this server."

TnTSCS
02-17-2012, 16:56
this is true... you could do that...

I have 0 experience with reading XML with sourcemod and parsing out the fields needed... but I'll start playing around with it.

McFlurry
02-17-2012, 17:31
Have you looked at the TinyXML Wrapper extension? It should work for this.

TnTSCS
02-17-2012, 19:27
I'll check that out, thank you

Peace-Maker
02-17-2012, 19:42
Here's a raw draft version implementing that idea.
One should add a cache (sqlite?) and remember the persons who had enough time already to reduce the load on steamcommunity.com :)

One convar:
sm_hoursplayed_minplaytime - How many minutes do players need to have played in order to join?

Players are kicked, if they don't have enough time on record or we're unable to read the profile (private/not setup).

Ah, needs the SteamTools (https://forums.alliedmods.net/showthread.php?t=170630) and TinyXml (http://forums.alliedmods.net/showthread.php?p=1263440) extensions installed.

McFlurry
02-17-2012, 19:51
Need to port that so it uses cURL instead of SteamTools, as SteamTools is only usable on Source 2009.
Something helpful (http://forums.alliedmods.net/showpost.php?p=1621855&postcount=307l)

TnTSCS
02-28-2012, 17:27
I like this plugin and I like what I learned from it - thank you :)

Peace-Maker
02-29-2012, 05:41
You actually use it?

TnTSCS
02-29-2012, 10:46
no, I don't use it on the server - I used it to build my knowledge base on TinyXml and Steamtools.

I changed your original post because your original post only looks at the last 2 weeks worth of time, and not the total time.

I added a third layer for XML to get the totalplayed element.

Anyways, I like the ability to be able to query 'public' profiles and be able to pass that data on player connect.

I'm working on learning the SQL part of SM so I can store/update data on players as they join so as to not have to continue to query for the same person.

Peace-Maker
02-29-2012, 13:35
What total playtime? The <summary><timeplayed (http://steamcommunity.com/profiles/76561198018153423/stats/CS:S/?xml=1)> element isn't available in all games. TF2 (http://steamcommunity.com/profiles/76561198018153423/stats/TF2/?xml=1) doesn't have that e.g. That's why i used hoursPlayed. Is there an element i didn't see?

I don't see any use for it currently, but maybe there'll be some use :P

TnTSCS
02-29-2012, 14:30
for TF2 it would be <secondsPlayedAllClassesLifetime>

as you can see from my TF2 (http://steamcommunity.com/profiles/76561197967464260/stats/TF2/?xml=1) profile, I've played for just over 22 minutes - LoL:

<secondsPlayedAllClassesLifetime>1359</secondsPlayedAllClassesLifetime>

For TF2, you could even restrict people from selecting certain classes unless they have played as that class for XX minutes/hours... if you look at my profile, I've played as Soldier class for 190 seconds... w00t

So, knowing that each game might have their own unique elements, it would make this plugin just a tad more complicated (just more code is all) if you wanted it to support all of them.

And maybe for TF2, it would be better to require X number of points before they're allowed to join your server:

<accumulatedPoints>13</accumulatedPoints>

asherkin
02-29-2012, 16:12
If you're going to be querying stats like that in TF2, you should do it directly with the SteamTools natives for it.
It's a lot more reliable, faster, and less taxing on Valve.

TnTSCS
02-29-2012, 16:48
ya, I'm still trying to learn all I can that steamtools offers :)

Thanks for the heads up about taxing Valve with these queries :)

TnTSCS
02-29-2012, 17:37
the power and flexibility

the lightbulb keeps getting brighter and brighter :) so many ideas... time to start putting some on paper so I can remember them all :)

Dr. McKay
03-18-2012, 14:20
This is a sample version of the plugin that uses SteamTools. It's not been tested and I didn't even attempt to compile it yet, but it's probably a good base to work off of.

#pragma semicolon 1

#include <sourcemod>
#include <steamtools>

new bool:statsChecked[MAXPLAYERS + 1] = {false, ...};

public OnClientDisconnect(client) {
statsChecked[client] = false;
}

public OnClientPostAdminCheck(client) {
statsChecked[client] = false;
Steam_RequestStats(client);
}

public Steam_StatsReceived(client) {
if(statsChecked[client] || CheckCommandAccess(client, "BypassPlaytimeCheck", ADMFLAG_ROOT)) {
return; // we've already checked them or they're an admin
}
statsChecked[client] = true;
new scout = Steam_GetStat(client, "Scout.accum.iPlayTime");
new soldier = Steam_GetStat(client, "Soldier.accum.iPlayTime");
new pyro = Steam_GetStat(client, "Pyro.accum.iPlayTime");
new demoman = Steam_GetStat(client, "Demoman.accum.iPlayTime");
new heavy = Steam_GetStat(client, "Heavy.accum.iPlayTime");
new engineer = Steam_GetStat(client, "Engineer.accum.iPlayTime");
new sniper = Steam_GetStat(client, "Sniper.accum.iPlayTime");
new medic = Steam_GetStat(client, "Medic.accum.iPlayTime");
new spy = Steam_GetStat(client, "Spy.accum.iPlayTime");
new total = scout + soldier + pyro + demoman + heavy + engineer + sniper + medic + spy;
if(total < 18000) { // I'm assuming it returns seconds played. If so, 18000 seconds = 5 hours
KickClient(client, "You must have 5 hours on record to play here");
}
}

Impact123
08-01-2012, 11:59
Still someone interested in this?
I have written a 2 part method, the plugin uses curl to fetch a custom phpscript.
The phpscript fetches the time played via the Steam-Api, caches it with apc and returns the value to the plugin.
The plugin also has a light cachesystem to reduce the load.

Yours sincerely
Impact

Blah91
10-23-2014, 11:09
Bumping this old thread; I really could use a plugin like one suggested in this thread.

Few (1-3) players are harassing my server with aimbotting and other cheating. They are farming new steam accounts and IP banning is futile, because they can and know how to reset their ip. I have banned them about 40 times during last three days. It's getting ridiculous.

Even though I have admins on my server AND SMAC detects those aimbotters, they still cause harm and ruin the fun for other players as it can take few minutes before they are banned. And then they come back few minutes later to try again.

With plugin like suggested in this thread, I could set up ~2-5 TF2 hour requirement on my server and it would make account farming much more difficult without effecting much the playerbase.

Please share your thoughts, etc.

e: Last 30 bans: http://kuvapilvi.fi/k/yh9J.png

Sreaper
10-23-2014, 13:07
This is a really nice plugin idea! It's too bad Steam Achievement Manager will let you modify your playtime essentially bypassing the plugin.