Merged in karlos's code, fixed potential get_user_weapon problem

This commit is contained in:
David Anderson 2005-11-19 00:34:25 +00:00
parent a8bb28caa4
commit 694d7c118c
3 changed files with 54 additions and 31 deletions

View File

@ -2502,6 +2502,8 @@ PFN_FORMAT g_fn_Format;
PFN_REGISTERFUNCTION g_fn_RegisterFunction;
PFN_REQ_FNPTR g_fn_RequestFunction;
PFN_AMX_PUSH g_fn_AmxPush;
PFN_SET_TEAM_INFO g_fn_SetTeamInfo;
PFN_PLAYER_PROP_ADDR g_fn_PlayerPropAddr;
// *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2611,6 +2613,8 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerFlags", g_fn_GetPlayerFlags, PFN_GETPLAYERFLAGS);
REQFUNC("GetPlayerEdict", g_fn_GetPlayerEdict, PFN_GET_PLAYER_EDICT);
REQFUNC("amx_Push", g_fn_AmxPush, PFN_AMX_PUSH);
REQFUNC("SetPlayerTeamInfo", g_fn_SetTeamInfo, PFN_SET_TEAM_INFO);
REQFUNC("PlayerPropAddr", g_fn_PlayerPropAddr, PFN_PLAYER_PROP_ADDR);
#ifdef MEMORY_TEST
// Memory
@ -2733,6 +2737,8 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerEdict(0);
MF_Format("", 4, "str");
MF_RegisterFunction(NULL, "");
MF_SetPlayerTeamInfo(0, 0, "");
MF_PlayerPropAddr(0, 0);
}
#endif

View File

@ -1927,6 +1927,28 @@ enum ForwardParam
FP_ARRAY, // array; use the return value of prepareArray.
};
enum PlayerProp
{
Player_Name, //String
Player_Ip, //String
Player_Team, //String
Player_Ingame, //bool
Player_Authorized, //bool
Player_Vgui, //bool
Player_Time, //float
Player_Playtime, //float
Player_MenuExpire, //float
Player_Weapons, //struct{int,int}[32]
Player_CurrentWeapon, //int
Player_TeamID, //int
Player_Deaths, //int
Player_Aiming, //int
Player_Menu, //int
Player_Keys, //int
Player_Flags, //int[32]
Player_Newmenu, //int
Player_NewmenuPage, //int
};
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
@ -1978,6 +2000,7 @@ typedef edict_t * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
#else
typedef void * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
#endif
typedef void * (*PFN_PLAYER_PROP_ADDR) (int /*id*/, int /*prop*/);
#ifdef MEMORY_TEST
typedef void * (*PFN_ALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
@ -2003,6 +2026,7 @@ typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
typedef int (*PFN_AMX_PUSH) (AMX * /*amx*/, cell /*value*/);
typedef int (*PFN_SET_TEAM_INFO) (int /*player */, int /*teamid */, const char */*name */);
extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
@ -2066,6 +2090,8 @@ extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
extern PFN_REQ_FNPTR g_fn_RequestFunction;
extern PFN_AMX_PUSH g_fn_AmxPush;
extern PFN_SET_TEAM_INFO g_fn_SetTeamInfo;
extern PFN_PLAYER_PROP_ADDR g_fn_PlayerPropAddr;
#ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems
@ -2126,6 +2152,8 @@ void MF_RegisterFunction (void *pfn, const char *description) { }
void * MF_RequestFunction (const char *description) { }
int MF_AmxPush (AMX *amx, cell *params) { }
int MF_AmxExec (AMX *amx, cell *retval, int idx) { }
int MF_SetPlayerTeamInfo (int id, int teamid, const char *teamname) { }
void * MF_PlayerPropAddr (int id, int prop) { }
#endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives
@ -2191,6 +2219,8 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RegisterFunction g_fn_RegisterFunction
#define MF_RequestFunction g_fn_RequestFunction;
#define MF_AmxPush g_fn_AmxPush
#define MF_SetPlayerTeamInfo g_fn_SetTeamInfo
#define MF_PlayerPropAddr g_fn_PlayerPropAddr
#ifdef MEMORY_TEST
/*** Memory ***/

View File

@ -525,43 +525,30 @@ static cell AMX_NATIVE_CALL strip_user_weapons(AMX *amx, cell *params) { // inde
edict_t* pPlayer = MF_GetPlayerEdict(params[1]);
string_t item = MAKE_STRING("trigger_once");
edict_t *pent = CREATE_NAMED_ENTITY( item );
if ( FNullEnt( pent ) ){
string_t item = MAKE_STRING("player_weaponstrip");
edict_t *pent = CREATE_NAMED_ENTITY(item);
if (FNullEnt(pent))
{
return 0;
}
KeyValueData pkvd;
pkvd.szClassName = (char *)STRING(pent->v.classname);
pkvd.szKeyName = "target"; // type
pkvd.szValue = "stripper";
pkvd.fHandled = false;
MDLL_KeyValue(pent, &pkvd);
MDLL_Spawn(pent);
item = MAKE_STRING("player_weaponstrip");
edict_t *pent2 = CREATE_NAMED_ENTITY( item );
if ( FNullEnt( pent2 ) ) {
return 0;
}
pkvd.szClassName = (char *)STRING(pent->v.classname);
pkvd.szKeyName = "targetname"; // type
pkvd.szValue = "stripper";
pkvd.fHandled = false;
MDLL_KeyValue(pent2, &pkvd);
MDLL_Spawn(pent2);
pent->v.origin = pPlayer->v.origin;
MDLL_Touch(pent, pPlayer);
MDLL_Use(pPlayer, pent);
REMOVE_ENTITY(pent);
REMOVE_ENTITY(pent2);
void *_cur = MF_PlayerPropAddr(params[1], Player_CurrentWeapon);
void *_wpns = MF_PlayerPropAddr(params[1], Player_Weapons);
typedef struct {
int a;
int b;
} WPN;
WPN *wpns = (WPN *)_wpns;
int *cur = (int *)_cur;
*cur = 0;
wpns[0].a = 0;
wpns[0].b = 0;
pPlayer->v.weapons = 0;
return 1;