From 75ce4c395aa30634cef4ef5e6cc076e21e8614ff Mon Sep 17 00:00:00 2001 From: Drifter Date: Tue, 10 Sep 2013 13:08:14 -0400 Subject: [PATCH] Add CS_UpdateClientModel native to cstrike extension (bug 5905, r=psychonic). --- extensions/cstrike/natives.cpp | 20 ++++++++++++++++++++ gamedata/sm-cstrike.games/game.csgo.txt | 7 +++++++ gamedata/sm-cstrike.games/game.css.txt | 7 +++++++ plugins/include/cstrike.inc | 10 ++++++++++ 4 files changed, 44 insertions(+) diff --git a/extensions/cstrike/natives.cpp b/extensions/cstrike/natives.cpp index 6f02b719..da7b23f2 100644 --- a/extensions/cstrike/natives.cpp +++ b/extensions/cstrike/natives.cpp @@ -787,6 +787,25 @@ static cell_t CS_GetClientAssists(IPluginContext *pContext, const cell_t *params #endif } +static cell_t CS_UpdateClientModel(IPluginContext *pContext, const cell_t *params) +{ + static ICallWrapper *pWrapper = NULL; + if (!pWrapper) + { + REGISTER_NATIVE_ADDR("SetModelFromClass", + pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, NULL, 0)); + } + + CBaseEntity *pEntity; + if (!(pEntity=GetCBaseEntity(params[1], true))) + { + return pContext->ThrowNativeError("Client index %d is not valid", params[1]); + } + + pWrapper->Execute(&pEntity, NULL); + + return 1; +} sp_nativeinfo_t g_CSNatives[] = { {"CS_RespawnPlayer", CS_RespawnPlayer}, @@ -807,6 +826,7 @@ sp_nativeinfo_t g_CSNatives[] = {"CS_SetClientContributionScore", CS_SetClientContributionScore}, {"CS_GetClientAssists", CS_GetClientAssists}, {"CS_SetClientAssists", CS_SetClientAssists}, + {"CS_UpdateClientModel", CS_UpdateClientModel}, {"CS_IsValidWeaponID", CS_IsValidWeaponID}, {NULL, NULL} }; diff --git a/gamedata/sm-cstrike.games/game.csgo.txt b/gamedata/sm-cstrike.games/game.csgo.txt index 2d6368ee..dfa87219 100644 --- a/gamedata/sm-cstrike.games/game.csgo.txt +++ b/gamedata/sm-cstrike.games/game.csgo.txt @@ -138,6 +138,13 @@ "linux" "@_ZNK16FileWeaponInfo_t15GetAttributeIntEPKcPK13CEconItemView" "mac" "@_ZNK16FileWeaponInfo_t15GetAttributeIntEPKcPK13CEconItemView" } + "SetModelFromClass" + { + "library" "server" + "windows" "\x55\x8B\xEC\x51\x53\x56\x8B\xF1\x57\xB9\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x8B\xD8" + "linux" "@_ZN9CCSPlayer17SetModelFromClassEv" + "mac" "@_ZN9CCSPlayer17SetModelFromClassEv" + } } } diff --git a/gamedata/sm-cstrike.games/game.css.txt b/gamedata/sm-cstrike.games/game.css.txt index b6be24e2..252a3b12 100644 --- a/gamedata/sm-cstrike.games/game.css.txt +++ b/gamedata/sm-cstrike.games/game.css.txt @@ -138,6 +138,13 @@ "linux" "@_ZN12CCSGameRules13CheckWinLimitEv" "mac" "@_ZN12CCSGameRules5ThinkEv" } + "SetModelFromClass" + { + "library" "server" + "windows" "\x55\x8B\xEC\x83\xEC\x2C\x89\x4D\xD4\x8B\x4D\xD4\xE8\x2A\x2A\x2A\x2A\x83\xF8\x02\x0F\x85\x2A\x2A\x2A\x2A\x8B" + "linux" "@_ZN9CCSPlayer17SetModelFromClassEv" + "mac" "@_ZN9CCSPlayer17SetModelFromClassEv" + } } } diff --git a/plugins/include/cstrike.inc b/plugins/include/cstrike.inc index 94219800..7c1f33b7 100644 --- a/plugins/include/cstrike.inc +++ b/plugins/include/cstrike.inc @@ -367,6 +367,15 @@ native CS_WeaponIDToAlias(CSWeaponID:weaponID, String:destination[], len); */ native bool:CS_IsValidWeaponID(CSWeaponID:id); +/** + * Sets a player's model based on their current class + * + * @param client Player's index. + * @noreturn + * @error Invalid client index, client not in game. + */ +native CS_UpdateClientModel(client); + /** * Do not edit below this line! */ @@ -404,6 +413,7 @@ public __ext_cstrike_SetNTVOptional() MarkNativeAsOptional("CS_AliasToWeaponID"); MarkNativeAsOptional("CS_WeaponIDToAlias"); MarkNativeAsOptional("CS_IsValidWeaponID"); + MarkNativeAsOptional("CS_UpdateClientModel"); } #endif