Last active
April 30, 2024 00:32
-
-
Save assyrianic/af8186a1506da5bf482e8df26db74e88 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
stock void RunScript(const char[] sCode, any ...) { | |
/** | |
* Run a VScript (Credit to Timocop) | |
* | |
* @param sCode Magic | |
* @return void | |
*/ | |
static int iScriptLogic = INVALID_ENT_REFERENCE; | |
if( iScriptLogic==INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic) ) { | |
iScriptLogic = EntIndexToEntRef(CreateEntityByName("logic_script")); | |
if( iScriptLogic==INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic) ) { | |
SetFailState("Could not create 'logic_script'"); | |
} | |
DispatchSpawn(iScriptLogic); | |
} | |
int code_len = strlen(sCode); | |
char[] sBuffer = new char[code_len + 1]; | |
VFormat(sBuffer, code_len, sCode, 2); | |
SetVariantString(sBuffer); | |
AcceptEntityInput(iScriptLogic, "RunScriptCode"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment