Raised This Month: $32 Target: $400
 8% 

Solved REQ - L4D2 connect plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
eziosid
Senior Member
Join Date: Sep 2017
Old 01-20-2018 , 07:37   REQ - L4D2 connect plugin
Reply With Quote #1

hi i need help on this cant compile can some 1 look at this tnx u
PHP Code:
#pragma semicolon    1

#include <sourcemod>
#include <geoip>
#undef REQUIRE_EXTENSIONS
#include <geoipcity>
#undef REQUIRE_PLUGIN
#include <colors>

#define DEBUG 0
#define    PLUGIN_VERSION        "1.0.3"

//Handle
new Handle:g_hGameMode INVALID_HANDLE;

new 
hCount;
new 
hSlots;
new 
bool:g_UseGeoIPCity false;

public 
Plugin:myinfo 
{
    
name            =    "Player Join Counting",
    
author            =    "TGMaster, Arg!",
    
description        =    "Informs other players when a client connects to the server and changes teams.",
    
version            =    PLUGIN_VERSION,
    
url                =    ""
}

public 
OnPluginStart()
{
    
LoadTranslations("common.phrases");
    
LoadTranslations("l4d_playerjoin.phrases");
    
//Check Game Mode
    
g_hGameMode FindConVar("mp_gamemode");
    
    
//Hook Event
    
HookEvent("player_disconnect"playerDisconnectEventHookMode_Pre);
    
    
// Check if we have GeoIPCity.ext loaded
    
g_UseGeoIPCity LibraryExists("GeoIPCity");
    
    
//Get Country
    
RegAdminCmd("sm_geolist"Command_WhereIsADMFLAG_GENERIC"sm_geolist <name or #userid> - prints geopraphical information about target(s)");
}
    
public 
OnLibraryAdded(const String:name[])
{
    
// Is the GeoIPCity extension running?
    
if(StrEqual(name"GeoIPCity"))
        
g_UseGeoIPCity true;
}

public 
OnLibraryRemoved(const String:name[])
{
    
// Was the GeoIPCity extension removed?
    
if(StrEqual(name"GeoIPCity"))
        
g_UseGeoIPCity false;
}

public 
OnMapStart()
{
    
//Refresh slot count
    
hCount CheckPlayerCount();
    
    
//Check game mode
    
decl String:sGameMode[16];
    
GetConVarString(g_hGameModesGameModesizeof(sGameMode));
    
    
//Versus or Scavenge has 8 slots
    
if (StrEqual(sGameMode"versus"false) || StrEqual(sGameMode"scavenge"false))
    {
        
hSlots 8;
    }
    
    
//Campaign or Realism has slots based on l4d_superversus
    
else if (StrEqual(sGameMode"coop"false) || StrEqual(sGameMode"realism"false))
    {
        
hSlots GetConVarInt(FindConVar("sv_maxplayers"));
    }

#if DEBUG
    
RegConsoleCmd("sm_doshit"CountPlayer_Cmd);
#endif
}

/*============================= P L A Y E R    C O N N E C T ============================*/

public OnClientConnected(client)
{
    if (
IsValidPlayer(client) && !IsFakeClient(client))
    {
        
hCount ++;
        if (
hCount <= hSlots)
            
CPrintToChatAll("{olive}%N {default}is {blue}connecting{default} ({green}%i{default}/{green}%d{default})"clienthCounthSlots);
        else
            
CPrintToChatAll("{olive}%N {default}is {blue}connecting{default} to the server."client);
    }
}

/*=========================== P L A Y E R    D I S C O N N E C T ==========================*/

public Action:playerDisconnect(Handle:event, const String:name[], bool:dontBroadcast)
{
    
decl String:reason[256];
    
decl String:timedOut[256];
    
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
    if (
client && !IsFakeClient(client) && !dontBroadcast)
    {
        
hCount--;
        
GetEventString(event"reason"reasonsizeof(reason));
        
Format(timedOutsizeof(timedOut), "%s timed out"client);
        
        if (
strcmp(reasontimedOut) == || strcmp(reason"No Steam logon") == 0)
        {
            
Format(reasonsizeof(reason), "Game crashed.");
        }
        
        
CPrintToChatAll("{olive}%N {default}has {red}left {default}<{olive}%s{default}>"clientreason);
    }
    return 
event_PlayerDisconnect_SuppresseventnamedontBroadcast );
}

/*===========================================================================================*/
static bool:IsValidPlayer(client
{
    if (
client <= MaxClients)
        return 
true;
    return 
false;
}

stock CheckPlayerCount()
{
    new 
real 0;
    for (new 
1<= MaxClientsi++)
    {
        if(
IsClientConnected(i) && !IsFakeClient(i)) 
            
real++;
    }
    
    return 
real;
    
}

public 
Action:event_PlayerDisconnect_Suppress(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!
dontBroadcast)
    {
        
decl String:clientName[33], String:networkID[22], String:reason[65];
        
GetEventString(event"name"clientNamesizeof(clientName));
        
GetEventString(event"networkid"networkIDsizeof(networkID));
        
GetEventString(event"reason"reasonsizeof(reason));

        new 
Handle:newEvent CreateEvent("player_disconnect"true);
        
SetEventInt(newEvent"userid"GetEventInt(event"userid"));
        
SetEventString(newEvent"reason"reason);
        
SetEventString(newEvent"name"clientName);        
        
SetEventString(newEvent"networkid"networkID);

        
FireEvent(newEventtrue);

        return 
Plugin_Handled;
    }

    return 
Plugin_Continue;
}

public 
Action:Command_WhereIs(clientargs)
{
    
decl String:target[65];
    
    
decl String:target_name[MAX_TARGET_LENGTH];
    
decl target_list[MAXPLAYERS];
    
decl target_count;
    
decl bool:tn_is_ml;
    
decl String:name[32];
    
    
decl String:ip[16];
    
decl String:city[46];
    
decl String:region[46];
    
decl String:country[46];
    
decl String:ccode[3];
    
decl String:ccode3[4];
    new 
bool:bIsLanIp;

    
//not enough arguments, display usage
    
if (args 1)
    {
        
ReplyToCommand(client"[SM] Usage: sm_geolist <name, #userid or @targets>");
        return 
Plugin_Handled;
    }    

    
//get command arguments
    
GetCmdArg(1targetsizeof(target));


    
//get the target of this command, return error if invalid
    
if ((target_count ProcessTargetString(
            
target,
            
client,
            
target_list,
            
MAXPLAYERS,
            
0,
            
target_name,
            
sizeof(target_name),
            
tn_is_ml)) <= 0)
    {
        
ReplyToTargetError(clienttarget_count);
        return 
Plugin_Handled;
    }
    
                
    for (new 
0target_counti++)
    {
        
GetClientIP(target_list[i], ipsizeof(ip)); 
        
GetClientName(target_list[i], name32);    
        
        
//detect LAN ip
        
bIsLanIp IsLanIPip );
        
        
// Using GeoIPCity extension...
        
if ( g_UseGeoIPCity )
        {
            if( !
GeoipGetRecordipcityregioncountryccodeccode3 ) )
            {
                if( 
bIsLanIp )
                {
                    
Formatcitysizeof(city), "%T""LAN City Desc"LANG_SERVER );
                    
Formatregionsizeof(region), "%T""LAN Region Desc"LANG_SERVER );
                    
Formatcountrysizeof(country), "%T""LAN Country Desc"LANG_SERVER );
                    
Formatccodesizeof(ccode), "%T""LAN Country Short"LANG_SERVER );
                    
Formatccode3sizeof(ccode3), "%T""LAN Country Short 3"LANG_SERVER );
                }
                else
                {
                    
Formatcitysizeof(city), "%T""Unknown City Desc"LANG_SERVER );
                    
Formatregionsizeof(region), "%T""Unknown Region Desc"LANG_SERVER );
                    
Formatcountrysizeof(country), "%T""Unknown Country Desc"LANG_SERVER );
                    
Formatccodesizeof(ccode), "%T""Unknown Country Short"LANG_SERVER );
                    
Formatccode3sizeof(ccode3), "%T""Unknown Country Short 3"LANG_SERVER );
                }
            }
        }
        else 
// Using GeoIP default extension...
        
{
            if( !
GeoipCode2(ipccode) )
            {
                if( 
bIsLanIp )
                {
                    
Formatccodesizeof(ccode), "%T""LAN Country Short"LANG_SERVER );
                }
                else
                {
                    
Formatccodesizeof(ccode), "%T""Unknown Country Short"LANG_SERVER );
                }
            }
            
            if( !
GeoipCountry(ipcountrysizeof(country)) )
            {
                if( 
bIsLanIp )
                {
                    
Formatcountrysizeof(country), "%T""LAN Country Desc"LANG_SERVER );
                }
                else
                {
                    
Formatcountrysizeof(country), "%T""Unknown Country Desc"LANG_SERVER );
                }
            }
            
            
// Since the GeoIPCity extension isn't loaded, we don't know the city or region.
            
if( bIsLanIp )
            {
                
Formatcitysizeof(city), "%T""LAN City Desc"LANG_SERVER );
                
Formatregionsizeof(region), "%T""LAN Region Desc"LANG_SERVER );
                
Formatccode3sizeof(ccode3), "%T""LAN Country Short 3"LANG_SERVER );
            }
            else
            {
                
Formatcitysizeof(city), "%T""Unknown City Desc"LANG_SERVER );
                
Formatregionsizeof(region), "%T""Unknown Region Desc"LANG_SERVER );
                
Formatccode3sizeof(ccode3), "%T""Unknown Country Short 3"LANG_SERVER );
            }
        }
        
        
// Fallback for unknown/empty location strings
        
if( StrEqualcity"" ) )
        {
            
Formatcitysizeof(city), "%T""Unknown City Desc"LANG_SERVER );
        }
        
        if( 
StrEqualregion"" ) )
        {
            
Formatregionsizeof(region), "%T""Unknown Region Desc"LANG_SERVER );
        }
        
        if( 
StrEqualcountry"" ) )
        {
            
Formatcountrysizeof(country), "%T""Unknown Country Desc"LANG_SERVER );
        }
        
        if( 
StrEqualccode"" ) )
        {
            
Formatccodesizeof(ccode), "%T""Unknown Country Short"LANG_SERVER );
        }
        
        if( 
StrEqualccode3"" ) )
        {
            
Formatccode3sizeof(ccode3), "%T""Unknown Country Short 3"LANG_SERVER );
        }
        
        
// Add "The" in front of certain countries
        
if( StrContainscountry"United"false ) != -|| 
            
StrContainscountry"Republic"false ) != -|| 
            
StrContainscountry"Federation"false ) != -|| 
            
StrContainscountry"Island"false ) != -|| 
            
StrContainscountry"Netherlands"false ) != -|| 
            
StrContainscountry"Isle"false ) != -|| 
            
StrContainscountry"Bahamas"false ) != -|| 
            
StrContainscountry"Maldives"false ) != -|| 
            
StrContainscountry"Philippines"false ) != -|| 
            
StrContainscountry"Vatican"false ) != -)
        {
            
Formatcountrysizeof(country), "The %s"country );
        }
        
        
ReplyToCommandclient"%s from %s in %s/%s"namecityregioncountry );
    }            
    
    return 
Plugin_Handled;
}

//Thanks to Darkthrone (https://forums.alliedmods.net/member.php?u=54636)
bool:IsLanIPString:src[16] )
{
    
decl String:ip4[4][4];
    new 
ipnum;

    if(
ExplodeString(src"."ip444) == 4)
    {
        
ipnum StringToInt(ip4[0])*65536 StringToInt(ip4[1])*256 StringToInt(ip4[2]);
        
        if((
ipnum >= 655360 && ipnum 655360+65535) || (ipnum >= 11276288 && ipnum 11276288+4095) || (ipnum >= 12625920 && ipnum 12625920+255))
        {
            return 
true;
        }
    }

    return 
false;

this plugin is only show player name its not show country how to fix this ?
https://forums.alliedmods.net/showthread.php?t=77306
tnx ARG

Last edited by eziosid; 01-22-2018 at 11:35. Reason: using old plugin
eziosid is offline
Reply


Thread Tools
Display Modes

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 20:53.


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