-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0 parents
commit 9eed381
Showing
5 changed files
with
315 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
|
||
# Custom for Visual Studio | ||
*.cs diff=csharp | ||
|
||
# Standard to msysgit | ||
*.doc diff=astextplain | ||
*.DOC diff=astextplain | ||
*.docx diff=astextplain | ||
*.DOCX diff=astextplain | ||
*.dot diff=astextplain | ||
*.DOT diff=astextplain | ||
*.pdf diff=astextplain | ||
*.PDF diff=astextplain | ||
*.rtf diff=astextplain | ||
*.RTF diff=astextplain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Ignore compiled SourceMod plugins | ||
|
||
*.smx |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Defer Server Command | ||
|
||
[:coffee: fund my caffeine addiction :coffee:](https://buymeacoff.ee/nosoop) | ||
|
||
A small utility to defer execution of a command until after all configs have been buffered. | ||
Created in response to [nosoop/SM-YetAnotherMapConfigPlugin#1][issue]. | ||
|
||
[issue]: https://github.com/nosoop/SM-YetAnotherMapConfigPlugin/issues/1 | ||
|
||
## Example | ||
|
||
In a configuration file: | ||
|
||
``` | ||
defer echo "Hello from defer!"; | ||
echo "Hello from config!"; | ||
``` | ||
|
||
"Hello from config!" will be printed out as the configuration file is being executed, and | ||
"Hello from defer!" will be printed after all configuration files have been buffered. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Internal server command `defer`. | ||
*/ | ||
#pragma semicolon 1 | ||
#include <sourcemod> | ||
|
||
#pragma newdecls required | ||
|
||
#define PLUGIN_VERSION "1.0.0" | ||
public Plugin myinfo = { | ||
name = "Defer Server Utility", | ||
author = "nosoop", | ||
description = "Defers execution of commands until after configs have been executed", | ||
version = PLUGIN_VERSION, | ||
url = "https://github.com/nosoop" | ||
} | ||
|
||
#define MAX_COMMAND_LENGTH 1024 | ||
|
||
ArrayList g_DeferredCommands; | ||
|
||
public void OnPluginStart() { | ||
g_DeferredCommands = new ArrayList(ByteCountToCells(MAX_COMMAND_LENGTH)); | ||
|
||
RegServerCmd("defer", DeferCmd); | ||
} | ||
|
||
Action DeferCmd(int args) { | ||
char buffer[MAX_COMMAND_LENGTH]; | ||
GetCmdArgString(buffer, sizeof(buffer)); | ||
|
||
g_DeferredCommands.PushString(buffer); | ||
} | ||
|
||
public void OnConfigsExecuted() { | ||
while (g_DeferredCommands.Length) { | ||
char buffer[MAX_COMMAND_LENGTH]; | ||
|
||
g_DeferredCommands.GetString(0, buffer, sizeof(buffer)); | ||
g_DeferredCommands.Erase(0); | ||
|
||
ServerCommand("%s", buffer); | ||
} | ||
} |