From e8c4c14f40c895887edffeae7562f2839676b7e4 Mon Sep 17 00:00:00 2001 From: s1lent Date: Fri, 3 Feb 2017 17:41:05 +0700 Subject: [PATCH] Reworked rg_remove_items_by_slot, rg_reset_user_model Ignore VS2015 files. --- .gitignore | 3 +++ reapi/msvc/reapi.vcxproj | 6 +++--- reapi/src/natives/natives_misc.cpp | 31 +++++++++++++++++++++++------- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 0b9d28e..9575227 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,10 @@ **/msvc/*.opensdf **/msvc/*.user **/msvc/*.suo +**/msvc/*.db +**/msvc/*.opendb **/msvc/*.aps +**/msvc/.vs **/msvc/START*.bat **/msvc/ipch **/PublishPath*.txt diff --git a/reapi/msvc/reapi.vcxproj b/reapi/msvc/reapi.vcxproj index 6e3ac38..3eeb92d 100644 --- a/reapi/msvc/reapi.vcxproj +++ b/reapi/msvc/reapi.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -288,13 +288,13 @@ DynamicLibrary true - v120_xp + v140_xp MultiByte DynamicLibrary false - v120_xp + v140_xp true MultiByte diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index 0873dee..ad310e7 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -807,8 +807,12 @@ cell AMX_NATIVE_CALL rg_remove_items_by_slot(AMX *amx, cell *params) pPlayer->ForEachItem(params[arg_slot], [pPlayer](CBasePlayerItem *pItem) { - if (pItem->IsWeapon() && pItem == pPlayer->m_pActiveItem) { - ((CBasePlayerWeapon *)pItem)->RetireWeapon(); + if (pItem->IsWeapon()) { + if (pItem == pPlayer->m_pActiveItem) { + ((CBasePlayerWeapon *)pItem)->RetireWeapon(); + } + + pPlayer->m_rgAmmo[ pItem->PrimaryAmmoIndex() ] = 0; } if (pPlayer->RemovePlayerItem(pItem)) { @@ -890,10 +894,11 @@ cell AMX_NATIVE_CALL rg_internal_cmd(AMX *amx, cell *params) CHECK_ISPLAYER(arg_index); CBasePlayer *pPlayer = UTIL_PlayerByIndex(params[arg_index]); - CHECK_CONNECTED(pPlayer, arg_index); + if (unlikely(pPlayer == nullptr || pPlayer->has_disconnected)) { + return FALSE; + } pPlayer->CSPlayer()->ClientCommand(getAmxString(amx, params[arg_cmd]), getAmxString(amx, params[arg_arg])); - return TRUE; } @@ -1235,7 +1240,7 @@ cell AMX_NATIVE_CALL rg_set_user_model(AMX *amx, cell *params) if (params[arg_update] != 0) { - char model[260]; + char model[MAX_PATH]; snprintf(model, sizeof(model), "models/player/%s/%s.mdl", newModel, newModel); pPlayer->CSPlayer()->SetNewPlayerModel(model); } @@ -1247,14 +1252,15 @@ cell AMX_NATIVE_CALL rg_set_user_model(AMX *amx, cell *params) * Reset model user * * @param index Client index +* @param update_index If true, the modelindex is reseted as well * * @return 1 if successfully, 0 otherwise * -* native rg_reset_user_model(const index); +* native rg_reset_user_model(const index, const bool:update_index = false); */ cell AMX_NATIVE_CALL rg_reset_user_model(AMX *amx, cell *params) { - enum args_e { arg_count, arg_index, arg_team, arg_model }; + enum args_e { arg_count, arg_index, arg_update }; CHECK_ISPLAYER(arg_index); @@ -1263,6 +1269,17 @@ cell AMX_NATIVE_CALL rg_reset_user_model(AMX *amx, cell *params) pPlayer->CSPlayer()->SetPlayerModelEx(""); pPlayer->CSPlayer()->SetPlayerModel(pPlayer->m_bHasC4); + + if (params[arg_update] != 0) + { + char *infobuffer = GET_INFO_BUFFER(pPlayer->edict()); + char *pModel = GET_KEY_VALUE(infobuffer, "model"); + + char model[MAX_PATH]; + snprintf(model, sizeof(model), "models/player/%s/%s.mdl", pModel, pModel); + pPlayer->CSPlayer()->SetNewPlayerModel(model); + } + return TRUE; }