Added ClientPrintf engine function (request at30137)

This commit is contained in:
Scott Ehlert 2006-05-23 03:26:26 +00:00
parent 7e36a19590
commit ac1e3a9001
7 changed files with 37 additions and 4 deletions

View File

@ -1061,6 +1061,16 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
(*g_engfuncs.pfnAlertMessage)(static_cast<ALERT_TYPE>(iparam1), temp);
return 1;
case EngFunc_ClientPrintf: // void ) (edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg);
cRet = MF_GetAmxAddr(amx, params[2]);
index = cRet[0];
CHECK_ENTITY(index);
cRet = MF_GetAmxAddr(amx, params[3]);
iparam1 = cRet[0];
temp = MF_GetAmxString(amx,params[4], 0, &len);
(*g_engfuncs.pfnClientPrintf)(INDEXENT2(index), static_cast<PRINT_TYPE>(iparam1), temp);
default:
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown engfunc type %d", type);
return 0;

View File

@ -80,7 +80,8 @@ enum {
EngFunc_SetClientKeyValue, // void ) (int clientIndex, char *infobuffer, char *key, char *value);
EngFunc_CreateInstancedBaseline, // int ) (int classname, struct entity_state_s *baseline);
EngFunc_GetInfoKeyBuffer, // char*) (edict_t *e);
EngFunc_AlertMessage // void ) (ALERT_TYPE atype, char *szFmt, ...);
EngFunc_AlertMessage, // void ) (ALERT_TYPE atype, char *szFmt, ...);
EngFunc_ClientPrintf // void ) (edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg);
};
#endif //_ENGFUNC_INCLUDE_H

View File

@ -142,6 +142,7 @@ void FMH_ServerDeactivate()
RESETE(AlertMessage);
RESETE(CreateInstancedBaseline);
RESETE(GetInfoKeyBuffer);
RESETE(ClientPrintf);
RESETD(Spawn);
RESETD(Think);

View File

@ -638,6 +638,18 @@ char *GetInfoKeyBuffer_post(edict_t *e)
RETURN_META_VALUE(MRES_IGNORED, reinterpret_cast<char *>(mlCellResult));
}
void ClientPrintf(edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg)
{
FM_ENG_HANDLE(FM_ClientPrintf, (Engine[FM_ClientPrintf].at(i), (cell)ENTINDEX(pEdict), (cell)ptype, szMsg));
RETURN_META(mswi(lastFmRes));
}
void ClientPrintf_post(edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg)
{
FM_ENG_HANDLE(FM_ClientPrintf, (Engine[FM_ClientPrintf].at(i), (cell)ENTINDEX(pEdict), (cell)ptype, szMsg));
RETURN_META(MRES_IGNORED);
}
/*
* Beginning of Engine->Game DLL hooks
*/
@ -1455,6 +1467,10 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params)
fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_DONE);
ENGHOOK(GetInfoKeyBuffer);
break;
case FM_ClientPrintf:
fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_CELL, FP_STRING, FP_DONE);
ENGHOOK(ClientPrintf);
break;
#if 0
// I know this does not fit with DLLFUNC(), but I dont want another native just for it.

View File

@ -1,7 +1,7 @@
#ifndef _INCLUDE_FORWARD_H
#define _INCLUDE_FORWARD_H
#define ENGFUNC_NUM FM_LAST_DONT_USE_ME // 130
#define ENGFUNC_NUM FM_LAST_DONT_USE_ME // 131
#define FMV_STRING 1
#define FMV_FLOAT 2
@ -163,6 +163,7 @@ enum {
FM_CreateInstancedBaseline,
FM_CreateBaseline,
FM_GetInfoKeyBuffer,
FM_ClientPrintf,
FM_LAST_DONT_USE_ME
};

View File

@ -117,7 +117,8 @@ enum {
// Returns pointer to info buffer that can be used with the infobuffer param of InfoKeyValue, SetKeyValue, and SetClientKeyValue
EngFunc_GetInfoKeyBuffer, // char*) (edict_t *e);
EngFunc_AlertMessage // void ) (ALERT_TYPE atype, char *szFmt, ...);
EngFunc_AlertMessage, // void ) (ALERT_TYPE atype, char *szFmt, ...);
EngFunc_ClientPrintf // void ) (edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg);
};
/* Used with dllfunc()
@ -534,7 +535,8 @@ enum {
FM_CmdEnd,
FM_CreateInstBaseline,
FM_CreateBaseline,
FM_GetInfoKeyBuffer
FM_GetInfoKeyBuffer,
FM_ClientPrintf
};
enum TraceResult

View File

@ -190,6 +190,8 @@ stock EF_CreateInstBaseline(CLASSNAME, baseline)
// of EF_InfoKeyValue, EF_SetKeyValue, and EF_SetClientKeyValue
stock EF_GetInfoKeyBuffer(const ENTITY)
return engfunc(EngFunc_GetInfoKeyBuffer, ENTITY)
stock EF_ClientPrintf(const ENTITY, const printType, const MESSAGE[])
return engfunc(EngFunc_ClientPrintf, ENTITY, printType, MESSAGE)
// DLLFuncs
stock DF_GameInit()