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

[help] keeping motd open for 5 seconds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pcquad
Member
Join Date: Jan 2012
Old 04-04-2013 , 14:54   [help] keeping motd open for 5 seconds
Reply With Quote #1

Code:
#pragma semicolon 1 // Force strict semicolon mode.

#include <sourcemod>

new Handle:forcemotdv[MAXPLAYERS+1];
new Handle:killmotdv[MAXPLAYERS+1];
public OnClientPutInServer(client)
{
	
	PrintToConsole(client, "Please wait 5 Seconds for the motd to be closed!");
	killmotdv[client] = CreateTimer(5.0, forcemotd, client);
	forcemotdv[client] = CreateTimer(0.1, killmotd, client);
	return true;
}
public OnClientDisconnect(client)
{
	if (forcemotdv[client] != INVALID_HANDLE)
	{
		KillTimer(forcemotdv[client]);
		forcemotdv[client] = INVALID_HANDLE;
	}
}
public Action:forcemotd(Handle:timer, any:client)
{
while(1){
	if(IsClientInGame(client)){
		
		ShowMOTDPanel(client,"News","http://mycodeboard.com/news",MOTDPANEL_TYPE_URL);
		PrintToChat(client, "Motd keeps open for 5 seconds");
	}
}
}
public Action:killmotd(Handle:timer, any:client)
{
	KillTimer(forcemotdv[client]);
}

Hi can you tell me where is my fault? It compiles fine but when i test it either my server crashes or nothing happens.

It basically should show the player as soon as he joins the motd for 5 seconds , if he closes it , the plugin should reopen the motd repeatedly.

Thanks in advance
__________________
pcquad is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 04-04-2013 , 15:11   Re: [help] keeping motd open for 5 seconds
Reply With Quote #2

Using an infinite loop is not the way to go.

Instead create your own "info" VGUI Panel, but create a "cmd" keyvalue for it too with the value Cmd_ClosedHTMLPage. This will detect the MOTD being closed so you may open it again (if (GetTime() - some LastTime) is less than 5 seconds).

Note however, that this won't work with TF2's QuickPlay or Matchmaking systems as these are now blocked.
__________________
11530 is offline
pcquad
Member
Join Date: Jan 2012
Old 04-04-2013 , 15:20   Re: [help] keeping motd open for 5 seconds
Reply With Quote #3

Quote:
Originally Posted by 11530 View Post
Using an infinite loop is not the way to go.

Instead create your own "info" VGUI Panel, but create a "cmd" keyvalue for it too with the value Cmd_ClosedHTMLPage. This will detect the MOTD being closed so you may open it again (if (GetTime() - some LastTime) is less than 5 seconds).

Note however, that this won't work with TF2's QuickPlay or Matchmaking systems as these are now blocked.
can you code me an example, im not very familiar with sourcepawn? Id appreciate it
__________________
pcquad is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 04-04-2013 , 17:45   Re: [help] keeping motd open for 5 seconds
Reply With Quote #4

Before I can, what game is this for anyway? You should have really mentioned it in the first post.
__________________
11530 is offline
pcquad
Member
Join Date: Jan 2012
Old 04-04-2013 , 18:10   Re: [help] keeping motd open for 5 seconds
Reply With Quote #5

Quote:
Originally Posted by 11530 View Post
Before I can, what game is this for anyway? You should have really mentioned it in the first post.
i got it thanks i modified the dynamid motd plugin to my needs thanks though
__________________
pcquad is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 04-04-2013 , 18:13   Re: [help] keeping motd open for 5 seconds
Reply With Quote #6

I didn't know you could force the MOTD with that plugin. Either way, I have a working version should you require it in the future.
__________________
11530 is offline
pcquad
Member
Join Date: Jan 2012
Old 04-04-2013 , 19:37   Re: [help] keeping motd open for 5 seconds
Reply With Quote #7

Quote:
Originally Posted by 11530 View Post
I didn't know you could force the MOTD with that plugin. Either way, I have a working version should you require it in the future.
well i did it like you said,the dynamic motd plugin has a onhtmlclose event , and i just put a timer for every connected client and if the time isnt over he cant close it

same for me , if you want my code ill provide it at anytime
__________________
pcquad is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 04-04-2013 , 21:27   Re: [help] keeping motd open for 5 seconds
Reply With Quote #8

Quote:
Originally Posted by pcquad View Post
well i did it like you said,the dynamic motd plugin has a onhtmlclose event , and i just put a timer for every connected client and if the time isnt over he cant close it

same for me , if you want my code ill provide it at anytime
Don't worry, I already had a working version for you once you had provided the game. Just needed a string change once you did, since I made it for TF2 and for 15 seconds.

I'll provide it anyway for those curious:

PHP Code:
#include <sourcemod>

#define FORCED_MOTD_URL "http://www.sourcemod.net/"

new bool:g_bFirstMOTDShown[MAXPLAYERS+1] = { false, ... };
new 
g_fLastTime[MAXPLAYERS+1] = { 0, ... };

enum
{
    
Cmd_None 0,
    
Cmd_JoinGame,
    
Cmd_ChangeTeam,
    
Cmd_Impulse101,
    
Cmd_MapInfo,
    
Cmd_ClosedHTMLPage,
    
Cmd_ChooseTeam
};

public 
OnPluginStart()
{
    
HookUserMessage(GetUserMessageId("VGUIMenu"), OnVGUIMenutrue);
    
AddCommandListener(OnMOTDClose"closed_htmlpage");
}

public 
Action:OnVGUIMenu(UserMsg:msg_idHandle:bf, const players[], playersNumbool:reliablebool:init)
{
    if (!
g_bFirstMOTDShown[players[0]])
    {
        
decl String:szBuffer[64];
        
BfReadString(bfszBuffersizeof(szBuffer));
        if (
strcmp(szBuffer"info") == 0)
        {
            
BfReadByte(bf);
            
BfReadString(bfszBuffersizeof(szBuffer));
            
BfReadString(bfszBuffersizeof(szBuffer));
            
//Detect TF2 Welcome screen.
            
if (strcmp(szBuffer"#TF_Welcome") == 0)
            {
                
g_bFirstMOTDShown[players[0]] = true;
                
g_fLastTime[players[0]] = GetTime();
                
CreateTimer(0.1OnVGUIMenuTimerplayers[0], TIMER_FLAG_NO_MAPCHANGE);
                return 
Plugin_Handled;
            }
        }
    }
    return 
Plugin_Continue;
}

public 
Action:OnVGUIMenuTimer(Handle:timerany:client)
{
    
OpenForcedMOTD(client);
}

stock OpenForcedMOTD(const client)
{
    new 
Handle:hKv CreateKeyValues("motd");
    
KvSetString(hKv"title""ForcedMOTD");
    
KvSetNum(hKv"type"MOTDPANEL_TYPE_URL);
    
KvSetString(hKv"msg"FORCED_MOTD_URL);
    
KvSetNum(hKv"cmd"Cmd_ClosedHTMLPage);
    
//Uncomment the line below if TF2 and you want fullscreen.
    //KvSetNum(hKv, "customsvr", 1);
    
ShowVGUIPanel(client"info"hKv);
    
CloseHandle(hKv);
}



public 
Action:OnMOTDClose(client, const String:command[], argc)
{
    if (
GetTime() - g_fLastTime[client] < 15)
    {
        
OpenForcedMOTD(client);
    }
    return 
Plugin_Continue;
}

public 
OnClientDisconnect_Post(client)
{
    
g_bFirstMOTDShown[client] = false;
    
g_fLastTime[client] = 0;

__________________

Last edited by 11530; 04-04-2013 at 21:28.
11530 is offline
Splendor
New Member
Join Date: Nov 2014
Old 11-14-2014 , 08:50   Re: [help] keeping motd open for 5 seconds
Reply With Quote #9

What do i need to change to make it work for Left 4 dead 2?And is there anyway to make it use default motd file?
Splendor is offline
nxlinux
Member
Join Date: Oct 2013
Location: China
Old 11-15-2014 , 20:42   Re: [help] keeping motd open for 5 seconds
Reply With Quote #10

i want to known this about left4dead2 games
nxlinux 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 10:58.


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