New naming convention, new natives: cs_set/get/reset_user_model and cs_get/set_hostage_follow
This commit is contained in:
parent
526d8a5de2
commit
3dcc2335b2
72
dlls/cstrike/CstrikePlayer.cpp
Executable file
72
dlls/cstrike/CstrikePlayer.cpp
Executable file
|
@ -0,0 +1,72 @@
|
|||
// CstrikePlayer.cpp: implementation of the CCstrikePlayer class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "CstrikePlayer.h"
|
||||
#include <string.h> // strcpy()
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CCstrikePlayer::CCstrikePlayer()
|
||||
{
|
||||
//SetOnline(false);
|
||||
SetModelled(false);
|
||||
//SetTime(0.0);
|
||||
SetInspectModel(false);
|
||||
}
|
||||
|
||||
/*bool CCstrikePlayer::GetOnline()
|
||||
{
|
||||
return online;
|
||||
}
|
||||
|
||||
bool CCstrikePlayer::SetOnline(bool onlineIn)
|
||||
{
|
||||
return online = onlineIn;
|
||||
}*/
|
||||
|
||||
bool CCstrikePlayer::GetModelled()
|
||||
{
|
||||
return modelled;
|
||||
}
|
||||
|
||||
bool CCstrikePlayer::SetModelled(bool modelledIn)
|
||||
{
|
||||
if (!modelledIn)
|
||||
SetInspectModel(false);
|
||||
|
||||
return modelled = modelledIn;
|
||||
}
|
||||
|
||||
const char* CCstrikePlayer::GetModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
const char* CCstrikePlayer::SetModel(const char* modelIn)
|
||||
{
|
||||
//SetTime(0.0);
|
||||
return strcpy(model, modelIn);
|
||||
}
|
||||
|
||||
/*float CCstrikePlayer::GetTime()
|
||||
{
|
||||
return time;
|
||||
}
|
||||
|
||||
void CCstrikePlayer::SetTime(float timeIn)
|
||||
{
|
||||
time = timeIn;
|
||||
}
|
||||
*/
|
||||
bool CCstrikePlayer::GetInspectModel()
|
||||
{
|
||||
return inspectModel;
|
||||
}
|
||||
|
||||
void CCstrikePlayer::SetInspectModel(bool inspectModelIn)
|
||||
{
|
||||
inspectModel = inspectModelIn;
|
||||
}
|
31
dlls/cstrike/CstrikePlayer.h
Executable file
31
dlls/cstrike/CstrikePlayer.h
Executable file
|
@ -0,0 +1,31 @@
|
|||
// CstrikePlayer.h: interface for the CCstrikePlayer class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(INCLUDED_CCSTRIKEPLAYER)
|
||||
#define INCLUDED_CCSTRIKEPLAYER
|
||||
|
||||
class CCstrikePlayer
|
||||
{
|
||||
public:
|
||||
CCstrikePlayer();
|
||||
|
||||
/*bool GetOnline();
|
||||
bool SetOnline(bool onlineIn);*/
|
||||
bool GetModelled();
|
||||
bool SetModelled(bool modelledIn);
|
||||
//float GetTime();
|
||||
//void SetTime(float timeIn);
|
||||
const char* GetModel();
|
||||
const char* SetModel(const char* modelIn);
|
||||
bool GetInspectModel();
|
||||
void SetInspectModel(bool inspectModelIn);
|
||||
|
||||
private:
|
||||
bool online, inspectModel;
|
||||
bool modelled;
|
||||
char model[32];
|
||||
//float time;
|
||||
};
|
||||
|
||||
#endif // !defined(INCLUDED_CCSTRIKEPLAYER)
|
|
@ -199,6 +199,12 @@ static cell AMX_NATIVE_CALL cs_get_hostage_id(AMX *amx, cell *params) // cs_get_
|
|||
return 0;
|
||||
}
|
||||
|
||||
// Make sure this is a hostage.
|
||||
if (strcmp(STRING(pEdict->v.classname), "hostage_entity") != 0) {
|
||||
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Return value at offset
|
||||
return (int)*((int *)pEdict->pvPrivateData + OFFSET_HOSTAGEID);
|
||||
}
|
||||
|
@ -979,6 +985,197 @@ static cell AMX_NATIVE_CALL cs_set_user_nvgoggles(AMX *amx, cell *params) // cs_
|
|||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL cs_get_user_model(AMX *amx, cell *params) // cs_get_user_model(index, model[], len); = 3 params
|
||||
{
|
||||
// Get model a player has.
|
||||
// params[1] = user index
|
||||
// params[2] = model
|
||||
// params[3] = max length to set
|
||||
|
||||
// Valid player index should be within range
|
||||
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
|
||||
{
|
||||
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Make into edict pointer
|
||||
edict_t *pPlayer = INDEXENT(params[1]);
|
||||
|
||||
// Check entity validity
|
||||
if (FNullEnt(pPlayer)) {
|
||||
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return SET_AMXSTRING(amx, params[2], GETCLIENTKEYVALUE(GETINFOKEYBUFFER(pPlayer), "model"), params[3]);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL cs_set_user_model(AMX *amx, cell *params) // cs_set_user_model(index, const model[]); = 2 params
|
||||
{
|
||||
// Set model on player.
|
||||
// params[1] = user index
|
||||
// params[2] = model
|
||||
|
||||
// Valid player index should be within range
|
||||
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
|
||||
{
|
||||
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Make into edict pointer
|
||||
edict_t* pPlayer = INDEXENT(params[1]);
|
||||
|
||||
// Check entity validity
|
||||
if (FNullEnt(pPlayer)) {
|
||||
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (params[2] == -1) {
|
||||
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char model[32];
|
||||
int len;
|
||||
|
||||
strcpy(model, GET_AMXSTRING(amx, params[2], 0, len));
|
||||
|
||||
g_players[params[1]].SetModel(model);
|
||||
g_players[params[1]].SetModelled(true);
|
||||
|
||||
SETCLIENTKEYVALUE(params[1], GETINFOKEYBUFFER(pPlayer), "model", (char*)g_players[params[1]].GetModel());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL cs_reset_user_model(AMX *amx, cell *params) // cs_reset_user_model(index); = 1 param
|
||||
{
|
||||
// Reset model on player.
|
||||
// params[1] = user index
|
||||
|
||||
// Valid player index should be within range
|
||||
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
|
||||
{
|
||||
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Make into edict pointer
|
||||
edict_t* pPlayer = INDEXENT(params[1]);
|
||||
|
||||
// Check entity validity
|
||||
if (FNullEnt(pPlayer)) {
|
||||
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_players[params[1]].SetModelled(false);
|
||||
|
||||
MDLL_ClientUserInfoChanged(pPlayer, GETINFOKEYBUFFER(pPlayer));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL cs_get_hostage_follow(AMX *amx, cell *params) // cs_get_hostage_follow(index); = 1 param
|
||||
{
|
||||
// What index is the hostage following? (this doesn't have to be a player)
|
||||
// params[1] = hostage index
|
||||
|
||||
// Valid index should be within range
|
||||
if (params[1] < gpGlobals->maxClients + 1 || params[1] > gpGlobals->maxEntities) // highest player index on a 10 player server is 10 :-)!
|
||||
{
|
||||
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Make into edict pointer
|
||||
edict_t* pHostage = INDEXENT(params[1]);
|
||||
|
||||
// Check entity validity
|
||||
if (FNullEnt(pHostage)) {
|
||||
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Make sure this is a hostage.
|
||||
if (strcmp(STRING(pHostage->v.classname), "hostage_entity") != 0) {
|
||||
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int following = *((int *)pHostage->pvPrivateData + OFFSET_HOSTAGEFOLLOW);
|
||||
|
||||
if (following == 0)
|
||||
return following;
|
||||
|
||||
// Else this is probably a pointer to an entity's edict.
|
||||
edict_t* pEntity = (edict_t*)following;
|
||||
|
||||
if (FNullEnt(pEntity)) {
|
||||
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ENTINDEX(pEntity);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL cs_set_hostage_follow(AMX *amx, cell *params) // cs_set_hostage_follow(index, followedindex = 0); = 2 params
|
||||
{
|
||||
// What index should the hostage be following? (this doesn't have to be a player)
|
||||
// params[1] = hostage index
|
||||
// params[2] = index to follow, if -1 then set hostage to not follow anything
|
||||
|
||||
// Valid index should be within range
|
||||
if (params[1] < gpGlobals->maxClients + 1 || params[1] > gpGlobals->maxEntities) // highest player index on a 10 player server is 10 :-)!
|
||||
{
|
||||
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Make into edict pointer
|
||||
edict_t* pHostage = INDEXENT(params[1]);
|
||||
|
||||
// Check entity validity
|
||||
if (FNullEnt(pHostage)) {
|
||||
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Make sure this is a hostage.
|
||||
if (strcmp(STRING(pHostage->v.classname), "hostage_entity") != 0) {
|
||||
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (params[2] == -1) {
|
||||
*((int *)pHostage->pvPrivateData + OFFSET_HOSTAGEFOLLOW) = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Valid index should be within range
|
||||
if (params[2] < 1 || params[2] > gpGlobals->maxEntities)
|
||||
{
|
||||
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Make into edict pointer
|
||||
edict_t* pEntity = INDEXENT(params[2]);
|
||||
|
||||
// Check entity validity
|
||||
if (FNullEnt(pEntity)) {
|
||||
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*((int *)pHostage->pvPrivateData + OFFSET_HOSTAGEFOLLOW) = (int)pEntity;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO cstrike_Exports[] = {
|
||||
{"cs_set_user_money", cs_set_user_money},
|
||||
{"cs_get_user_money", cs_get_user_money},
|
||||
|
@ -1002,14 +1199,83 @@ AMX_NATIVE_INFO cstrike_Exports[] = {
|
|||
{"cs_set_user_backpackammo", cs_set_user_backpackammo},
|
||||
{"cs_get_user_nvgoggles", cs_get_user_nvgoggles},
|
||||
{"cs_set_user_nvgoggles", cs_set_user_nvgoggles},
|
||||
{"cs_get_hostage_follow", cs_get_hostage_follow},
|
||||
{"cs_set_hostage_follow", cs_set_hostage_follow},
|
||||
|
||||
{"cs_get_user_model", cs_get_user_model},
|
||||
{"cs_set_user_model", cs_set_user_model},
|
||||
{"cs_reset_user_model", cs_reset_user_model},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
/******************************************************************************************/
|
||||
/***GetEngineFunctions******************/
|
||||
void MessageBegin(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed) {
|
||||
// Reset player model a short while (MODELRESETTIME) after this if they are using an edited model.
|
||||
if(msg_type == GET_USER_MSG_ID(PLID, "ResetHUD", NULL)) {
|
||||
int entityIndex = ENTINDEX(ed);
|
||||
if(g_players[entityIndex].GetModelled())
|
||||
g_players[entityIndex].SetInspectModel(true);
|
||||
//g_players[ENTINDEX(ed)].SetTime(gpGlobals->time + MODELRESETTIME);
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion) {
|
||||
if(!pengfuncsFromEngine)
|
||||
return(FALSE);
|
||||
else if(*interfaceVersion != ENGINE_INTERFACE_VERSION) {
|
||||
*interfaceVersion = ENGINE_INTERFACE_VERSION;
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
//meta_engfuncs.pfnSetModel = SetModel;
|
||||
meta_engfuncs.pfnMessageBegin = MessageBegin;
|
||||
|
||||
memcpy(pengfuncsFromEngine, &meta_engfuncs, sizeof(enginefuncs_t));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/***GetEntityAPI2******************/
|
||||
void ClientDisconnect(edict_t *pEntity) {
|
||||
g_players[ENTINDEX(pEntity)].SetModelled(false);
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void ClientUserInfoChanged(edict_t *pEntity, char *infobuffer) {
|
||||
if(g_players[ENTINDEX(pEntity)].GetModelled() && pEntity->v.deadflag == DEAD_NO) {
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
} else {
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerPostThink(edict_t* pPlayer) {
|
||||
int entityIndex = ENTINDEX(pPlayer);
|
||||
|
||||
if(g_players[entityIndex].GetModelled()) {
|
||||
if (g_players[entityIndex].GetInspectModel() && strcmp(g_players[entityIndex].GetModel(), GETCLIENTKEYVALUE(GETINFOKEYBUFFER(pPlayer), "model")) != 0) {
|
||||
LOG_CONSOLE(PLID, "%s should have model %s and currently has %s", STRING(pPlayer->v.netname), (char*)g_players[entityIndex].GetModel(), GETCLIENTKEYVALUE(GETINFOKEYBUFFER(pPlayer), "model"));
|
||||
SETCLIENTKEYVALUE(entityIndex, GETINFOKEYBUFFER(pPlayer), "model", (char*)g_players[entityIndex].GetModel());
|
||||
g_players[entityIndex].SetInspectModel(false);
|
||||
}
|
||||
}
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion) {
|
||||
gFunctionTable.pfnClientDisconnect = ClientDisconnect;
|
||||
gFunctionTable.pfnClientUserInfoChanged = ClientUserInfoChanged;
|
||||
gFunctionTable.pfnPlayerPostThink = PlayerPostThink;
|
||||
|
||||
memcpy(pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS));
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/******************************************************************************************/
|
||||
|
||||
C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_t *pMetaUtilFuncs) {
|
||||
*pPlugInfo = &Plugin_info;
|
||||
gpMetaUtilFuncs = pMetaUtilFuncs;
|
||||
|
@ -1030,13 +1296,13 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m
|
|||
return(FALSE);
|
||||
}
|
||||
|
||||
gMetaFunctionTable.pfnGetEntityAPI2 = GetEntityAPI2;
|
||||
gMetaFunctionTable.pfnGetEngineFunctions = GetEngineFunctions;
|
||||
|
||||
memcpy(pFunctionTable, &gMetaFunctionTable, sizeof(META_FUNCTIONS));
|
||||
gpGamedllFuncs = pGamedllFuncs;
|
||||
|
||||
// Init stuff here
|
||||
//g_msgMoney = GET_USER_MSG_ID(PLID, "Money", NULL);
|
||||
//g_msgTextMsg = GET_USER_MSG_ID(PLID, "TextMsg", NULL);
|
||||
//g_msgStatusIcon = GET_USER_MSG_ID(PLID, "StatusIcon", NULL);
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
|
|
@ -53,10 +53,10 @@ BSC32=bscmake.exe
|
|||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"Release/cstrike_amxx.dll"
|
||||
# Begin Special Build Tool
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Cmds=echo Copying dll... copy Release\cstrike.dll K:\S\cstrike\addons\amx\dlls echo Copying inc... copy cstrike.inc K:\S\cstrike\addons\amx\examples\include
|
||||
PostBuild_Cmds=echo Copying dll... copy Release\cstrike_amxx.dll K:\S\cstrike\addons\amx\dlls echo Copying inc... copy cstrike_amxx.inc K:\S\cstrike\addons\amx\examples\include
|
||||
# End Special Build Tool
|
||||
|
||||
!ELSEIF "$(CFG)" == "cstrike - Win32 Debug"
|
||||
|
@ -83,7 +83,7 @@ BSC32=bscmake.exe
|
|||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"Debug/cstrike_mm_debug.dll" /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"Debug/cstrike_amxx_debug.dll" /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
@ -102,6 +102,10 @@ SOURCE=.\cstrike.cpp
|
|||
|
||||
SOURCE=.\cstrike.def
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CstrikePlayer.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
|
@ -110,6 +114,10 @@ SOURCE=.\cstrike.def
|
|||
|
||||
SOURCE=.\cstrike.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CstrikePlayer.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
|
@ -117,7 +125,7 @@ SOURCE=.\cstrike.h
|
|||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cstrike.inc
|
||||
SOURCE=.\cstrike_amxx.inc
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//#define CS_WON_BUILD // comment when compiling for STEAM
|
||||
//#define __cswonbuild__ // comment when compiling for STEAM
|
||||
|
||||
/* AMX Mod X
|
||||
* Counter-Strike Module
|
||||
|
@ -34,16 +34,20 @@
|
|||
*/
|
||||
|
||||
// cstrike MODULE TO DO HERE: http://www.amxmodx.org/forums/viewtopic.php?t=45
|
||||
// This implementation uses Vexd's way (lightly modified) of setting models on players.
|
||||
|
||||
#include <extdll.h>
|
||||
#include <meta_api.h>
|
||||
#include <modules.h>
|
||||
#include "CstrikePlayer.h"
|
||||
|
||||
meta_globals_t *gpMetaGlobals; // Variables provided to plugins.
|
||||
gamedll_funcs_t *gpGamedllFuncs; // Pair of function tables provided by game DLL.
|
||||
mutil_funcs_t *gpMetaUtilFuncs; // Meta Utility Function table type.
|
||||
enginefuncs_t g_engfuncs; // Engine hands this to DLLs for functionality callbacks
|
||||
globalvars_t *gpGlobals; // JGHG says: contains info on server, like maxcliens, (time?) etc, stringbase is here :-) seems to be used with entity classnames...
|
||||
enginefuncs_t meta_engfuncs;
|
||||
globalvars_t *gpGlobals;
|
||||
DLL_FUNCTIONS gFunctionTable;
|
||||
|
||||
// Must provide at least one of these...
|
||||
static META_FUNCTIONS gMetaFunctionTable; /* = {
|
||||
|
@ -55,7 +59,7 @@ static META_FUNCTIONS gMetaFunctionTable; /* = {
|
|||
NULL, // pfnGetNewDLLFunctions_Post META; called after game DLL
|
||||
NULL, // pfnGetEngineFunctions META; called before HL engine
|
||||
NULL // pfnGetEngineFunctions_Post META; called after HL engine
|
||||
}; */
|
||||
};*/
|
||||
|
||||
pfnamx_engine_g* g_engAmxFunc;
|
||||
pfnmodule_engine_g* g_engModuleFunc;
|
||||
|
@ -71,135 +75,79 @@ pfnmodule_engine_g* g_engModuleFunc;
|
|||
#define LOGTAG "AMXCS"
|
||||
#define DATE __DATE__
|
||||
|
||||
#define GETINFOKEYBUFFER (*g_engfuncs.pfnGetInfoKeyBuffer)
|
||||
#define SETCLIENTKEYVALUE (*g_engfuncs.pfnSetClientKeyValue)
|
||||
#define GETCLIENTKEYVALUE (*g_engfuncs.pfnInfoKeyValue)
|
||||
|
||||
#if defined CS_WON_BUILD
|
||||
#if defined __linux__
|
||||
#define LINUXOFFSET 5
|
||||
// "player" entities
|
||||
#define OFFSET_TEAM 114 + LINUXOFFSET // same as STEAM
|
||||
#define OFFSET_CSMONEY 115 + LINUXOFFSET // same as STEAM
|
||||
#define OFFSET_NVGOGGLES 129 + LINUXOFFSET // same as STEAM
|
||||
#define OFFSET_DEFUSE_PLANT 193 + LINUXOFFSET // same as STEAM
|
||||
#define OFFSET_VIP 215 + LINUXOFFSET // same as STEAM
|
||||
#define OFFSET_BUYZONE 239 + LINUXOFFSET // differs -2 from STEAM
|
||||
|
||||
#define OFFSET_AWM_AMMO 381 + LINUXOFFSET // differs -1 from STEAM
|
||||
#define OFFSET_SCOUT_AMMO 382 + LINUXOFFSET // all of these probably differs by -1, didn't really test that yet though
|
||||
#define OFFSET_PARA_AMMO 383 + LINUXOFFSET
|
||||
#define OFFSET_FAMAS_AMMO 384 + LINUXOFFSET
|
||||
#define OFFSET_M3_AMMO 385 + LINUXOFFSET
|
||||
#define OFFSET_USP_AMMO 386 + LINUXOFFSET
|
||||
#define OFFSET_FIVESEVEN_AMMO 387 + LINUXOFFSET
|
||||
#define OFFSET_DEAGLE_AMMO 388 + LINUXOFFSET
|
||||
#define OFFSET_P228_AMMO 389 + LINUXOFFSET
|
||||
#define OFFSET_GLOCK_AMMO 390 + LINUXOFFSET
|
||||
#define OFFSET_FLASH_AMMO 391 + LINUXOFFSET
|
||||
#define OFFSET_HE_AMMO 392 + LINUXOFFSET
|
||||
#define OFFSET_SMOKE_AMMO 393 + LINUXOFFSET
|
||||
#define OFFSET_C4_AMMO 394 + LINUXOFFSET // differs -1 from STEAM
|
||||
|
||||
#define OFFSET_CSDEATHS 448 + LINUXOFFSET // differs -1 from STEAM
|
||||
// "weapon_*" entities
|
||||
#define OFFSET_WEAPONTYPE 43 + LINUXOFFSET // same as STEAM
|
||||
#define OFFSET_SILENCER_FIREMODE 70 + LINUXOFFSET // differs -4 from STEAM
|
||||
// "hostage_entity" entities
|
||||
#define OFFSET_HOSTAGEID 487 + LINUXOFFSET // same as STEAM
|
||||
#define EXTRAOFFSET 5 // offsets 5 higher in Linux builds
|
||||
#else
|
||||
// "player" entities
|
||||
#define OFFSET_TEAM 114
|
||||
#define OFFSET_CSMONEY 115
|
||||
#define OFFSET_NVGOGGLES 129
|
||||
#define OFFSET_DEFUSE_PLANT 193
|
||||
#define OFFSET_VIP 215
|
||||
#define OFFSET_BUYZONE 239
|
||||
|
||||
#define OFFSET_AWM_AMMO 381
|
||||
#define OFFSET_SCOUT_AMMO 382
|
||||
#define OFFSET_PARA_AMMO 383
|
||||
#define OFFSET_FAMAS_AMMO 384
|
||||
#define OFFSET_M3_AMMO 385
|
||||
#define OFFSET_USP_AMMO 386
|
||||
#define OFFSET_FIVESEVEN_AMMO 387
|
||||
#define OFFSET_DEAGLE_AMMO 388
|
||||
#define OFFSET_P228_AMMO 389
|
||||
#define OFFSET_GLOCK_AMMO 390
|
||||
#define OFFSET_FLASH_AMMO 391
|
||||
#define OFFSET_HE_AMMO 392
|
||||
#define OFFSET_SMOKE_AMMO 393
|
||||
#define OFFSET_C4_AMMO 394
|
||||
|
||||
#define OFFSET_CSDEATHS 448
|
||||
|
||||
#define OFFSET_WEAPONTYPE 43
|
||||
#define OFFSET_SILENCER_FIREMODE 70
|
||||
// "hostage_entity" entities
|
||||
#define OFFSET_HOSTAGEID 487
|
||||
#define EXTRAOFFSET 0 // no change in Windows builds
|
||||
#endif // defined __linux__
|
||||
|
||||
#if defined __cswonbuild__ // from here WON build looks for offsets
|
||||
// "player" entities
|
||||
#define OFFSET_TEAM 114 + EXTRAOFFSET // same as STEAM
|
||||
#define OFFSET_CSMONEY 115 + EXTRAOFFSET // same as STEAM
|
||||
#define OFFSET_NVGOGGLES 129 + EXTRAOFFSET // same as STEAM
|
||||
#define OFFSET_DEFUSE_PLANT 193 + EXTRAOFFSET // same as STEAM
|
||||
#define OFFSET_VIP 215 + EXTRAOFFSET // same as STEAM
|
||||
#define OFFSET_BUYZONE 239 + EXTRAOFFSET // differs -2 from STEAM
|
||||
|
||||
#define OFFSET_AWM_AMMO 381 + EXTRAOFFSET // differs -1 from STEAM
|
||||
#define OFFSET_SCOUT_AMMO 382 + EXTRAOFFSET // all of these probably differs by -1, didn't really test that yet though
|
||||
#define OFFSET_PARA_AMMO 383 + EXTRAOFFSET
|
||||
#define OFFSET_FAMAS_AMMO 384 + EXTRAOFFSET
|
||||
#define OFFSET_M3_AMMO 385 + EXTRAOFFSET
|
||||
#define OFFSET_USP_AMMO 386 + EXTRAOFFSET
|
||||
#define OFFSET_FIVESEVEN_AMMO 387 + EXTRAOFFSET
|
||||
#define OFFSET_DEAGLE_AMMO 388 + EXTRAOFFSET
|
||||
#define OFFSET_P228_AMMO 389 + EXTRAOFFSET
|
||||
#define OFFSET_GLOCK_AMMO 390 + EXTRAOFFSET
|
||||
#define OFFSET_FLASH_AMMO 391 + EXTRAOFFSET
|
||||
#define OFFSET_HE_AMMO 392 + EXTRAOFFSET
|
||||
#define OFFSET_SMOKE_AMMO 393 + EXTRAOFFSET
|
||||
#define OFFSET_C4_AMMO 394 + EXTRAOFFSET // differs -1 from STEAM
|
||||
|
||||
#define OFFSET_CSDEATHS 448 + EXTRAOFFSET // differs -1 from STEAM
|
||||
// "weapon_*" entities
|
||||
#define OFFSET_WEAPONTYPE 43 + EXTRAOFFSET // same as STEAM
|
||||
#define OFFSET_SILENCER_FIREMODE 70 + EXTRAOFFSET // differs -4 from STEAM
|
||||
// "hostage_entity" entities
|
||||
//#define OFFSET_HOSTAGEFOLLOW 86 + EXTRAOFFSET // NOT YET CHECKED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! find out before build
|
||||
#define OFFSET_HOSTAGEID 487 + EXTRAOFFSET // same as STEAM
|
||||
#else // from here STEAM build looks for offsets
|
||||
#if defined __linux__
|
||||
#define LINUXOFFSET 5
|
||||
// "player" entities
|
||||
#define OFFSET_TEAM 114 + LINUXOFFSET
|
||||
#define OFFSET_CSMONEY 115 + LINUXOFFSET
|
||||
#define OFFSET_NVGOGGLES 129 + LINUXOFFSET
|
||||
#define OFFSET_DEFUSE_PLANT 193 + LINUXOFFSET
|
||||
#define OFFSET_VIP 215 + LINUXOFFSET
|
||||
#define OFFSET_BUYZONE 241 + LINUXOFFSET
|
||||
// "player" entities
|
||||
#define OFFSET_TEAM 114 + EXTRAOFFSET
|
||||
#define OFFSET_CSMONEY 115 + EXTRAOFFSET
|
||||
#define OFFSET_NVGOGGLES 129 + EXTRAOFFSET
|
||||
#define OFFSET_DEFUSE_PLANT 193 + EXTRAOFFSET
|
||||
#define OFFSET_VIP 215 + EXTRAOFFSET
|
||||
#define OFFSET_BUYZONE 241 + EXTRAOFFSET
|
||||
|
||||
#define OFFSET_AWM_AMMO 382 + LINUXOFFSET
|
||||
#define OFFSET_SCOUT_AMMO 383 + LINUXOFFSET
|
||||
#define OFFSET_PARA_AMMO 384 + LINUXOFFSET
|
||||
#define OFFSET_FAMAS_AMMO 385 + LINUXOFFSET
|
||||
#define OFFSET_M3_AMMO 386 + LINUXOFFSET
|
||||
#define OFFSET_USP_AMMO 387 + LINUXOFFSET
|
||||
#define OFFSET_FIVESEVEN_AMMO 388 + LINUXOFFSET
|
||||
#define OFFSET_DEAGLE_AMMO 389 + LINUXOFFSET
|
||||
#define OFFSET_P228_AMMO 390 + LINUXOFFSET
|
||||
#define OFFSET_GLOCK_AMMO 391 + LINUXOFFSET
|
||||
#define OFFSET_FLASH_AMMO 392 + LINUXOFFSET
|
||||
#define OFFSET_HE_AMMO 393 + LINUXOFFSET
|
||||
#define OFFSET_SMOKE_AMMO 394 + LINUXOFFSET
|
||||
#define OFFSET_C4_AMMO 395 + LINUXOFFSET
|
||||
#define OFFSET_AWM_AMMO 382 + EXTRAOFFSET
|
||||
#define OFFSET_SCOUT_AMMO 383 + EXTRAOFFSET
|
||||
#define OFFSET_PARA_AMMO 384 + EXTRAOFFSET
|
||||
#define OFFSET_FAMAS_AMMO 385 + EXTRAOFFSET
|
||||
#define OFFSET_M3_AMMO 386 + EXTRAOFFSET
|
||||
#define OFFSET_USP_AMMO 387 + EXTRAOFFSET
|
||||
#define OFFSET_FIVESEVEN_AMMO 388 + EXTRAOFFSET
|
||||
#define OFFSET_DEAGLE_AMMO 389 + EXTRAOFFSET
|
||||
#define OFFSET_P228_AMMO 390 + EXTRAOFFSET
|
||||
#define OFFSET_GLOCK_AMMO 391 + EXTRAOFFSET
|
||||
#define OFFSET_FLASH_AMMO 392 + EXTRAOFFSET
|
||||
#define OFFSET_HE_AMMO 393 + EXTRAOFFSET
|
||||
#define OFFSET_SMOKE_AMMO 394 + EXTRAOFFSET
|
||||
#define OFFSET_C4_AMMO 395 + EXTRAOFFSET
|
||||
|
||||
#define OFFSET_CSDEATHS 449 + LINUXOFFSET
|
||||
// "weapon_*" entities
|
||||
#define OFFSET_WEAPONTYPE 43 + LINUXOFFSET
|
||||
#define OFFSET_SILENCER_FIREMODE 74 + LINUXOFFSET
|
||||
// "hostage_entity" entities
|
||||
#define OFFSET_HOSTAGEID 487 + LINUXOFFSET
|
||||
|
||||
#else
|
||||
// "player" entities
|
||||
#define OFFSET_TEAM 114
|
||||
#define OFFSET_CSMONEY 115
|
||||
#define OFFSET_NVGOGGLES 129
|
||||
#define OFFSET_DEFUSE_PLANT 193
|
||||
#define OFFSET_VIP 215
|
||||
#define OFFSET_BUYZONE 241
|
||||
|
||||
#define OFFSET_AWM_AMMO 382
|
||||
#define OFFSET_SCOUT_AMMO 383
|
||||
#define OFFSET_PARA_AMMO 384
|
||||
#define OFFSET_FAMAS_AMMO 385
|
||||
#define OFFSET_M3_AMMO 386
|
||||
#define OFFSET_USP_AMMO 387
|
||||
#define OFFSET_FIVESEVEN_AMMO 388
|
||||
#define OFFSET_DEAGLE_AMMO 389
|
||||
#define OFFSET_P228_AMMO 390
|
||||
#define OFFSET_GLOCK_AMMO 391
|
||||
#define OFFSET_FLASH_AMMO 392
|
||||
#define OFFSET_HE_AMMO 393
|
||||
#define OFFSET_SMOKE_AMMO 394
|
||||
#define OFFSET_C4_AMMO 395
|
||||
|
||||
#define OFFSET_CSDEATHS 449
|
||||
// "weapon_*" entities
|
||||
#define OFFSET_WEAPONTYPE 43
|
||||
#define OFFSET_SILENCER_FIREMODE 74
|
||||
// "hostage_entity" entities
|
||||
#define OFFSET_HOSTAGEID 487
|
||||
#endif // defined __linux__
|
||||
#endif // defined CS_WON_BUILD
|
||||
#define OFFSET_CSDEATHS 449 + EXTRAOFFSET
|
||||
// "weapon_*" entities
|
||||
#define OFFSET_WEAPONTYPE 43 + EXTRAOFFSET
|
||||
#define OFFSET_SILENCER_FIREMODE 74 + EXTRAOFFSET
|
||||
// "hostage_entity" entities
|
||||
#define OFFSET_HOSTAGEFOLLOW 86 + EXTRAOFFSET
|
||||
#define OFFSET_HOSTAGEID 487 + EXTRAOFFSET
|
||||
#endif // defined __cswonbuild__
|
||||
|
||||
// Offsets of ammo amount in player entities
|
||||
/*
|
||||
|
@ -276,6 +224,7 @@ pfnmodule_engine_g* g_engModuleFunc;
|
|||
#define DEFUSER_COLOUR_B 0
|
||||
|
||||
#define HAS_NVGOGGLES (1<<0)
|
||||
#define MODELRESETTIME 1.0
|
||||
// cstrike-specific defines above
|
||||
|
||||
// Globals below
|
||||
|
@ -298,7 +247,6 @@ module_info_s module_info = {
|
|||
RELOAD_MODULE,
|
||||
};
|
||||
|
||||
//int g_msgMoney;
|
||||
//int g_msgTextMsg;
|
||||
//int g_msgStatusIcon;
|
||||
CCstrikePlayer g_players[33];
|
||||
//bool g_initialized = false;
|
||||
// Globals above
|
||||
|
|
118
plugins/include/cstrike.inc
Executable file
118
plugins/include/cstrike.inc
Executable file
|
@ -0,0 +1,118 @@
|
|||
/* Counter-Strike functions
|
||||
*
|
||||
* by the AMX Mod X Development Team
|
||||
*
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
|
||||
#if defined _cstrike_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _cstrike_included
|
||||
|
||||
/* Returns index of entity (does not have to be a player) which hostage is following. 0 is hostage doesn't follow anything. */
|
||||
native cs_get_hostage_follow(index);
|
||||
|
||||
/* Set hostage to follow entity specified in followedindex. Does not have to be a player. If followedindex is 0 the hostage will stop following. */
|
||||
native cs_set_hostage_follow(index, followedindex = 0);
|
||||
|
||||
/* Get unique hostage id. */
|
||||
native cs_get_hostage_id(index);
|
||||
|
||||
/* Get amount of ammo in backpack on a user for a specific weapon.
|
||||
* Look in amxconst.inc for weapon types: CSW_*.
|
||||
* Weapons on the same line uses the same ammo type:
|
||||
* awm
|
||||
* scout, ak, g3
|
||||
* para
|
||||
* famas, m4a1, aug, sg550, galil, sg552
|
||||
* m3, xm
|
||||
* usp, ump, mac
|
||||
* fiveseven, p90
|
||||
* deagle
|
||||
* p228
|
||||
* glock, mp5, tmp, elites
|
||||
* flash
|
||||
* he
|
||||
* smoke
|
||||
*/
|
||||
native cs_get_user_backpackammo(index, weapon);
|
||||
|
||||
/* Restock/remove ammo in a user's backpack. */
|
||||
native cs_set_user_backpackammo(index, weapon, amount);
|
||||
|
||||
/* Get deaths. */
|
||||
native cs_get_user_deaths(index);
|
||||
|
||||
/* Set deaths. (Doesn't update scoreboard right away? fix later?) */
|
||||
native cs_set_user_deaths(index, newdeaths);
|
||||
|
||||
/* Returns 1 if user has a defuse kit. */
|
||||
native cs_get_user_defusekit(index);
|
||||
|
||||
/* If defusekit is 1, the user will have a defuse kit.
|
||||
* You can specify a different colour for the defuse kit icon showing on hud. Default is the normal green.
|
||||
* You can specify an icon. Default is "defuser". Set flash to 1 if you want the icon to flash red. */
|
||||
native cs_set_user_defusekit(index, defusekit = 1, r = 0, g = 160, b = 0, icon[] = "defuser", flash = 0);
|
||||
|
||||
/* Is user in buyzone? Returns 1 when true, 0 when false. */
|
||||
native cs_get_user_inside_buyzone(index);
|
||||
|
||||
/* Get user model. */
|
||||
native cs_get_user_model(index, model[], len);
|
||||
|
||||
/* Set user model. */
|
||||
native cs_set_user_model(index, const model[]);
|
||||
|
||||
/* Use to reset model to standard selected model. */
|
||||
native cs_reset_user_model(index);
|
||||
|
||||
/* Returns users money. */
|
||||
native cs_get_user_money(index);
|
||||
|
||||
/* Gives money to user. If flash is 1, the difference between new and old amount will flash red or green. */
|
||||
native cs_set_user_money(index, money, flash = 1);
|
||||
|
||||
/* Does user have night vision goggles? */
|
||||
native cs_get_user_nvgoggles(index);
|
||||
|
||||
/* Set nvgoggles to 1 to give night vision goggles to index. Set it to 0 to remove them. */
|
||||
native cs_set_user_nvgoggles(index, nvgoggles = 1);
|
||||
|
||||
/* Returns 1 if user has the "skill" to plant bomb, else 0. Normally this would only be true for a terrorist carrying a bomb. */
|
||||
native cs_get_user_plant(index);
|
||||
|
||||
/* If plant is 1, a user will be set to be able to plant bomb within the usual bomb target areas if having one.
|
||||
* You should use this if you give a player a weapon_c4, or he won't be able to plant it
|
||||
* without dropping it and picking it up again (only possible for terrorists).
|
||||
* If showbombicon is 1, the green C4 icon will be shown on user hud (if plant "skill" was enabled). */
|
||||
native cs_set_user_plant(index, plant = 1, showbombicon = 1);
|
||||
|
||||
/* Get team directly from player's entity.
|
||||
* 1 = terrorist
|
||||
* 2 = counter-terrorist
|
||||
* 3 = spectator */
|
||||
native cs_get_user_team(index);
|
||||
|
||||
/* Set user team without killing player (so you can move hostages, plant bomb etc as terrorist). */
|
||||
native cs_set_user_team(index, team);
|
||||
|
||||
/* Is user vip? */
|
||||
native cs_get_user_vip(index);
|
||||
|
||||
/* If vip = 1, user is set to vip. Note that this is useful to unset vips, so they can change teams properly.
|
||||
* This will not change the player's model to/from vip, or add/remove the "VIP" text in scoreboard. */
|
||||
native cs_set_user_vip(index, vip = 1);
|
||||
|
||||
/* Returns 1 if specified weapon is in burst mode. */
|
||||
native cs_get_weapon_burstmode(index);
|
||||
|
||||
/* If burstmode = 1, weapon will be changed to burst mode, 0 and non-burst mode (semiautomatic/automatic) will be activated.
|
||||
* Only GLOCK and FAMAS can enter/leave burst mode. */
|
||||
native cs_set_weapon_burstmode(index, burstmode = 1);
|
||||
|
||||
/* Returns 1 if weapon is silenced, else 0. */
|
||||
native cs_get_weapon_silenced(index);
|
||||
|
||||
/* If silence = 1, weapon will be silenced, 0 and silencer will be removed. Only USP and M4A1 can be silenced. */
|
||||
native cs_set_weapon_silenced(index, silence = 1);
|
Loading…
Reference in New Issue
Block a user