Quote:
Originally Posted by Timocop
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(sBuffer, sizeof(sBuffer), sCode, 2);
SetVariantString(sBuffer);
AcceptEntityInput(iScriptLogic, "RunScriptCode");
}
|
This is very good to know, recently i've been working on some bot modification myself with my multiple weapon plugins. As of now they pickup 2 weapons(I plan on having them use them all, one of the biggest issues with melee though is that they act as if there still shooting so they'll swing from a distance constantly. I'm planning on working around this issue with script command to command them to move at there targets(It'll take some fudging but i can get it to work). I plan on making some human like sick bots. If a player goes idle there bot won't actually pickup any weapon so u can keep what u had(unless they run out of ammo), it works very well. I also hated the fact that bots would seem to get stuck not doing anything when swarmed by infected, especially if hit in the back. I have alleviated this also with script command. One thing I found with my testing is my server would crash using script command in this manner, because its constantly being called(I assume because of memory leaking). I worked around this issue by adding a timer of at least 0.5 to the script command itself to prevent it from firing constantly and it seems to work, no more crashing. However I can see this being very useful, thank u Timo