View Single Post
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 09-30-2018 , 04:20   Re: [L4D2] Improved and Perfected SurvivorAI Autotrigger
Reply With Quote #7

Quote:
Originally Posted by Timocop View Post
You should avoid all "script" cmds, they leak very badly and fill up ram because they create a new instance all the time. Use the logic_script entity instead, they wont leak.

Heres my stock i made:
PHP Code:
/**
* Runs a single line of vscript code.
* NOTE: Dont use the "script" console command, it startes a new instance and leaks memory. Use this instead!
*
* @param sCode        The code to run.
* @noreturn
*/
stock L4D2_RunScript(const String:sCode[], any:...)
{
    static 
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);
    }
    
    static 
String:sBuffer[512];
    
VFormat(sBuffersizeof(sBuffer), sCode2);
    
    
SetVariantString(sBuffer);
    
AcceptEntityInput(iScriptLogic"RunScriptCode");

__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline