AdminMod.de
https://www.adminmod.de/

Livestats 2.0 Problem!!!!
https://www.adminmod.de/viewtopic.php?t=2872
Seite 1 von 1

Autor:  netkowalski [ 06.05.2002, 20:31 ]
Betreff des Beitrags:  Livestats 2.0 Problem!!!!

Also, ich habe nun meine Livestats um eine (sehr nützliche?!) Skin Funktion erweitert um so jedem die Möglichkeit zu geben es anzupassen!!!
Ich habe aber ein Problem:
DIE AMX WIRD 1.5 MB GROß!!!!!!
Das dürfte für viele, kleinere, Server zuviel sein! Ich hab mir das ma im HEX-Editor angeschaut und festgestellt das die eigentliche amx nicht sehr groß ist!!!! Aber 95% des .amx Files sin binäre Nullen!!!!!
Was soll das?? Was macht der compiler da??
Hat jemand ne Idee???

Hier der Code:
Code:
/*
KowStats 2.0
The Livestat Plugin for AdminMod!

U have to install LogD and turn mp_logdetail to 3!
Also U must set file_acces_read 1 and file_acces_write 1 in Ur server.cfg or listenserver.cfg
And U have to make the directory
kowstats
in your cstrike folder!
Then make a file named
skin.skf
and
block.skf
in this directory, too.
These are the skinfiles. They are textfiles and u can edit them 
with any standard texteditor (e.g. Notepad).
For a little Help, in how to make these files view the readme.
After the normal plugin installation KowStats is running!
If U have a webserver U can make the kowstat folder to a
Document folder! In this case others have acces to your stats!

(c) by kowalski 2002-05-06
netkowalski@web.de
www.teamplanet.de.vu
ICQ: 120528390
IRC: #teamclan @ quakenet
*/

#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>

#define ACCESS_CONSOLE 131072
#define ACCESS_MAN 1024
#define CLEAN_SLATE 0
new STRING_VERSION[MAX_DATA_LENGTH] = "0.1";

new StatUsers[MAX_PLAYERS];
new UserDeads[MAX_PLAYERS];
new UserFrags[MAX_PLAYERS];
new Skinlines[999][MAX_DATA_LENGTH];
new Blocklines[999][MAX_DATA_LENGTH];
new Blockline;
new Skinline;
new CTBlockLine;
new TBlockLine;
new CTLine;
new TLine;
new NameLine;
new KillsLine;
new DeadsLine;
new ScoreT;
new ScoreCT;
new MomArrayIndex = 1;


public plugin_connect(HLUserName, HLIP, UserIndex)
{
	StatUsers[MomArrayIndex]=UserIndex;
	MomArrayIndex = MomArrayIndex+1;
	stat_say();
	return PLUGIN_CONTINUE;
	
}

public stat_dis(dName, dUID, dWonid, dTeam)
{
	new UIndex[MAX_DATA_LENGTH];
	new iUIndex;
	convert_string(dUID,UIndex,MAX_DATA_LENGTH);
	iUIndex=strtonum(UIndex);
	for (new i=1;i<MomArrayIndex-1;i=i+1)
	{
		if (StatUsers[i]==iUIndex)
		{
			for (new j=i;j<MomArrayIndex-2;j=j+1)
			{
				StatUsers[j]=StatUsers[j+1];
			}
			MomArrayIndex=MomArrayIndex-1;
		}
	}
	stat_say();
}
public stat_sui( HLCommand,HLData,HLUserName,UserIndex )
{
	new UIndex[MAX_DATA_LENGTH];
	new iUIndex;
	new Trash[MAX_DATA_LENGTH];
	new Data[MAX_DATA_LENGTH];
	convert_string( HLData, Data, MAX_DATA_LENGTH );
	strsplit(Data," ",UIndex,MAX_DATA_LENGTH,Trash,MAX_DATA_LENGTH);
	iUIndex=strtonum(UIndex);
  	UserFrags[iUIndex]=UserFrags[iUIndex]-1;
   	UserDeads[iUIndex]=UserDeads[iUIndex]+1;
   	stat_say();
}

public stat_kil( HLCommand,HLData,HLUserName,UserIndex )
{
   	new iIDA;
   	new iIDV;
   	new sIDA[MAX_DATA_LENGTH];
   	new sIDV[MAX_DATA_LENGTH];
   	new Data[MAX_DATA_LENGTH];
   	new Team1;
   	new Team2;
   	new Trash1;
   	new Trash2;
   	new Trash4[MAX_NAME_LENGTH];
   	
   	convert_string( HLData, Data, MAX_DATA_LENGTH );
   	strsplit(Data," ",sIDA,MAX_DATA_LENGTH,sIDV,MAX_DATA_LENGTH);

   	iIDA = strtonum(sIDA);
   	iIDV = strtonum(sIDV);
   	playerinfo(iIDA, Trash4, MAX_NAME_LENGTH, Trash1, Trash2,Team1);
   	playerinfo(iIDV, Trash4, MAX_NAME_LENGTH, Trash1, Trash2,Team2);
   	snprintf(Data,MAX_DATA_LENGTH,"%i ^n %i",Team1,Team2);
      	if (Team1==Team2){
   		UserFrags[iIDA]=UserFrags[iIDA]-1;
   		return PLUGIN_HANDLED;
      	}

   	for (new i=1;i<MomArrayIndex+1;i=i+ 1)
   	{
   		if (iIDV==StatUsers[i])
   		{
   			UserDeads[i]=UserDeads[i]+ 1;
   		}
   	}
   	for (new i=1;i<MomArrayIndex+1;i=i+1)
   	{
   		if (iIDA==StatUsers[i])
   		{
   			UserFrags[i]=UserFrags[i]+ 1;
   		}
   	}
   	stat_say();
   	return PLUGIN_HANDLED;
}


stat_say()
{
	new Msg[MAX_DATA_LENGTH];
	new Team;
   	new Trash1;
   	new Trash2;
   	new Trash4[MAX_NAME_LENGTH];
   	new onotwrite;
   	new teamva;
   	deletefile("kowstats/stats.htm");
	snprintf(Skinlines[CTLine],MAX_DATA_LENGTH,"%i",ScoreCT);
	snprintf(Skinlines[TLine],MAX_DATA_LENGTH,"%i",ScoreT);
	for (new i=1;i<Skinline+1;i=i+1)
	{
		
		if (i==CTBlockLine || i==TBlockLine)
		{
			onotwrite=1;
			if (i==TBlockLine)
			{
				teamva=1;
			}else{
				teamva=2;
			}
			for (new o=1;o<MomArrayIndex;o=o+1)
			{
				playerinfo(StatUsers[o], Trash4, MAX_NAME_LENGTH, Trash1, Trash2,Team);
				if (Team==teamva)
				{
					snprintf(Blocklines[NameLine],MAX_DATA_LENGTH,"%s",Trash4);
					snprintf(Blocklines[KillsLine],MAX_DATA_LENGTH,"%i",UserFrags[o]);
					snprintf(Blocklines[DeadsLine],MAX_DATA_LENGTH,"%i",UserDeads[o]);
					//writefile("kowstats/stats.htm",Trash4,-1);
					for (new j=1;j<Blockline+1;j=j+1)
					{
						writefile("kowstats/stats.htm",Blocklines[j],-1);	
					}				
				}			
			}
		}
		
		if (onotwrite==0)
		{
			writefile("kowstats/stats.htm",Skinlines[i],-1);
		}
		else
		{
			onotwrite=0;
		}					
	}
	/*
	for (new i=1;i<MomArrayIndex;i=i+1)
	{
		playerinfo(StatUsers[i], Trash4, MAX_NAME_LENGTH, Trash1, Trash2,Team);
		if (Team==2)
		{
			snprintf(Msg,MAX_DATA_LENGTH,"<tr><TD WIDTH=200>%s</TD><TD WIDTH=50>%i</TD><TD WIDTH=50>%i</TD></TR>",Trash4,UserFrags[i],UserDeads[i]);
			writefile("kowstats/stats.htm",Msg,-1);
		}
	}
	snprintf(Msg,MAX_DATA_LENGTH,"</table><br>Terrors: %i<br><table border=1><tr><TD WIDTH=200>NAME:</TD><TD WIDTH=50>FRAGS:</TD><TD WIDTH=50>DEADS:</TD></TR>",ScoreT);
	writefile("kowstats/stats.htm",Msg,-1);
	for (new j=1;j<MomArrayIndex;j=j+1)
	{
		playerinfo(StatUsers[j], Trash4, MAX_NAME_LENGTH, Trash1, Trash2,Team);
		if (Team==1)
		{
			//snprintf(Msg,MAX_DATA_LENGTH,"%s: Frags: %i Deads: %i",UName,UserFrags[i],UserDeads[i]);
			snprintf(Msg,MAX_DATA_LENGTH,"<tr><TD WIDTH=200>%s</TD><TD WIDTH=50>%i</TD><TD WIDTH=50>%i</TD></TR>",Trash4,UserFrags[j],UserDeads[j]);
			writefile("kowstats/stats.htm",Msg,-1);
		}
	}
	*/
}





public stat_res(HLCommand,HLData,HLUserName,UserIndex)
{
	for( new loop = 0; loop < MomArrayIndex; loop = loop + 1 )
   	{
   		UserFrags[loop] = CLEAN_SLATE;
		UserDeads[loop] = CLEAN_SLATE;
   	}
   	stat_say();
}

public stat_tsc(HLCommand,HLData,HLUserName,UserIndex)
{
	new Params[MAX_DATA_LENGTH];
	convert_string(HLData,Params,MAX_DATA_LENGTH);
	new Data1[MAX_DATA_LENGTH];				//team
	new Data2[MAX_DATA_LENGTH];				//action
	strbreak(Params,Data1,Data2,MAX_DATA_LENGTH);
	if(strmatch(Data2, "CTs_Win", strlen("CTs_Win")) || strmatch(Data2, "Terrorists_Win", strlen("Terrorists_Win"))) {
		new scores[MAX_DATA_LENGTH];
		new ctscore[MAX_DATA_LENGTH];
		new terrorscore[MAX_DATA_LENGTH];
		new useless[MAX_DATA_LENGTH];
		strbreak(Data2, useless, scores, MAX_DATA_LENGTH);
		strbreak(scores, ctscore, terrorscore, MAX_DATA_LENGTH);
		strsplit(ctscore,"#",Data1,MAX_DATA_LENGTH,Data2,MAX_DATA_LENGTH);
		ScoreCT = strtonum(Data2);
		strsplit(terrorscore,"#",Data1,MAX_DATA_LENGTH,Data2,MAX_DATA_LENGTH);
		ScoreT = strtonum(Data2);
	}
	stat_say();
	return PLUGIN_CONTINUE;
}

public stat_tsa(HLCommand,HLData,HLUserName,UserIndex)
{
	new Params[MAX_DATA_LENGTH];
	convert_string(HLData,Params,MAX_DATA_LENGTH);
	if (strmatch(Params, "Game_Commencing", strlen("Game_Commencing")) || strmatch(Params, "Restart_Round_", strlen("Restart_Round_")))
	{
		for( new loop = 0; loop < MomArrayIndex; loop = loop + 1 )
   		{
   			UserFrags[loop] = CLEAN_SLATE;
			UserDeads[loop] = CLEAN_SLATE;
   		}
   		stat_say();
	}
	return PLUGIN_CONTINUE;
}




public plugin_init()
{
   plugin_registerinfo("LIVESTATS-Script","Put the Stats LIVE in a HTML-File",STRING_VERSION);
   plugin_registercmd("stat_kil", "stat_kil", ACCESS_CONSOLE);
   plugin_registercmd("stat_sui", "stat_sui", ACCESS_CONSOLE);
   plugin_registercmd("stat_dis", "stat_dis", ACCESS_CONSOLE);
   plugin_registercmd("stat_tsc", "stat_tsc", ACCESS_CONSOLE);
   plugin_registercmd("stat_tsa", "stat_tsa", ACCESS_CONSOLE);
   //plugin_registercmd("stat_say", "stat_say", ACCESS_CONSOLE);
   plugin_registercmd("stat_res", "stat_res", ACCESS_CONSOLE);


   exec( "logd_reg 3 admin_command stat_res" );
   exec( "logd_reg 52 admin_command stat_dis" );
   exec( "logd_reg 53 admin_command stat_sui" );
   exec( "logd_reg 57 admin_command stat_kil" );
   exec( "logd_reg 61 admin_command stat_tsc" );
   exec( "logd_reg 62 admin_command stat_tsa" );
   for (new i=1;i<filesize("kowstats/block.skf", 1)+1;i=i+1)
   {
   	readfile("kowstats/block.skf",Blocklines[i],i,MAX_DATA_LENGTH);
   	if (strcmp("::NAME::", Blocklines[i])==0)
   	{
   		NameLine=i;
   	}
   	if (strcmp("::KILLS::", Blocklines[i])==0)
   	{
   		KillsLine=i;
   	}
   	if (strcmp("::DEADS::", Blocklines[i])==0)
   	{
   		DeadsLine=i;
   	}
   }
   Blockline=filesize("kowstats/block.skf",1==0);
   for (new j=1;j<filesize("kowstats/skin.skf", 1)+1;j=j+1)
   {
   	readfile("kowstats/skin.skf",Skinlines[j],j,MAX_DATA_LENGTH);
   	if (strcmp("::CT::", Skinlines[j])==0)
   	{
   		CTLine=j;
   	}
   	if (strcmp("::T::", Skinlines[j]) ==0)
   	{
   		TLine=j;
   	}
   	if (strcmp("::CTBLOCK::", Skinlines[j])==0)
   	{
   		CTBlockLine=j;
   	}
   	if (strcmp("::TBLOCK::", Skinlines[j])==0)
   	{
   		TBlockLine=j;
   	}
   }
   Skinline=filesize("kowstats/skin.skf",1);
   return PLUGIN_CONTINUE;
}
Sorry das er nicht kommentiert ist!
Naja, richtig verwenden könt ihr den wahrscheinlich eh net, da ihr nicht wisst wie man die Skinfiles baut. (Auch wenn sich das manche ausm Code ableiten können) Aber eine genaue Beschreibung etc folgt wenn das Problem behoben ist!!!

Also, VIELEN DANK für die Hilfe!!

kowalski

Autor:  Warhead [ 06.05.2002, 22:49 ]
Betreff des Beitrags: 

Das kommt daher, da Du die Variablen Skinlines und Blocklines so groß definiert hast. In der AMX-Datei wird für diese Variablen schon Speicher beim kompilieren reserviert.

Autor:  netkowalski [ 07.05.2002, 13:17 ]
Betreff des Beitrags: 

Merci beacoup!


Das hab ich mir scghosn fast gedacht. Naja, werd ich sie kleiner machen!

kowalski

Seite 1 von 1 Alle Zeiten sind UTC+01:00
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/