Raised This Month: $51 Target: $400
 12% 

how to stop people from disabling motd


Post New Thread Reply   
 
Thread Tools Display Modes
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 05-23-2016 , 12:40   Re: how to stop people from disabling motd
Reply With Quote #11

Quote:
Originally Posted by Grey83 View Post
Nobody likes annoying advertising.
+1
__________________
coding & free software
shanapu is offline
SM9
Veteran Member
Join Date: Sep 2013
Location: United Kingdom
Old 05-23-2016 , 15:58   Re: how to stop people from disabling motd
Reply With Quote #12

PHP Code:
#include <sourcemod>

bool g_bAdvertPlaying[MAXPLAYERS 1];

public 
Plugin myinfo 
{
    
name "Advert Example"
    
author "SM9 (xCoderx)"
    
version VERSION
    
url "http://www.fragdeluxe.com"
};

#define ADVERT_URL "https://motdgd.com/motd/?user=1337&gm=csgo"

public void OnPluginStart()
{
    
HookUserMessage(GetUserMessageId("VGUIMenu"), OnVGUIMenutrue);
}

public 
void OnClientDisconnect(int iClient)
{
    
g_bAdvertPlaying[iClient] = false;
}

public 
void QueryMotdCheck(QueryCookie qCookieint iClientConVarQueryResult cqResultchar[] chCvarNamechar[] chCvarValueDataPack dPack)
{
    if (
cqResult != ConVarQuery_Okay) {
        return;
    }
    
    
int iValue StringToInt(chCvarValue);
    
    if (
iValue 0) {
        
KickClient(iClient"You must set cl_disablehtmlmotd 0 to play here");
        return;
    }
    
    
Handle hKv CreateKeyValues("data");
    
    
KvSetNum(hKv"cmd"5);
    
KvSetString(hKv"msg"ADVERT_URL);
    
KvSetString(hKv"title""Advertisement");
    
KvSetNum(hKv"type"MOTDPANEL_TYPE_URL);
    
    
ShowVGUIPanel(iClient"info"hKvtrue);
    
CloseHandle(hKv);
}

stock void PlayAdvert(int iClient)
{
    if(
g_bAdvertPlaying[iClient]) {
        return;
    }
    
    
QueryClientConVar(iClient"cl_disablehtmlmotd"QueryMotdCheck);
}

// Some messy code, but this will stop people killing the advert.
public Action OnVGUIMenu(UserMsg msg_idHandle hPb, const int[] playersint playersNumbool reliablebool init)
{
    
int iClient players[0];
    
    if(!
IsValidClient(iClient)) {
        return 
Plugin_Continue;
    }
    
    
char chBuffer[64]; PbReadString(hPb"name"chBuffersizeof(chBuffer));
    
    if (
StrEqual(chBuffer"info"false)) {
        
int iCount PbGetRepeatedFieldCount(hPb"subkeys");
        
char chName[128]; char chWebsite[420];
        
        for (
int i 0iCounti++) {
            
Handle hSubKey PbReadRepeatedMessage(hPb"subkeys"i);
            
PbReadString(hSubKey"name"chName128);
            
            if (
StrEqual(chName"msg"false)) {
                
PbReadString(hSubKey"str"chWebsite420);
                
                if (!
StrEqual(chWebsiteADVERT_URLfalse)) {
                    if(
g_bAdvertPlaying[iClient]) {
                        return 
Plugin_Handled;
                    }
                } else {
                    
g_bAdvertPlaying[iClient] = true;
                    
                    
// You can write a PHP script which the client is redirected to after motdgd finishes the advert, then send an rcon to server.
                    // I won't provide that example here, since its too long.
                    // But the advert should usually be finished before 60 seconds anyway.
                    
CreateTimer(60.0Timer_AdvertFinishedGetClientUserId(iClient), TIMER_FLAG_NO_MAPCHANGE); 

                }
            }
        }
    }
    
    return 
Plugin_Continue;


public 
Action Timer_AdvertFinished(Handle hTimerint iUserId
{
    
int iClient GetClientOfUserId(iClient);
    
    if(!
IsValidClient(iClient)) {
        return 
Plugin_Stop;
    }
    
    
g_bAdvertPlaying[iClient] = false;
    
    return 
Plugin_Stop;
}

stock bool IsValidClient(int iClient)
{
    if (
iClient <= || iClient MaxClients) {
        return 
false;
    }
    
    return 
IsClientInGame(iClient);


Last edited by SM9; 05-23-2016 at 15:59.
SM9 is offline
Mitsuru
Member
Join Date: Jun 2013
Location: Fakes country
Old 03-27-2018 , 02:27   Re: how to stop people from disabling motd
Reply With Quote #13

cl_disablehtmlmotd 1,The default value of the client is 1?I forgot to
Mitsuru is offline
OSWO
Senior Member
Join Date: Jul 2015
Location: United Kingdom, London
Old 03-28-2018 , 21:41   Re: how to stop people from disabling motd
Reply With Quote #14

Just check their cl_disablehtmlmotd value, if it's 1 make them unable to play the server lol, I know a couple of scummy surf servers that do that (:
__________________
SourceTimer | WeaponSkins++ | BasePlugins++ https://github.com/OSCAR-WOS
OSWO is offline
Reply



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 09:12.


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