Raised This Month: $51 Target: $400
 12% 

100% written+working write realtime status to file


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Podunk
Senior Member
Join Date: Nov 2005
Location: Florida
Old 09-02-2007 , 15:36   100% written+working write realtime status to file
Reply With Quote #1

statusing!!!! This will write ggstatus.txt every second with all players/stats

IT runs smoothly on the production server in my sig!!!


I'm also working on a plugin called gg_furnace which will have the status on screen at all times, and will be gradiented, the bottom is red, top is yellow, etc



Just pop this line in plugin_init:

set_task(1.0,"output_status");


and slide this function in there and your done!

Code:
 public output_status()
 {
	if(!get_pcvar_num(gg_stats_mode)) return 0;
	new id=0,file,status_file[13] = "ggstatus.txt";
 	if(get_pcvar_num(gg_teamplay))
 	{
 		file = fopen(status_file,"wt"); 		
 		new leader = teamplay_get_lead_team(), otherTeam = (leader == 1) ? 2 : 1;
 		new displayWeapon[24], teamName[32];
		new team;
		for(team=leader;team>0;team=otherTeam)
		{
			if(teamLevel[team] && teamLvlWeapon[team][0]) formatex(displayWeapon,23,"%s",teamLvlWeapon[team]);
			else formatex(displayWeapon,23,"%L",id,"NONE");
			get_team_name(team,teamName,31);
			fprintf(file,"L:%i (%s) %i/%i %s^n",teamLevel[team],displayWeapon,teamScore[team],teamplay_get_team_goal(team),teamName);
			if(team == otherTeam) break;
		}
		fclose(file);
 	}
 	else
 	{
		new totalPlayers = get_playersnum(), stats_mode = get_pcvar_num(gg_stats_mode);
		new players[32], num;
		get_players(players,num);
		SortCustom1D(players,num,"score_custom_compare");
		new i, name[32], player, authid[24], wins, points;
		new stats_ip = get_pcvar_num(gg_stats_ip), displayWeapon[24];
		file = fopen(status_file,"wt");
		for(i=0;i<totalPlayers;i++)
		{
			if(i >= totalPlayers) break;
			player = players[i];
			get_user_name(player,name,31);
			if(level[player] && lvlWeapon[player][0]) formatex(displayWeapon,23,"%s",lvlWeapon[player]);
			else formatex(displayWeapon,23,"%L",id,"NONE");
			if(stats_mode)
			{
				if(stats_ip) get_user_ip(player,authid,23);
				else get_user_authid(player,authid,23);
				stats_get_data(authid,wins,points,dummy,1,dummy[0]);
				fprintf(file,"L:%i (%s) %i/%i %s:%i %s^n",level[player],displayWeapon,score[player],get_level_goal(level[player]),(stats_mode == 1) ? "W" : "P",(stats_mode == 1) ? wins : points,name);
			}
			else
			{
				fprintf(file,"L:%i (%s) %i/%i %s^n",level[player],displayWeapon,score[player],get_level_goal(level[player]),name);
			}
		}
		fclose(file);
	}
	set_task(1.0,"output_status");
	return PLUGIN_CONTINUE;
 }
this is what the file looked like on my production server:
Code:
L:10 (xm1014) 1/2 W:2 free
L:7 (tmp) 1/2 W:125 KoYo
L:7 (tmp) 1/2 W:0 dz| The Plague
L:7 (tmp) 0/2 W:3 dz| blue|gurl
L:5 (fiveseven) 0/2 W:0 Disco Stu
L:4 (usp) 1/2 W:0 TheOxeneer!
L:4 (usp) 1/2 W:0 mashoogana12
L:4 (usp) 1/2 W:31 The Rat
L:4 (usp) 1/2 W:0 Harmony
L:4 (usp) 1/2 W:0 wannabelikeJACK
L:4 (usp) 0/2 W:0 envy me
L:4 (usp) 0/2 W:0 Allouch
L:4 (usp) 0/2 W:14 bongela
L:2 (p228) 1/2 W:0 :p G)-(0$T R!D3R*qc
L:2 (p228) 0/2 W:0 dalby
L:2 (p228) 0/2 W:2 Superman
L:1 (glock18) 1/2 W:0 Cinci
L:1 (glock18) 1/2 W:0 MaK :|:  daxZ_-
L:0 (none) 0/2 W:57 |FMJ| Oranges Leather Pants
L:0 (none) 0/2 W:0 soulcaster
__________________
Check out my website at http://matthewmiller.info

Last edited by Podunk; 09-03-2007 at 12:08. Reason: addfile
Podunk is offline
Send a message via MSN to Podunk
Old 09-02-2007, 16:37
Podunk
This message has been deleted by Podunk.
Old 09-02-2007, 16:39
Podunk
This message has been deleted by Podunk.
Old 09-03-2007, 11:53
Podunk
This message has been deleted by Podunk.
Podunk
Senior Member
Join Date: Nov 2005
Location: Florida
Old 09-06-2007 , 21:37   Re: 100% written+working write realtime status to file
Reply With Quote #2

OH CRAP GOOD IDEA

REPLACE PLAYER NAME WITH PLAYER STEAMID
__________________
Check out my website at http://matthewmiller.info
Podunk is offline
Send a message via MSN to Podunk
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 09-06-2007 , 21:46   Re: 100% written+working write realtime status to file
Reply With Quote #3

Looks nice, but I think that every second might end up being too much of a hog.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Podunk
Senior Member
Join Date: Nov 2005
Location: Florida
Old 09-06-2007 , 21:56   Re: 100% written+working write realtime status to file
Reply With Quote #4

doesnt seem to be hogging this box (click sig)

http://www.foolyfrag.com

I'm also FoolyCooly in another lifetime.
__________________
Check out my website at http://matthewmiller.info
Podunk is offline
Send a message via MSN to Podunk
Podunk
Senior Member
Join Date: Nov 2005
Location: Florida
Old 09-06-2007 , 22:01   Re: 100% written+working write realtime status to file
Reply With Quote #5

HOLY GODDESS ANOTHER GREAT IDEA:

CVAR SETTINGS TO TURN ON/OFF FIELDSS!!!!!!!


WOW IM ON A ROLL TODAY
__________________
Check out my website at http://matthewmiller.info
Podunk is offline
Send a message via MSN to Podunk
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 09-06-2007 , 22:51   Re: 100% written+working write realtime status to file
Reply With Quote #6

While you're at it, you might as well add a cvar for refresh rate. ;)

.....furikuri
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Podunk
Senior Member
Join Date: Nov 2005
Location: Florida
Old 09-06-2007 , 22:52   Re: 100% written+working write realtime status to file
Reply With Quote #7

it might need an asynchronous thread for this to work as intended (a way to quickly get updates from gg)asdfasdfasdf

WOW ANOTHER IDEA:

32 CVARS RIGHT?

gg_p1s
gg_p2s
gg_p3
__________________
Check out my website at http://matthewmiller.info
Podunk is offline
Send a message via MSN to Podunk
Podunk
Senior Member
Join Date: Nov 2005
Location: Florida
Old 09-06-2007 , 22:55   Re: 100% written+working write realtime status to file
Reply With Quote #8

yup DEFINITLEY a cvar for frequency because I can already see that this will probably take some time to optimize - to make it as efficient as possible.
__________________
Check out my website at http://matthewmiller.info
Podunk is offline
Send a message via MSN to Podunk
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:01.


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