Hi Leutz,
so, ich habe über Ostern ma wieder ein bißchen gecodet und dabei ist unter anderem dies hier herausgekommen:
Code:
/*
KowStats
The Livestat Plugin for AdminMod!
U have to install LogD and turn mp_logdetail to 3!
And U have to make the directory
kowstats
in your cstrike folder!
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-03-31
netkowalski@web.de
*/
#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 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];
deletefile("kowstats/stats.htm");
writefile("kowstats/stats.htm","<html><body><font size=4>Counters:",-1);
snprintf(Msg,MAX_DATA_LENGTH,"%i<br><table border=1><tr><TD WIDTH=200>NAME:</TD><TD WIDTH=50>FRAGS:</TD><TD WIDTH=50>DEADS:</TD></TR>",ScoreCT);
writefile("kowstats/stats.htm",Msg,-1);
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_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" );
return PLUGIN_CONTINUE;
}
Ein Plugin das euch Server-Livestats liefert!
Es funktioniert wie folgt:
Als erstes müsst ihr den Ordner
kowstats
im cstrike verzeichnis anlegen.
Dann auf übliche Weise das Plugin installen und voilá!
FERTIG!
So, ich denke ma dies ist eine nette kleine alternative zu anderen Programmen!
Es ist vor allen Dingen sehr einfach!
Es wird in das kowstats Verzeichnis eine html Datei (stats.htm) erstellt.
Die Datei besteht einfach nur aus 2 billigen Tabellen!
Also grafisch nicht grad das dollste!
Wer mehr haben möchte, macht sich das bitte selber.
Sollte nich so schwer sein!
Ich habe diesen Code ma wieder nicht kommentiert (bin einfach zu faul).
Aber wenn jemand Fragen hat, dann soll er sich melden!!
kowalski
[EDIT]
ÄNDERUNG IM SOURCE VORGENOMEN!!
Ein bißchen Bugfixing! Kan sein das es auch vorher ging!
So auf jeden Fall!
[/EDIT]