Pastebin
Paste #577: No description
< previous paste - next paste>
Pasted by panda
void edsp_monitor_check( edict_t* pEntity ) {
//SERVER_PRINT("PUTINSERVER : 1\n");
char outbuffer[256];
for ( int i = 0; i < ClientCount; i++ ) {
// Client cannot change name during connection and joining the server.
// Compare via connection name and entity's netname.
if ( !strcmp(ci[ i ].name.c_str(), STRING( pEntity->v.netname ))) {
// Fill the PlayerInfo Structure.
pi[ PlayerCount ].auth = GETPLAYERAUTHID( pEntity );
pi[ PlayerCount ].name = ci[ i ].name;
pi[ PlayerCount ].address = ci[ i ].address;
pi[ PlayerCount ].clientnum = GETPLAYERUSERID( pEntity );
pi[ PlayerCount ].playernum = PlayerCount;
pi[ PlayerCount ].pEntity = pEntity;
//pEDSP[ PlayerCount ] = pEntity;
// Entity sometimes slow to authenticate with vALVE
// Do not accept STEAM_ID_PENDING
while (!strcmp(pi[ PlayerCount ].auth.c_str(), "STEAM_ID_PENDING")) {
pi[ PlayerCount ].auth = GETPLAYERAUTHID( pEntity );
} // while
//SERVER_PRINT("PUTINSERVER : 2\n");
// Start informing clients of new entity.
// Set the HUD Text Parameters
memset(&hText, 0, sizeof(hText));
hText.channel = 1;
hText.x = 0.5;
hText.y = 0.5;
hText.effect = 0;
hText.r1 = hText.g1 = hText.b1 = 255;
hText.a1 = 255;
hText.r2 = hText.g2 = hText.b2 = 255;
hText.a2 = 255;
hText.fadeinTime = 0.2;
hText.fadeoutTime = 1;
hText.holdTime = 1.5;
hText.fxTime = 0.5;
// Check CVAR value to determine course of action
if((int)CVAR_GET_FLOAT("edsp_monitor")>=1) {
// creating a thread in order to handle multiple connections.
// WINDOWS ONLY - Need to investigate a Linux alternative.
snprintf( outbuffer, 256, "Creating thread for %s [%s]\n", pi[ PlayerCount ].name.c_str(), pi[ PlayerCount ].auth.c_str() );
SERVER_PRINT( outbuffer );
// The thread will be passed the associated element of the pInfo array that corresponds
// to the client. Access will be Player->foo
ti[ PlayerCount ].hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) extractInfo , &pi[ PlayerCount ], THREAD_ALL_ACCESS, 0);
if ( ti[ PlayerCount ].hThread ) {
SERVER_PRINT( "Thread Created ...\n" );
}
else
{
SERVER_PRINT( "Thread Failed!\n" );
}
if((int)CVAR_GET_FLOAT("edsp_monitor")>=2) {
// Inform clients
// Message to the entities HUD.
snprintf( outbuffer, 256, "[ED:SP] Player - %s [%s]\n say has entered the game.\n", pi[ PlayerCount ].name.c_str(), pi[ PlayerCount ].auth.c_str() );
HudMessageA( hText, outbuffer );
snprintf( outbuffer, 256, "[ED:SP] Now scanning %s ...\n", pi[ PlayerCount ].name.c_str() );
HudMessageA( hText, outbuffer );
} // if
} // if
} // if
} // for
ResumeThread( ti[ PlayerCount ].hThread ); // Resume the thread
ClientCount--; // one less client due to one more player.
PlayerCount++; // one more player due to one less client.
}
----------------------------------------------------
struct pInfo {
edict_t *pEntity;
string name; // players name on connection *ENSURE THAT YOU NEVER PASS A std::string to a meta/hlsdk function!!!! use .c_str()!!!
string address; // client connection address
string auth; // players STEAM_ID
string edac; // client running ED:AC - Positive = 1; Negative = 0
string ticked; // client ticked - Positive = 1; Negative = 0
string ipmatch; // Client IP matched to ED Site IP - Positive = 1; Negative = 0
string username; // Client's ED Username
string edid; // Client's EDID
string teamname; // Client's ED Teamname
string commsarg; // Arguement supplied during communication
int clientnum; // Players USERID - Game Servers Internal Reference - i.e. # 1
int playernum;
};
----------------------------------------
int WINAPI extractInfo( pInfo *player ) {
WININET is in here followed by
if (strcmp(reply.c_str(), "FALSE")) {
buf = new char[reply.length() + 1];
strcpy(buf, reply.c_str());
pch = strtok(buf, ",\"");
if ( pch!=NULL ) player->edac = pch;
if ( pch!=NULL ) pch = strtok(NULL, ",\"");
if ( pch!=NULL ) player->ticked = pch;
if ( pch!=NULL ) pch = strtok(NULL, ",\"");
if ( pch!=NULL ) player->ipmatch = pch;
if ( pch!=NULL ) pch = strtok(NULL, ",\"");
if ( pch!=NULL ) player->username = pch;
if ( pch!=NULL ) pch = strtok(NULL, ",\"");
if ( pch!=NULL ) player->edid = pch;
if ( pch!=NULL ) pch = strtok(NULL, ",\"");
if ( pch!=NULL ) player->teamname = pch;
// Action from reply.
if ( !strcmp(player->ticked.c_str(), "1" ) ) {
snprintf( outbuffer, 256, "[ED:SP] %s [%s] is ticked.\n", player->name.c_str(), player->auth.c_str() );
SERVER_PRINT( outbuffer );
HudMessageA(ht, outbuffer);
}
else
{
snprintf( outbuffer, 256, "[ED:SP] %s [%s] is not ticked.\n", player->name.c_str(), player->auth.c_str() );
SERVER_PRINT( outbuffer );
HudMessageA(ht, outbuffer );
//pEnt = INDEXENT(player->playernum);
if ( !FNullEnt( INDEXENT(player->playernum) ) ) {
CLIENT_PRINTF( pEDSP[ player->playernum], print_console, UTIL_VarArgs("[ED:SP] You have been kicked from the secure server.\nReason: Not a valid player ...\n"));
}
SafeKick(player->clientnum);
}
if ( !strcmp(player->ipmatch.c_str(), "1" ) ) {
snprintf( outbuffer, 256, "[ED:SP] %s [%s] has passed IP checking ...", player->name.c_str(), player->auth.c_str() );
SERVER_PRINT( outbuffer );
}
else
{
snprintf( outbuffer, 256, "[ED:SP] %s [%s] has a different IP then the last recorded instance ...\n", player->name.c_str(), player->auth.c_str() );
SERVER_PRINT( outbuffer );
//EggDropIPSend();
}
}
else
{
if ( !FNullEnt( player->pEntity ) ) {
CLIENT_PRINTF( player->pEntity, print_console, UTIL_VarArgs("[ED:SP] You have been kicked from the secure server.\nReason - NO AUTH ...\n"));
}
SafeKick(player->clientnum);
}
return 0;
}
New Paste
Go to most recent paste.