Ich hab' mir gedacht, dass das doch auch im LAN ganz nett wäre und hab' daher mal versucht das ganze so umzuschreiben, das es auf IPs aufbaut.
Ich hab's noch nicht getestet aber dafür fehler- und warning-frei kompiliert
Code:
/************************
* PLUGIN 'FakeName_LAN' *
* *
* changes by GGGSN8P *
*************************/
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
#define MAX_IPADDRESS 32
#define MAX_IPDESCRIPT 30
new STRING_VERSION[MAX_DATA_LENGTH] = "1.0";
new UserIP[MAX_PLAYERS][MAX_IPADDRESS];
new time;
new fsek[MAX_DATA_LENGTH];
new stimer = 30;
public admin_check(HLCommand,HLData,HLUserName,UserIndex)
{
new User[MAX_NAME_LENGTH];
new Data[MAX_DATA_LENGTH];
new Command[MAX_COMMAND_LENGTH];
new strUserIndex[MAX_DATA_LENGTH];
convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
convert_string(HLData,Data,MAX_DATA_LENGTH);
convert_string(HLUserName,User,MAX_NAME_LENGTH);
if(strcasestr(Data, "stop")!=-1)
{
kill_timer(time);
selfmessage("[SERVER]: Namescheck wurde angehalten.");
return PLUGIN_HANDLED;
}
if(strcasestr(Data, "start")!=-1)
{
kill_timer(time);
numtostr(UserIndex,strUserIndex);
time = set_timer("go", fsek[0], 99999, strUserIndex);
selfmessage("[SERVER]: Namescheck wurde gestartet.");
return PLUGIN_HANDLED;
}
if(strcasestr(Data, "start")==-1 && strcasestr(Data, "stop")==-1)
{
consgreet("Es fehlt leider der command. admin_check <start/stop>");
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public go(strUserIndex[])
{
new TextFile[MAX_DATA_LENGTH];
new counter = 0;
new i;
new maxplayers = maxplayercount();
new j;
new UserIndex;
new Name[MAX_NAME_LENGTH];
new strLine1[MAX_DATA_LENGTH];
new strLine2[MAX_DATA_LENGTH];
new strUserIP1[MAX_DATA_LENGTH];
new strUserIP2[MAX_DATA_LENGTH];
new Dummy[MAX_DATA_LENGTH];
new UserIP1;
new UserIP2;
new strName[MAX_DATA_LENGTH];
new Text[MAX_TEXT_LENGTH];
new fmsg[MAX_DATA_LENGTH];
new fps[MAX_DATA_LENGTH];
UserIndex = strtonum(strUserIndex);
strcpy(TextFile, "lanname.txt", MAX_DATA_LENGTH);
if (fileexists(TextFile) == 1)
{
counter = filesize(TextFile, 1);
}
else
{
counter = 0;
return PLUGIN_HANDLED;
}
if (fileexists(TextFile) == 1)
{
get_vaultdata("fakenamemsg",fmsg, MAX_DATA_LENGTH);
get_vaultdata("fakenameps",fps, MAX_DATA_LENGTH);
for(i=1; i<=maxplayers; i++)
{
for(j=1; j <= counter; j++)
{
//Hier wird WONID durch IP ersetzt
//Der vergleich geht über UserIndex ('iplist.pfn')
if (readfile("iplist.pfn",strLine1,UserIndex,MAX_DATA_LENGTH) != 0)
{
strbreak(strLine1, strUserIP1, Dummy, MAX_TEXT_LENGTH);
// strncpy(strUserIP1,strLine1,index(strLine1,";"),MAX_DATA_LENGTH);
UserIP1 = strtonum(strUserIP1);
if (readfile(TextFile, strLine2, j, MAX_DATA_LENGTH) != 0)
{
//strbreak(str, first, second, maxlen)
strbreak(strLine2,strUserIP2,strName,MAX_DATA_LENGTH);
UserIP2 = strtonum(strUserIP2);
if (UserIP2 == UserIP1)
{
if (streq(strName, Name)==0)
{
snprintf(Text, MAX_TEXT_LENGTH, "name ^"%s^"", strName);
execclient(Name,Text);
typesay(fmsg,5,255,0,0);
say(fps);
}
}
}
}
}
}
}
selfmessage("[SERVER]: Namescheck abgeschlossen.");
return PLUGIN_CONTINUE;
}
public plugin_connect(HLUserName, HLIP, UserIndex)
{
new Text[MAX_TEXT_LENGTH];
new User[MAX_NAME_LENGTH];
// new UserIP[MAX_DATA_LENGTH];
if (UserIndex >= 1 && UserIndex <= MAX_PLAYERS)
{
strinit(UserIP[UserIndex]);
convert_string(HLIP, UserIP[UserIndex], MAX_IPADDRESS);
convert_string(HLUserName,User,MAX_NAME_LENGTH);
// add User to List
snprintf(Text, MAX_TEXT_LENGTH, "%s %s",UserIP,User);
writefile("iplist.pfn", Text, UserIndex);
}
return PLUGIN_CONTINUE;
}
public plugin_disconnect(HLUserName, UserIndex)
{
new Text[MAX_TEXT_LENGTH];
if (UserIndex >= 1 && UserIndex <= MAX_PLAYERS)
{
// delete User from List
snprintf(Text, MAX_TEXT_LENGTH, "");
writefile("iplist.pfn", Text, UserIndex);
strinit(UserIP[UserIndex]);
}
return PLUGIN_CONTINUE;
}
public plugin_init()
{
plugin_registerinfo("Fake name","Codet bei MrSpoocy www.foc-clan.de",STRING_VERSION);
plugin_registercmd("admin_check","admin_check",ACCESS_KICK,"Mit admin_check kann man pruefen welche user unter anderem namen spielen , sie werden automatisch umbennat (muessen in der name.txt stehen mit wonid)");
get_vaultdata("fakenamesek",fsek, MAX_DATA_LENGTH);
new VaultData[MAX_DATA_LENGTH];
if(get_vaultdata("fakenamesek", VaultData, MAX_DATA_LENGTH) != 0)
{
stimer = strtonum(VaultData);
}
time = set_timer("go", stimer, 99999);
return PLUGIN_CONTINUE;
}
PLEASE return report!
_________________
Denn nur wer was zu sagen hat,
Der hat's, wenn es nicht unabdingbar ist
http://clan-ggg.de.vu/