Raised This Month: $ Target: $400
 0% 

100% written+working write realtime status to file


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 07:28.


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