How to set tasks

Adding Modules to help with scripting/coding plugins.
User avatar
Archive-Poster
Posts: 1090
Gender:
United States of America

How to set tasks

Post by Archive-Poster »

I've Edited CTask from source code. Heres files if anyone is going to make tasks in module. (Works without amxmodx).
working to me.

[for those who is going to add this extension]

1. Write This In Main Code:

Code: Select all

CTaskMngr TaskManager;
extern DLL_FUNCTIONS *g_pFunctionTable;
static float TimeLimit;
static float TimeLeft = 0.0f;
2. Hook load forward. i've edited GetEngineFunctions_Post Function and added there forward that will be called.
3. After Creating Forward, Add there this code:

Code: Select all

g_pFunctionTable->pfnSpawn = OnSpawn;
g_pFunctionTable->pfnStartFrame = OnStartFrame;
4. And add those forwards. (before ^ this forward).

Code: Select all

int OnSpawn(edict_t *P1)
{
	TimeLimit = CVAR_GET_FLOAT("mp_timelimit");
	TaskManager.registerTimers(&gpGlobals->time, &TimeLimit, &TimeLeft);
	g_pFunctionTable->pfnSpawn = NULL;
	return NULL;
}

void OnStartFrame(void)
{
	TaskManager.startFrame();
}
Now you can call task whenever you want.
Flag:
1 = Repeat Task With Specified Times.
2 = Loop Infinitely.
Attachments
Task.zip
(80.15 KiB) Not downloaded yet

Who is online

Users browsing this forum: No registered users and 0 guests