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

move to trash


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GoGetSomeSleep
Senior Member
Join Date: Dec 2018
Location: Miami/Florida
Old 01-20-2019 , 08:22   move to trash
Reply With Quote #1

trash

Last edited by GoGetSomeSleep; 03-11-2020 at 14:06. Reason: moderation
GoGetSomeSleep is offline
CliptonHeist
Senior Member
Join Date: Feb 2016
Old 01-20-2019 , 11:00   Re: [REQ] L4D2 1 command with more commands + timer
Reply With Quote #2

There are better ways to do this e.g. the built-in sm_help or sm_searchcmd, a motd page or even an advertisments plugin, but if you want to do it like this then here:

(Untested)
PHP Code:
#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

// Edit/Add to these for your own commands
char g_sCommands[][] = {
    {
"sm_command2"},
    {
"sm_command3"},
    {
"sm_command4"}
};

int g_iCount[MAXPLAYERS 1] = {0, ...};

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_command"Command_Command"[SM] Is a command.");
}

public 
Action Command_Command(int Clientint iArgs)
{
    if(!
IsValidClient(Client)) return Plugin_Handled;

    
CreateTimer(1.0Timer_CommandClientTIMER_REPEAT);
    
PrintToChat(Client"[SM] Printing commands:");
    return 
Plugin_Handled;
}

public 
Action Timer_Command(Handle Timerint Client)
{
    if(!
IsValidClient(Client)) return Plugin_Stop;

    
PrintToChat(Client"[SM] %s"g_sCommands[g_iCount[Client]]);
    
g_iCount[Client]++;

    if(
g_iCount[Client] >= sizeof(g_sCommands)) 
    {
        
g_iCount[Client] = 0;
        return 
Plugin_Stop;
    }

    return 
Plugin_Continue;
}

stock bool IsValidClient(int client)
{
    return 
client >= && 
    
client <= MaxClients && 
    
IsClientConnected(client) && 
    
IsClientAuthorized(client) && 
    
IsClientInGame(client);

CliptonHeist is offline
CliptonHeist
Senior Member
Join Date: Feb 2016
Old 01-20-2019 , 11:48   Re: [REQ] L4D2 1 command with more commands + timer
Reply With Quote #3

Quote:
Originally Posted by GoGetSomeSleep View Post
Hey, thanks for your help, but that's not exactly what I want...
I want to be able to write a few commands with a single command, with a timer for 1 second between them
Oh you mean executing commands? You should just need to change this line:
Code:
PrintToChat(Client, "[SM] %s", g_sCommands[g_iCount[Client]]);
to this:
Code:
FakeClientCommand(Client, "%s", g_sCommands[g_iCount[Client]]);
Although I haven't used FakeClientCommand that much before so I'm not sure if it'll work the way I expect.
CliptonHeist 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 16:00.


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