Added change_task()
Added server_changelevel forward
This commit is contained in:
parent
8ea1c7f486
commit
41c7d041df
|
@ -168,6 +168,20 @@ CTaskMngr::CTask* CTaskMngr::findTask( int id , AMX* amx )
|
||||||
return 0;
|
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){
|
void CTaskMngr::unlink(CTask* a){
|
||||||
if ( a->prev ) a->prev->next = a->next;
|
if ( a->prev ) a->prev->next = a->next;
|
||||||
else head = a->next;
|
else head = a->next;
|
||||||
|
|
|
@ -62,6 +62,7 @@ public:
|
||||||
CTask* next;
|
CTask* next;
|
||||||
CTask* prev;
|
CTask* prev;
|
||||||
inline void setToRemove() { exec_time = -1.0f; }
|
inline void setToRemove() { exec_time = -1.0f; }
|
||||||
|
inline void changeTime(float flNewTime) { exec_time = flNewTime; }
|
||||||
inline bool isToReply() { return (repeat-- > 0); }
|
inline bool isToReply() { return (repeat-- > 0); }
|
||||||
inline bool isRemoved() { return (exec_time == -1.0f); }
|
inline bool isRemoved() { return (exec_time == -1.0f); }
|
||||||
CTask( CPluginMngr::CPlugin* p, int f, int flags, int i,
|
CTask( CPluginMngr::CPlugin* p, int f, int flags, int i,
|
||||||
|
@ -103,6 +104,7 @@ public:
|
||||||
void registerTimers( float* timer , float* timelimit, float* timeleft );
|
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 );
|
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; }
|
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 );
|
int removeTasks( int id , AMX* amx );
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
|
|
@ -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 );
|
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 */
|
static cell AMX_NATIVE_CALL task_exists(AMX *amx, cell *params) /* 1 param */
|
||||||
{
|
{
|
||||||
return g_tasksMngr.taskExists( params[1] , params[2] ? 0 : amx );
|
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_cvar_flags", remove_cvar_flags },
|
||||||
{ "remove_quotes", remove_quotes },
|
{ "remove_quotes", remove_quotes },
|
||||||
{ "remove_task", remove_task },
|
{ "remove_task", remove_task },
|
||||||
|
{ "change_task", change_task },
|
||||||
{ "remove_user_flags", remove_user_flags },
|
{ "remove_user_flags", remove_user_flags },
|
||||||
{ "server_cmd", server_cmd },
|
{ "server_cmd", server_cmd },
|
||||||
{ "server_exec", server_exec },
|
{ "server_exec", server_exec },
|
||||||
|
|
|
@ -122,6 +122,7 @@ int FF_PluginLog = -1;
|
||||||
int FF_PluginEnd = -1;
|
int FF_PluginEnd = -1;
|
||||||
int FF_InconsistentFile = -1;
|
int FF_InconsistentFile = -1;
|
||||||
int FF_ClientAuthorized = -1;
|
int FF_ClientAuthorized = -1;
|
||||||
|
int FF_ChangeLevel = -1;
|
||||||
|
|
||||||
// fake metamod api
|
// fake metamod api
|
||||||
CFakeMeta g_FakeMeta;
|
CFakeMeta g_FakeMeta;
|
||||||
|
@ -275,6 +276,7 @@ int C_Spawn( edict_t *pent ) {
|
||||||
FF_PluginEnd = registerForward("plugin_end", ET_IGNORE, FP_DONE);
|
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_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_ClientAuthorized = registerForward("client_authorized", ET_IGNORE, FP_CELL, FP_DONE);
|
||||||
|
FF_ChangeLevel = registerForward("server_changelevel", ET_STOP, FP_STRING, FP_DONE);
|
||||||
|
|
||||||
modules_callPluginsLoaded();
|
modules_callPluginsLoaded();
|
||||||
|
|
||||||
|
@ -915,6 +917,18 @@ void C_MessageEnd_Post(void) {
|
||||||
RETURN_META(MRES_IGNORED);
|
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
|
#if 0
|
||||||
const char *C_Cmd_Args( void )
|
const char *C_Cmd_Args( void )
|
||||||
{
|
{
|
||||||
|
@ -1232,6 +1246,7 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
|
||||||
#endif
|
#endif
|
||||||
meta_engfuncs.pfnPrecacheModel = C_PrecacheModel;
|
meta_engfuncs.pfnPrecacheModel = C_PrecacheModel;
|
||||||
meta_engfuncs.pfnPrecacheSound = C_PrecacheSound;
|
meta_engfuncs.pfnPrecacheSound = C_PrecacheSound;
|
||||||
|
meta_engfuncs.pfnChangeLevel = C_ChangeLevel;
|
||||||
|
|
||||||
return g_FakeMeta.GetEngineFunctions(pengfuncsFromEngine, interfaceVersion, &meta_engfuncs);
|
return g_FakeMeta.GetEngineFunctions(pengfuncsFromEngine, interfaceVersion, &meta_engfuncs);
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user