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

Autoexec command by client after connected/timer.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bonkorn
Senior Member
Join Date: Jul 2015
Old 07-25-2017 , 04:22   Autoexec command by client after connected/timer.
Reply With Quote #1

I'm using Help Menu, i just want Autoexec sm_helpmenu which displays help menu by client after 30sec.
I don't want to use Menu Based Rules which can auto display menu for connected players because it seems complicated to me.

This should be similar but failed, need help.
Used Fake Client Execute as reference.
Code:
public OnClientPutInServer(client) {
		CreateTimer(30.0, Timer_AutoShow, client);
}

public Action:Timer_AutoShow(client, args )
{
	for (new client = 1; client <= MaxClients; client++)
	{
		PerformFakeExec(client, sm_helpmenu);
	}
	
	return Plugin_Handled;
}

stock PerformFakeExec(client, const String:sm_helpmenu[])
{
	FakeClientCommandEx(client,sm_helpmenu);
}
Bonkorn is offline
WatchDogs
Senior Member
Join Date: Oct 2015
Location: Iran
Old 07-25-2017 , 10:16   Re: Autoexec command by client after connected/timer.
Reply With Quote #2

Hi,

This is the correct form of doing this:


PHP Code:
public OnClientPutInServer(client
{
    
CreateTimer(30.0Timer_AutoShowGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
}

public 
Action:Timer_AutoShow(Handle:timerany:userid)
{
    new 
client GetClientOfUserId(userid);
    if(
client && IsClientInGame(client))
    {
        
FakeClientCommandEx(client"sm_helpmenu");
    }
    return 
Plugin_Handled;

Good luck ;)
__________________

Last edited by WatchDogs; 07-25-2017 at 11:06.
WatchDogs is offline
Unbelievable
Senior Member
Join Date: Jan 2016
Old 07-25-2017 , 12:17   Re: Autoexec command by client after connected/timer.
Reply With Quote #3

Can i add idea? Can you make it so it only displays once for new players then never shows again?
__________________

Last edited by Unbelievable; 07-25-2017 at 12:19.
Unbelievable is offline
WatchDogs
Senior Member
Join Date: Oct 2015
Location: Iran
Old 07-25-2017 , 19:22   Re: Autoexec command by client after connected/timer.
Reply With Quote #4

Ya, with a simple change:

PHP Code:
#include <sourcemod>
#include <clientprefs>

Handle g_hClientCookies;

public 
void OnPluginStart()
{
    
g_hClientCookies RegClientCookie("HelpMenuCookie""A cookie for storing data for help menu"CookieAccess_Private);
}

public 
void OnClientPutInServer(int client)
{
    if (
AreClientCookiesCached(client))
    {
        
char sCookie[8];
        
GetClientCookie(clientg_hClientCookiessCookiesizeof(sCookie));
        if (!
StrEqual(sCookie"known"))
        {
            
CreateTimer(30.0Timer_AutoShowGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
        }
    }
}

public 
Action Timer_AutoShow(Handle timerany userid)
{
    
int client GetClientOfUserId(userid);
    if (
client && IsClientInGame(client))
    {
        
char sAuthId[32];
        
GetClientAuthId(clientAuthId_EnginesAuthIdsizeof(sAuthId));
        
FakeClientCommandEx(client"sm_helpmenu");
        
SetAuthIdCookie(sAuthIdg_hClientCookies"known");
    }
    return 
Plugin_Handled;

__________________
WatchDogs is offline
Unbelievable
Senior Member
Join Date: Jan 2016
Old 07-26-2017 , 14:22   Re: Autoexec command by client after connected/timer.
Reply With Quote #5

Thank you bro just one more question can you execute any sm command for clients using this plugin?.
__________________
Unbelievable is offline
WatchDogs
Senior Member
Join Date: Oct 2015
Location: Iran
Old 07-26-2017 , 15:28   Re: Autoexec command by client after connected/timer.
Reply With Quote #6

Yes, Just change the line:


PHP Code:
FakeClientCommandEx(client"sm_helpmenu"); 
To

PHP Code:
FakeClientCommandEx(client"your_command"); 
__________________
WatchDogs is offline
SZOKOZ
Member
Join Date: Jan 2014
Old 07-26-2017 , 15:48   Re: Autoexec command by client after connected/timer.
Reply With Quote #7

Quote:
Originally Posted by Unbelievable View Post
Thank you bro just one more question can you execute any sm command for clients using this plugin?.
https://forums.alliedmods.net/showpo...61&postcount=3
Any server side command so yes any sm command will work. (:
__________________
May still be available for SM scripting. Just look at my Steam profile regarding my availability.
My Steam

Last edited by SZOKOZ; 07-26-2017 at 15:50.
SZOKOZ is offline
Unbelievable
Senior Member
Join Date: Jan 2016
Old 07-26-2017 , 18:24   Re: Autoexec command by client after connected/timer.
Reply With Quote #8

Cool thanks.
__________________
Unbelievable is offline
Bonkorn
Senior Member
Join Date: Jul 2015
Old 07-27-2017 , 10:59   Re: Autoexec command by client after connected/timer.
Reply With Quote #9

Thanks to WatchDogs's help, it worked for me.
Quote:
Originally Posted by WatchDogs View Post
PHP Code:
public OnClientPutInServer(client
{
    
CreateTimer(30.0Timer_AutoShowGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
}

public 
Action:Timer_AutoShow(Handle:timerany:userid)
{
    new 
client GetClientOfUserId(userid);
    if(
client && IsClientInGame(client))
    {
        
FakeClientCommandEx(client"sm_helpmenu");
    }
    return 
Plugin_Handled;

Bonkorn 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 14:05.


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