diff --git a/amxmodx/CTask.cpp b/amxmodx/CTask.cpp index 430e53b9..a2f9f8df 100755 --- a/amxmodx/CTask.cpp +++ b/amxmodx/CTask.cpp @@ -168,6 +168,20 @@ CTaskMngr::CTask* CTaskMngr::findTask( int id , AMX* amx ) return 0; } +int CTaskMngr::changeTask(int id, AMX *amx, float flNewTime) +{ + CTask *a; + int i = 0; + + while ( (a=findTask(id, amx)) != 0) + { + a->changeTime(flNewTime > 0.1 ? flNewTime : 0.1); + ++i; + } + + return i; +} + void CTaskMngr::unlink(CTask* a){ if ( a->prev ) a->prev->next = a->next; else head = a->next; diff --git a/amxmodx/CTask.h b/amxmodx/CTask.h index 66714926..46b76f08 100755 --- a/amxmodx/CTask.h +++ b/amxmodx/CTask.h @@ -62,6 +62,7 @@ public: CTask* next; CTask* prev; inline void setToRemove() { exec_time = -1.0f; } + inline void changeTime(float flNewTime) { exec_time = flNewTime; } inline bool isToReply() { return (repeat-- > 0); } inline bool isRemoved() { return (exec_time == -1.0f); } CTask( CPluginMngr::CPlugin* p, int f, int flags, int i, @@ -103,6 +104,7 @@ public: void registerTimers( float* timer , float* timelimit, float* timeleft ); void registerTask( CPluginMngr::CPlugin* plugin, int func, int flags, int i, float base, float exec, int parlen , const cell* par, int repeat ); inline int taskExists( int id ,AMX* amx) { return findTask(id,amx ) ? 1 : 0; } + int changeTask(int id, AMX *amx, float flNewTime); int removeTasks( int id , AMX* amx ); void clear(); diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index 3bc6317d..5ba8fa25 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -1580,6 +1580,12 @@ static cell AMX_NATIVE_CALL remove_task(AMX *amx, cell *params) /* 1 param */ return g_tasksMngr.removeTasks( params[1] , params[2] ? 0 : amx ); } +static cell AMX_NATIVE_CALL change_task(AMX *amx, cell *params) +{ + REAL flNewTime = amx_ctof(params[2]); + return g_tasksMngr.changeTask(params[1], params[3] ? 0 : amx, flNewTime); +} + static cell AMX_NATIVE_CALL task_exists(AMX *amx, cell *params) /* 1 param */ { return g_tasksMngr.taskExists( params[1] , params[2] ? 0 : amx ); @@ -2599,6 +2605,7 @@ AMX_NATIVE_INFO amxmod_Natives[] = { { "remove_cvar_flags", remove_cvar_flags }, { "remove_quotes", remove_quotes }, { "remove_task", remove_task }, + { "change_task", change_task }, { "remove_user_flags", remove_user_flags }, { "server_cmd", server_cmd }, { "server_exec", server_exec }, diff --git a/amxmodx/meta_api.cpp b/amxmodx/meta_api.cpp index d86c2cd1..1c33703c 100755 --- a/amxmodx/meta_api.cpp +++ b/amxmodx/meta_api.cpp @@ -122,6 +122,7 @@ int FF_PluginLog = -1; int FF_PluginEnd = -1; int FF_InconsistentFile = -1; int FF_ClientAuthorized = -1; +int FF_ChangeLevel = -1; // fake metamod api CFakeMeta g_FakeMeta; @@ -275,6 +276,7 @@ int C_Spawn( edict_t *pent ) { FF_PluginEnd = registerForward("plugin_end", ET_IGNORE, FP_DONE); FF_InconsistentFile = registerForward("inconsistent_file", ET_STOP, FP_CELL, FP_STRING, FP_STRINGEX, FP_DONE); FF_ClientAuthorized = registerForward("client_authorized", ET_IGNORE, FP_CELL, FP_DONE); + FF_ChangeLevel = registerForward("server_changelevel", ET_STOP, FP_STRING, FP_DONE); modules_callPluginsLoaded(); @@ -915,6 +917,18 @@ void C_MessageEnd_Post(void) { RETURN_META(MRES_IGNORED); } +void C_ChangeLevel(char* s1, char* s2) +{ + if (FF_ChangeLevel) { + int retVal = 0; + char *map = s1; + retVal = executeForwards(FF_ChangeLevel, map); + if (retVal) + RETURN_META(MRES_SUPERCEDE); + } + RETURN_META(MRES_IGNORED); +} + #if 0 const char *C_Cmd_Args( void ) { @@ -1232,6 +1246,7 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte #endif meta_engfuncs.pfnPrecacheModel = C_PrecacheModel; meta_engfuncs.pfnPrecacheSound = C_PrecacheSound; + meta_engfuncs.pfnChangeLevel = C_ChangeLevel; return g_FakeMeta.GetEngineFunctions(pengfuncsFromEngine, interfaceVersion, &meta_engfuncs); /*