Bos93 » 07 фев 2014, 23:06
Перенести не просто? Смотри:
[pawn]
static META_FUNCTIONS gMetaFunctionTable;
C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs)
{
gpMetaGlobals = pMGlobals;
gpGamedllFuncs = pGamedllFuncs;
gMetaFunctionTable.pfnGetEngineFunctions = GetEngineFunctions;
memcpy(pFunctionTable, &gMetaFunctionTable, sizeof(META_FUNCTIONS));
return true;
}
enginefuncs_t g_pengfuncsTable;
C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int * )
{
pengfuncsFromEngine->pfnCmd_Argc = Cmd_Argc;
pengfuncsFromEngine->pfnCmd_Argv = Cmd_Argv;
pengfuncsFromEngine->pfnCmd_Args = Cmd_Args;
return 1;
}
[/pawn]
[pawn]
struct fakecmd_t
{
char args[256];
const char *argv[3];
int argc;
bool fake;
};
fakecmd_t g_fakecmd;
[/pawn]
[pawn]
const char *Cmd_Args(void)
{
// if the global "fake" flag is set, which means that engclient_cmd was used, supercede the function
if (g_fakecmd.fake)
RETURN_META_VALUE(MRES_SUPERCEDE, (g_fakecmd.argc > 1) ? g_fakecmd.args : g_fakecmd.argv[0]);
// otherwise ignore it
RETURN_META_VALUE(MRES_IGNORED, NULL);
}
const char *Cmd_Argv(int argc)
{
// if the global "fake" flag is set, which means that engclient_cmd was used, supercede the function
if (g_fakecmd.fake)
RETURN_META_VALUE(MRES_SUPERCEDE, (argc < 3) ? g_fakecmd.argv[argc] : "");
// otherwise ignore it
RETURN_META_VALUE(MRES_IGNORED, NULL);
}
int Cmd_Argc(void)
{
// if the global "fake" flag is set, which means that engclient_cmd was used, supercede the function
if (g_fakecmd.fake)
RETURN_META_VALUE(MRES_SUPERCEDE, g_fakecmd.argc);
// otherwise ignore it
RETURN_META_VALUE(MRES_IGNORED, 0);
}
[/pawn]
[pawn]
void UTIL_FakeClientCommand(edict_t *pEdict, const char *cmd, const char *arg1, const char *arg2)
{
if (!cmd)
return; // no command
// store command
g_fakecmd.argv[0] = cmd;
// if only arg2 is passed, swap the arguments
if (!arg1 && arg2)
{
arg1 = arg2;
arg2 = NULL;
}
// store arguments
if (arg2)
{ // both arguments passed
g_fakecmd.argc = 3; // 2 arguments + 1 command
// store arguments
g_fakecmd.argv[1] = arg1;
g_fakecmd.argv[2] = arg2;
// build argument line
snprintf(g_fakecmd.args, 255, "%s %s", arg1, arg2);
// if snprintf reached 255 chars limit, this will make sure there will be no access violation
g_fakecmd.args[255] = 0;
}
else if (arg1)
{ // only one argument passed
g_fakecmd.argc = 2; // 1 argument + 1 command
// store argument
g_fakecmd.argv[1] = arg1;
// build argument line
snprintf(g_fakecmd.args, 255, "%s", arg1);
// if snprintf reached 255 chars limit, this will make sure there will be no access violation
g_fakecmd.args[255] = 0;
}
else
g_fakecmd.argc = 1; // no argmuents -> only one command
// set the global "fake" flag so the Cmd_Arg* functions will be superceded
g_fakecmd.fake = true;
// tell the GameDLL that the client sent a command
MDLL_ClientCommand(pEdict);
// unset the global "fake" flag
g_fakecmd.fake = false;
}
[/pawn]
Это всё.
[pawn]
UTIL_FakeClientCommand( pEntity, "drop", "weapon_usp" );
[/pawn]
А тебе не надо даже регать функции, просто ункоментить.
Всем добра, любви и осознанности.
Nosce animum tuum.
А осознание и есть, что понял и осмыслил..
А коль не думал ты о том, то кто о том замыслил..?