Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds
Watch MODSonair

Members Online

»
0 Active | 50 Guests
Online:

LATEST FORUM THREADS

»
New BF2 Mod
BF2 General

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: ScriptSearch AFK
hyper1234
General Member
Since: Mar 17, 2009
Posts: 358
Last: Apr 13, 2011
[view latest posts]
Level 5
Category: CoD2 Scripting
Posted: Friday, Feb. 26, 2010 07:20 am
Hey guys. Making a new zombie server, just looking for a script that will kick inactive players after 10 minutes. Sure its easy, anyone got one out there? Cheers
Share |
playername
Preferred Member
Since: Aug 24, 2006
Posts: 821
Last: Apr 15, 2011
[view latest posts]
Level 7
Forum Moderator
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Friday, Feb. 26, 2010 08:34 am
Hi Hyper,
There is a way. I guess the simpliest would be to see if the player's origin is changing. If the origin is the same, then he must be AFK.

Code:
checkInactivePayer()
{
	// If they disconnect or die, we need to end the loop.
	self endon("disconnect");
	self endon("death");

	// Set our starting origin
	org = self.origin;
	count = 0;

	// Loop while they are still alive
	while(1)
	{
		// If our origin hasn't changed, increase our count.
		if(self.origin == org)
		{
			// If the count is above or 600, that means they haven't moved in 10 minuets.
			if(count >= 600)
			{
				num = self getEntityNumber();
				kick(num);
				break;
			}

			count++;
		}
		// Else we need to reset back to and change the org
		else
		{
			count = 0;
			org = self.origin;
		}

		// Check every second. (1*60 == 1 min)(60*10 == 600 sec OR 10 min)
		wait 1;
	}
}


Now, to call it, add this to your player_spawn() function:
Code:
self thread checkInactivePayer();


Also note, this has NOT been tested as I have created this at school and have no way of testing it's outcome. Hope this helps!

edited on Feb. 26, 2010 10:35 am by playername
nullFew tips for coding.
1. Keep the script as short as possible.
2. Don't comment every line. Only comment portions where they may be needed to point something out.
3. Don't over complicate the script, keep it organized and easy to read.

These help you find simple errors and makes it easy to make changes.
Share |
hyper1234
General Member
Since: Mar 17, 2009
Posts: 358
Last: Apr 13, 2011
[view latest posts]
Level 5
Category: CoD2 Scripting
Posted: Sunday, Feb. 28, 2010 05:53 am
Alright, thanks for that. ill give it a shot and let you know how it goes.
Share |
clanhelio
General Member
Since: Aug 30, 2008
Posts: 223
Last: Mar 23, 2011
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Sunday, Feb. 28, 2010 12:27 pm
You might want to watch out, I think in the zombie mod when you die and go to that menu, you kind of drift in spectator, so your origin is constantly changing.
Share |
playername
Preferred Member
Since: Aug 24, 2006
Posts: 821
Last: Apr 15, 2011
[view latest posts]
Level 7
Forum Moderator
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Monday, Mar. 1, 2010 07:07 am
Hmm, does it drift? I have never noticed any spectator camera drift before. Makes me curious. I think I might just constantly print the origin of a spectator camera to be sure, but as long as it isn't getting input from the client/player, it's origin shouldn't be changing.
nullFew tips for coding.
1. Keep the script as short as possible.
2. Don't comment every line. Only comment portions where they may be needed to point something out.
3. Don't over complicate the script, keep it organized and easy to read.

These help you find simple errors and makes it easy to make changes.
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»