diff --git a/extensions/cstrike/AMBuilder b/extensions/cstrike/AMBuilder
index 6ff16fb38..151119d88 100644
--- a/extensions/cstrike/AMBuilder
+++ b/extensions/cstrike/AMBuilder
@@ -1,25 +1,28 @@
# vim: set ts=2 sw=2 tw=99 noet ft=python:
import os
-sdk = SM.sdkInfo['ep2v']
+sdks = ['ep2v', 'csgo']
-if AMBuild.target['platform'] in sdk['platform']:
- compiler = SM.DefaultHL2Compiler('extensions/cstrike', 'ep2v')
+for i in sdks:
+ sdk = SM.sdkInfo[i]
+ if AMBuild.target['platform'] in sdk['platform']:
+ compiler = SM.DefaultHL2Compiler('extensions/cstrike', i)
- name = 'game.cstrike.ext.' + sdk['ext']
- extension = AMBuild.AddJob(name)
- binary = Cpp.LibraryBuilder(name, AMBuild, extension, compiler)
- SM.PreSetupHL2Job(extension, binary, 'ep2v')
- binary.AddSourceFiles('extensions/cstrike', [
- 'extension.cpp',
- 'natives.cpp',
- 'RegNatives.cpp',
- 'timeleft.cpp',
- 'forwards.cpp',
- 'sdk/smsdk_ext.cpp',
- 'CDetour/detours.cpp',
- 'asm/asm.c'
- ])
- SM.PostSetupHL2Job(extension, binary, 'ep2v')
- SM.AutoVersion('extensions/cstrike', binary)
- binary.SendToJob()
\ No newline at end of file
+ name = 'game.cstrike.ext.' + sdk['ext']
+ extension = AMBuild.AddJob(name)
+ binary = Cpp.LibraryBuilder(name, AMBuild, extension, compiler)
+ SM.PreSetupHL2Job(extension, binary, i)
+ binary.AddSourceFiles('extensions/cstrike', [
+ 'extension.cpp',
+ 'natives.cpp',
+ 'RegNatives.cpp',
+ 'timeleft.cpp',
+ 'forwards.cpp',
+ 'util_cstrike.cpp',
+ 'sdk/smsdk_ext.cpp',
+ 'CDetour/detours.cpp',
+ 'asm/asm.c'
+ ])
+ SM.PostSetupHL2Job(extension, binary, i)
+ SM.AutoVersion('extensions/cstrike', binary)
+ binary.SendToJob()
\ No newline at end of file
diff --git a/extensions/cstrike/extension.cpp b/extensions/cstrike/extension.cpp
index 7fbdfc8d9..ea91621cf 100644
--- a/extensions/cstrike/extension.cpp
+++ b/extensions/cstrike/extension.cpp
@@ -59,9 +59,9 @@ ISDKTools *g_pSDKTools = NULL;
bool CStrike::SDK_OnLoad(char *error, size_t maxlength, bool late)
{
- if (strcmp(g_pSM->GetGameFolderName(), "cstrike") != 0)
+ if (strcmp(g_pSM->GetGameFolderName(), "cstrike") != 0 && strcmp(g_pSM->GetGameFolderName(), "csgo") != 0)
{
- snprintf(error, maxlength, "Cannot Load Cstrike Extension on mods other than CS:S");
+ snprintf(error, maxlength, "Cannot Load Cstrike Extension on mods other than CS:S and CS:GO");
return false;
}
@@ -73,7 +73,7 @@ bool CStrike::SDK_OnLoad(char *error, size_t maxlength, bool late)
{
if (error)
{
- snprintf(error, maxlength, "Could not read sm-cstrike.games.txt: %s", conf_error);
+ snprintf(error, maxlength, "Could not read sm-cstrike.games: %s", conf_error);
}
return false;
}
diff --git a/extensions/cstrike/extension.h b/extensions/cstrike/extension.h
index f311fd8c4..3ffb9a3df 100644
--- a/extensions/cstrike/extension.h
+++ b/extensions/cstrike/extension.h
@@ -44,12 +44,22 @@
int CallPriceForward(int client, const char *weapon_name, int price);
+#if SOURCE_ENGINE == SE_CSGO
+#define WEAPON_C4 49
+#define WEAPON_KNIFE 42
+#define WEAPON_KNIFE_GG 41
+#define WEAPON_KEVLAR 50
+#define WEAPON_ASSAULTSUIT 51
+#define WEAPON_NIGHTVISION 52
+#define WEAPON_DEFUSER 53
+#else
#define WEAPON_C4 6
#define WEAPON_KNIFE 28
#define WEAPON_SHIELD 30
#define WEAPON_KEVLAR 31
#define WEAPON_ASSAULTSUIT 32
#define WEAPON_NIGHTVISION 33
+#endif
/**
* @brief Sample implementation of the SDK Extension.
diff --git a/extensions/cstrike/forwards.cpp b/extensions/cstrike/forwards.cpp
index b725e6763..19533608a 100644
--- a/extensions/cstrike/forwards.cpp
+++ b/extensions/cstrike/forwards.cpp
@@ -1,5 +1,6 @@
#include "extension.h"
#include "forwards.h"
+#include "util_cstrike.h"
bool g_pTerminateRoundDetoured = false;
bool g_pCSWeaponDropDetoured = false;
@@ -37,11 +38,27 @@ DETOUR_DECL_MEMBER1(DetourHandleBuy, int, const char *, weapon)
lastclient = -1;
return 0;
}
+
+#if SOURCE_ENGINE == SE_CSGO
+ int defaultprice = -1;
+ if (g_iPriceOffset != -1 && g_PriceDetoured)
+ {
+ defaultprice = CallPriceForwardCSGO(client, weapon);
+ }
+#endif
+
int val = DETOUR_MEMBER_CALL(DetourHandleBuy)(weapon);
+
+#if SOURCE_ENGINE == SE_CSGO
+ if (defaultprice != -1)
+ SetWeaponPrice(weapon, defaultprice);
+#endif
+
lastclient = -1;
return val;
}
+#if SOURCE_ENGINE != SE_CSGO
DETOUR_DECL_MEMBER0(DetourWeaponPrice, int)
{
int price = DETOUR_MEMBER_CALL(DetourWeaponPrice)();
@@ -53,6 +70,7 @@ DETOUR_DECL_MEMBER0(DetourWeaponPrice, int)
return CallPriceForward(lastclient, weapon_name, price);
}
+#endif
DETOUR_DECL_MEMBER2(DetourTerminateRound, void, float, delay, int, reason)
{
@@ -79,6 +97,7 @@ DETOUR_DECL_MEMBER2(DetourTerminateRound, void, float, delay, int, reason)
return DETOUR_MEMBER_CALL(DetourTerminateRound)(orgdelay, orgreason);
}
+
DETOUR_DECL_MEMBER3(DetourCSWeaponDrop, void, CBaseEntity *, weapon, bool, something, bool, toss)
{
if (g_pIgnoreCSWeaponDropDetour)
@@ -102,6 +121,7 @@ DETOUR_DECL_MEMBER3(DetourCSWeaponDrop, void, CBaseEntity *, weapon, bool, somet
return;
}
+
bool CreateWeaponPriceDetour()
{
if (weaponNameOffset == -1)
@@ -112,6 +132,29 @@ bool CreateWeaponPriceDetour()
return false;
}
}
+
+#if SOURCE_ENGINE == SE_CSGO
+ if (g_iPriceOffset == -1)
+ {
+ if (!g_pGameConf->GetOffset("WeaponPrice", &g_iPriceOffset))
+ {
+ g_iPriceOffset = -1;
+ g_pSM->LogError(myself, "Failed to get WeaponPrice offset - Disabled OnGetWeaponPrice forward");
+ return false;
+ }
+ }
+ if (!CreateHandleBuyDetour())
+ {
+ g_pSM->LogError(myself, "HandleCommand_Buy_Internal failed to detour, disabled OnGetWeaponPrice forward.");
+ return false;
+ }
+ else
+ {
+ g_PriceDetoured = true;
+ return true;
+ }
+#else
+
DWeaponPrice = DETOUR_CREATE_MEMBER(DetourWeaponPrice, "GetWeaponPrice");
if (DWeaponPrice != NULL)
@@ -129,6 +172,7 @@ bool CreateWeaponPriceDetour()
g_pSM->LogError(myself, "GetWeaponPrice detour could not be initialized - Disabled OnGetWeaponPrice forward.");
return false;
+#endif
}
bool CreateTerminateRoundDetour()
@@ -179,13 +223,14 @@ bool CreateCSWeaponDropDetour()
void RemoveWeaponPriceDetour()
{
+#if SOURCE_ENGINE != SE_CSGO
if (DWeaponPrice != NULL)
{
DWeaponPrice->Destroy();
DWeaponPrice = NULL;
}
g_PriceDetoured = false;
-
+#endif
}
void RemoveHandleBuyDetour()
@@ -220,6 +265,85 @@ void RemoveCSWeaponDropDetour()
}
g_pCSWeaponDropDetoured = false;
}
+
+#if SOURCE_ENGINE == SE_CSGO
+bool SetWeaponPrice(int weaponID, int price)
+{
+ void *info = GetWeaponInfo(weaponID);
+ if (!info)
+ {
+ return false;
+ }
+ *(int *)((intptr_t)info+g_iPriceOffset) = price;
+ return true;
+}
+
+bool SetWeaponPrice(const char *weapon, int price)
+{
+ const char *weaponalias = GetTranslatedWeaponAlias(weapon);
+ int weaponID = AliasToWeaponID(weaponalias);
+ if (weaponID <= 0)
+ {
+ return false;
+ }
+ void *info = GetWeaponInfo(weaponID);
+ if (!info)
+ {
+ return false;
+ }
+ *(int *)((intptr_t)info+g_iPriceOffset) = price;
+ return true;
+
+}
+
+int CallPriceForwardCSGO(int client, const char *weapon, int price)
+{
+ int changedprice = price;
+ cell_t result = Pl_Continue;
+
+ g_pPriceForward->PushCell(client);
+ g_pPriceForward->PushString(weapon);
+ g_pPriceForward->PushCellByRef(&changedprice);
+ g_pPriceForward->Execute(&result);
+
+ if (result == Pl_Continue)
+ return price;
+
+ return changedprice;
+}
+
+int CallPriceForwardCSGO(int client, const char *weapon)
+{
+ const char *weaponalias = GetTranslatedWeaponAlias(weapon);
+ int weaponID = AliasToWeaponID(weaponalias);
+ if (weaponID <= 0)
+ {
+ return -1;
+ }
+ void *info = GetWeaponInfo(weaponID);
+ if (!info)
+ {
+ return -1;
+ }
+ const char *weapon_name = (const char *)((intptr_t)info + weaponNameOffset);
+ int price = *(int *)((intptr_t)info + g_iPriceOffset);
+ int changedprice = price;
+ cell_t result = Pl_Continue;
+
+ g_pPriceForward->PushCell(client);
+ g_pPriceForward->PushString(weapon_name);
+ g_pPriceForward->PushCellByRef(&changedprice);
+ g_pPriceForward->Execute(&result);
+
+ if (result == Pl_Continue)
+ return -1;
+ if (SetWeaponPrice(weaponID, changedprice))
+ return price;
+ else
+ return -1;
+}
+#else
+
int CallPriceForward(int client, const char *weapon_name, int price)
{
int changedprice = price;
@@ -236,3 +360,4 @@ int CallPriceForward(int client, const char *weapon_name, int price)
return changedprice;
}
+#endif
diff --git a/extensions/cstrike/forwards.h b/extensions/cstrike/forwards.h
index 785c3224c..3cd8161e1 100644
--- a/extensions/cstrike/forwards.h
+++ b/extensions/cstrike/forwards.h
@@ -9,9 +9,17 @@ void RemoveHandleBuyDetour();
void RemoveTerminateRoundDetour();
void RemoveCSWeaponDropDetour();
+#if SOURCE_ENGINE == SE_CSGO
+bool SetWeaponPrice(int weaponID, int price);
+bool SetWeaponPrice(const char *weapon, int price);
+int CallPriceForwardCSGO(int client, const char *weapon);
+int CallPriceForwardCSGO(int client, const char *weapon, int price);
+#endif
+
extern IServerGameEnts *gameents;
extern IForward *g_pHandleBuyForward;
extern IForward *g_pPriceForward;
extern IForward *g_pTerminateRoundForward;
extern IForward *g_pCSWeaponDropForward;
+extern int g_iPriceOffset;
#endif //_INCLUDE_CSTRIKE_FORWARDS_H_
diff --git a/extensions/cstrike/msvc10/cstrike.vcxproj b/extensions/cstrike/msvc10/cstrike.vcxproj
index b744db53b..93549fa4e 100644
--- a/extensions/cstrike/msvc10/cstrike.vcxproj
+++ b/extensions/cstrike/msvc10/cstrike.vcxproj
@@ -476,6 +476,7 @@
+
@@ -485,6 +486,7 @@
+
diff --git a/extensions/cstrike/msvc10/cstrike.vcxproj.filters b/extensions/cstrike/msvc10/cstrike.vcxproj.filters
index 45511d9b3..b33e18f24 100644
--- a/extensions/cstrike/msvc10/cstrike.vcxproj.filters
+++ b/extensions/cstrike/msvc10/cstrike.vcxproj.filters
@@ -39,6 +39,9 @@
Source Files
+
+ Source Files
+
SourceMod SDK
@@ -62,6 +65,9 @@
Header Files
+
+ Header Files
+
SourceMod SDK
diff --git a/extensions/cstrike/msvc9/cstrike.vcproj b/extensions/cstrike/msvc9/cstrike.vcproj
index f08b6bfd5..aa35c79ae 100644
--- a/extensions/cstrike/msvc9/cstrike.vcproj
+++ b/extensions/cstrike/msvc9/cstrike.vcproj
@@ -537,7 +537,7 @@
Name="VCCLCompilerTool"
AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_ORANGEBOXVALVE=6 /D SE_LEFT4DEAD=7 /D SE_LEFT4DEAD2=8 /D SE_ALIENSWARM=9 /D SE_PORTAL2=10 /D SE_CSGO=11 /D COMPILER_MSVC /D COMPILER_MSVC32"
Optimization="0"
- AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;..\..\..\public\extensions;"$(HL2SDK-CSGO)\public";"$(HL2SDK-CSGO)\public\game\server";"$(HL2SDK-CSGO)\public\engine";"$(HL2SDK-CSGO)\public\tier0";"$(HL2SDK-CSGO)\public\tier1";"$(MMSOURCE18)\core";"$(MMSOURCE18)\core\sourcehook""
+ AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;..\..\..\public\extensions;"$(HL2SDKCSGO)\public";"$(HL2SDKCSGO)\public\game\server";"$(HL2SDKCSGO)\public\engine";"$(HL2SDKCSGO)\public\tier0";"$(HL2SDKCSGO)\public\tier1";"$(MMSOURCE18)\core";"$(MMSOURCE18)\core\sourcehook""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=11"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -561,7 +561,7 @@
/>
+
+
+
+
+int g_iPriceOffset = -1;
+
#define REGISTER_NATIVE_ADDR(name, code) \
void *addr; \
if (!g_pGameConf->GetMemSig(name, &addr) || !addr) \
@@ -44,7 +48,7 @@
inline CBaseEntity *GetCBaseEntity(int num, bool isplayer)
{
- edict_t *pEdict = engine->PEntityOfEntIndex(num);
+ edict_t *pEdict = gamehelpers->EdictOfIndex(num);
if (!pEdict || pEdict->IsFree())
{
return NULL;
@@ -292,35 +296,13 @@ static cell_t CS_TerminateRound(IPluginContext *pContext, const cell_t *params)
static cell_t CS_GetTranslatedWeaponAlias(IPluginContext *pContext, const cell_t *params)
{
- static ICallWrapper *pWrapper = NULL;
-
- if (!pWrapper)
- {
- REGISTER_NATIVE_ADDR("GetTranslatedWeaponAlias",
- PassInfo pass[1]; \
- PassInfo retpass[1]; \
- pass[0].flags = PASSFLAG_BYVAL; \
- pass[0].type = PassType_Basic; \
- pass[0].size = sizeof(char *); \
- retpass[0].flags = PASSFLAG_BYVAL; \
- retpass[0].type = PassType_Basic; \
- retpass[0].size = sizeof(char *); \
- pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass[0], pass, 1))
- }
- char *dest, *weapon;
+ char *weapon;
+ char *dest;
pContext->LocalToString(params[2], &dest);
pContext->LocalToString(params[1], &weapon);
- char *ret = new char[128];
-
- unsigned char vstk[sizeof(char *)];
- unsigned char *vptr = vstk;
-
- *(char **)vptr = weapon;
-
- pWrapper->Execute(vstk, &ret);
-
+ const char *ret = GetTranslatedWeaponAlias(weapon);
strncopy(dest, ret, params[3]);
return 1;
@@ -329,34 +311,31 @@ static cell_t CS_GetTranslatedWeaponAlias(IPluginContext *pContext, const cell_t
static cell_t CS_GetWeaponPrice(IPluginContext *pContext, const cell_t *params)
{
//Hard code return values for weapons that dont call GetWeaponPrice and always use default value.
- if (params[2] == WEAPON_C4 || params[2] == WEAPON_KNIFE || params[2] == WEAPON_SHIELD)
+ int id = GetRealWeaponID(params[2]);
+#if SOURCE_ENGINE == SE_CSGO
+ if (id == WEAPON_C4 || id == WEAPON_KNIFE || id == WEAPON_KNIFE_GG)
+#else
+ if (id == WEAPON_C4 || id == WEAPON_KNIFE || id == WEAPON_SHIELD)
+#endif
return 0;
- if (params[2] == WEAPON_KEVLAR)
+ if (id == WEAPON_KEVLAR)
return 650;
- if (params[2] == WEAPON_ASSAULTSUIT)
+ if (id == WEAPON_ASSAULTSUIT)
return 1000;
- if (params[2] == WEAPON_NIGHTVISION)
+ if (id == WEAPON_NIGHTVISION)
return 1250;
+#if SOURCE_ENGINE == SE_CSGO
+ if (id == WEAPON_DEFUSER)
+ return 200;
+#endif
+ if (id == 0)
+ return 0;
- static ICallWrapper *pWrapper = NULL;
- static int priceOffset = -1;
- if (!pWrapper)
+ if (g_iPriceOffset == -1)
{
- REGISTER_NATIVE_ADDR("GetWeaponInfo",
- PassInfo pass[1]; \
- PassInfo retpass[1]; \
- pass[0].flags = PASSFLAG_BYVAL; \
- pass[0].type = PassType_Basic; \
- pass[0].size = sizeof(int); \
- retpass[0].flags = PASSFLAG_BYVAL; \
- retpass[0].type = PassType_Basic; \
- retpass[0].size = sizeof(void *); \
- pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass[0], pass, 1))
- }
- if (priceOffset == -1)
- {
- if (!g_pGameConf->GetOffset("WeaponPrice", &priceOffset))
+ if (!g_pGameConf->GetOffset("WeaponPrice", &g_iPriceOffset))
{
+ g_iPriceOffset = -1;
return pContext->ThrowNativeError("Failed to get WeaponPrice offset");
}
}
@@ -367,30 +346,31 @@ static cell_t CS_GetWeaponPrice(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("Client index %d is not valid", params[1]);
}
- void *info;
-
- unsigned char vstk[sizeof(int)];
- unsigned char *vptr = vstk;
-
- *(int *)vptr = params[2];
-
- pWrapper->Execute(vstk, &info);
-
+ void *info = GetWeaponInfo(params[2]);
if (!info)
return pContext->ThrowNativeError("Failed to get weaponinfo");
- int price = *(int *)((intptr_t)info + priceOffset);
+ int price = *(int *)((intptr_t)info + g_iPriceOffset);
if (params[3] || weaponNameOffset == -1)
return price;
const char *weapon_name = (const char *)((intptr_t)info + weaponNameOffset);
+#if SOURCE_ENGINE == SE_CSGO
+ return CallPriceForwardCSGO(params[1], weapon_name, price);
+#else
return CallPriceForward(params[1], weapon_name, price);
+#endif
}
static cell_t CS_GetClientClanTag(IPluginContext *pContext, const cell_t *params)
{
+#if SOURCE_ENGINE == SE_CSGO
+ size_t len;
+ pContext->StringToLocalUTF8(params[2], params[3], "", &len);
+ return len;
+#else
static void *addr;
if (!addr)
{
@@ -426,10 +406,14 @@ static cell_t CS_GetClientClanTag(IPluginContext *pContext, const cell_t *params
pContext->StringToLocalUTF8(params[2], params[3], src, &len);
return len;
+#endif
}
static cell_t CS_SetClientClanTag(IPluginContext *pContext, const cell_t *params)
{
+#if SOURCE_ENGINE == SE_CSGO
+ return 0;
+#else
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
@@ -464,6 +448,16 @@ static cell_t CS_SetClientClanTag(IPluginContext *pContext, const cell_t *params
pWrapper->Execute(vstk, NULL);
return 1;
+#endif
+}
+
+static cell_t CS_AliasToWeaponID(IPluginContext *pContext, const cell_t *params)
+{
+ char *weapon;
+
+ pContext->LocalToString(params[1], &weapon);
+
+ return GetFakeWeaponID(AliasToWeaponID(weapon));
}
sp_nativeinfo_t g_CSNatives[] =
@@ -476,6 +470,7 @@ sp_nativeinfo_t g_CSNatives[] =
{"CS_GetWeaponPrice", CS_GetWeaponPrice},
{"CS_GetClientClanTag", CS_GetClientClanTag},
{"CS_SetClientClanTag", CS_SetClientClanTag},
+ {"CS_AliasToWeaponID", CS_AliasToWeaponID},
{NULL, NULL}
};
diff --git a/extensions/cstrike/sdk/smsdk_config.h b/extensions/cstrike/sdk/smsdk_config.h
index f56dbfb5c..3105fb772 100644
--- a/extensions/cstrike/sdk/smsdk_config.h
+++ b/extensions/cstrike/sdk/smsdk_config.h
@@ -38,8 +38,8 @@
*/
/* Basic information exposed publicly */
-#define SMEXT_CONF_NAME "CS:S Tools"
-#define SMEXT_CONF_DESCRIPTION "CS:S extended functionality"
+#define SMEXT_CONF_NAME "CS Tools"
+#define SMEXT_CONF_DESCRIPTION "CS extended functionality"
#define SMEXT_CONF_VERSION ""
#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
#define SMEXT_CONF_URL "http://www.sourcemod.net/"
diff --git a/extensions/cstrike/timeleft.h b/extensions/cstrike/timeleft.h
index bb44b91bf..cc00adbca 100644
--- a/extensions/cstrike/timeleft.h
+++ b/extensions/cstrike/timeleft.h
@@ -40,6 +40,9 @@ class TimeLeftEvents : public IGameEventListener2
public:
bool LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background);
virtual void FireGameEvent(IGameEvent *event);
+#if SOURCE_ENGINE >= SE_ALIENSWARM
+ virtual int GetEventDebugID( void ) { return 42; }
+#endif
};
extern TimeLeftEvents g_TimeLeftEvents;
diff --git a/extensions/cstrike/util_cstrike.cpp b/extensions/cstrike/util_cstrike.cpp
new file mode 100644
index 000000000..328a5a78e
--- /dev/null
+++ b/extensions/cstrike/util_cstrike.cpp
@@ -0,0 +1,379 @@
+/**
+ * vim: set ts=4 :
+ * =============================================================================
+ * SourceMod Counter-Strike:Source Extension
+ * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
+ * =============================================================================
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, version 3.0, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ *
+ * As a special exception, AlliedModders LLC gives you permission to link the
+ * code of this program (as well as its derivative works) to "Half-Life 2," the
+ * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
+ * by the Valve Corporation. You must obey the GNU General Public License in
+ * all respects for all other code used. Additionally, AlliedModders LLC grants
+ * this exception to all derivative works. AlliedModders LLC defines further
+ * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
+ * or .
+ *
+ * Version: $Id$
+ */
+
+#include "util_cstrike.h"
+
+#include "extension.h"
+#include "RegNatives.h"
+
+#define REGISTER_ADDR(name, defaultret, code) \
+ void *addr; \
+ if (!g_pGameConf->GetMemSig(name, &addr) || !addr) \
+ { \
+ g_pSM->LogError(myself, "Failed to locate function."); \
+ return defaultret; \
+ } \
+ code; \
+ g_RegNatives.Register(pWrapper);
+
+void *GetWeaponInfo(int weaponID)
+{
+ static ICallWrapper *pWrapper = NULL;
+ if (!pWrapper)
+ {
+ REGISTER_ADDR("GetWeaponInfo", NULL,
+ PassInfo pass[1]; \
+ PassInfo retpass; \
+ pass[0].flags = PASSFLAG_BYVAL; \
+ pass[0].type = PassType_Basic; \
+ pass[0].size = sizeof(int); \
+ retpass.flags = PASSFLAG_BYVAL; \
+ retpass.type = PassType_Basic; \
+ retpass.size = sizeof(void *); \
+ pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, pass, 1))
+ }
+
+ void *info;
+
+ unsigned char vstk[sizeof(int)];
+ unsigned char *vptr = vstk;
+
+ *(int *)vptr = weaponID;
+
+ pWrapper->Execute(vstk, &info);
+
+ return info;
+}
+
+const char *GetTranslatedWeaponAlias(const char *weapon)
+{
+ static ICallWrapper *pWrapper = NULL;
+
+ if (!pWrapper)
+ {
+ REGISTER_ADDR("GetTranslatedWeaponAlias", weapon,
+ PassInfo pass[1]; \
+ PassInfo retpass; \
+ pass[0].flags = PASSFLAG_BYVAL; \
+ pass[0].type = PassType_Basic; \
+ pass[0].size = sizeof(const char *); \
+ retpass.flags = PASSFLAG_BYVAL; \
+ retpass.type = PassType_Basic; \
+ retpass.size = sizeof(const char *); \
+ pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, pass, 1))
+ }
+ const char *ret = new char[128];
+
+ unsigned char vstk[sizeof(const char *)];
+ unsigned char *vptr = vstk;
+
+ *(const char **)vptr = weapon;
+
+ pWrapper->Execute(vstk, &ret);
+
+ return ret;
+}
+
+int AliasToWeaponID(const char *weapon)
+{
+ static ICallWrapper *pWrapper = NULL;
+
+ if (!pWrapper)
+ {
+ REGISTER_ADDR("AliasToWeaponID", 0,
+ PassInfo pass[1]; \
+ PassInfo retpass; \
+ pass[0].flags = PASSFLAG_BYVAL; \
+ pass[0].type = PassType_Basic; \
+ pass[0].size = sizeof(const char *); \
+ retpass.flags = PASSFLAG_BYVAL; \
+ retpass.type = PassType_Basic; \
+ retpass.size = sizeof(int); \
+ pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, pass, 1))
+ }
+ int weaponID = 0;
+
+ unsigned char vstk[sizeof(const char *)];
+ unsigned char *vptr = vstk;
+
+ *(const char **)vptr = weapon;
+
+ pWrapper->Execute(vstk, &weaponID);
+
+ return weaponID;
+}
+int GetRealWeaponID(int weaponId)
+{
+#if SOURCE_ENGINE == SE_CSGO
+ switch((SMCSWeapon)weaponId)
+ {
+ case SMCSWeapon_NONE:
+ return (int)CSGOWeapon_NONE;
+ case SMCSWeapon_DEAGLE:
+ return (int)CSGOWeapon_DEAGLE;
+ case SMCSWeapon_ELITE:
+ return (int)CSGOWeapon_ELITE;
+ case SMCSWeapon_FIVESEVEN:
+ return (int)CSGOWeapon_FIVESEVEN;
+ case SMCSWeapon_GLOCK:
+ return (int)CSGOWeapon_GLOCK;
+ case SMCSWeapon_P228:
+ return (int)CSGOWeapon_P228;
+ case SMCSWeapon_USP:
+ return (int)CSGOWeapon_USP;
+ case SMCSWeapon_AK47:
+ return (int)CSGOWeapon_AK47;
+ case SMCSWeapon_AUG:
+ return (int)CSGOWeapon_AUG;
+ case SMCSWeapon_AWP:
+ return (int)CSGOWeapon_AWP;
+ case SMCSWeapon_FAMAS:
+ return (int)CSGOWeapon_FAMAS;
+ case SMCSWeapon_G3SG1:
+ return (int)CSGOWeapon_G3SG1;
+ case SMCSWeapon_GALIL:
+ return (int)CSGOWeapon_GALIL;
+ case SMCSWeapon_GALILAR:
+ return (int)CSGOWeapon_GALILAR;
+ case SMCSWeapon_M249:
+ return (int)CSGOWeapon_M249;
+ case SMCSWeapon_M3:
+ return (int)CSGOWeapon_M3;
+ case SMCSWeapon_M4A1:
+ return (int)CSGOWeapon_M4A1;
+ case SMCSWeapon_MAC10:
+ return (int)CSGOWeapon_MAC10;
+ case SMCSWeapon_MP5NAVY:
+ return (int)CSGOWeapon_MP5NAVY;
+ case SMCSWeapon_P90:
+ return (int)CSGOWeapon_P90;
+ case SMCSWeapon_SCOUT:
+ return (int)CSGOWeapon_SCOUT;
+ case SMCSWeapon_SG550:
+ return (int)CSGOWeapon_SG550;
+ case SMCSWeapon_SG552:
+ return (int)CSGOWeapon_SG552;
+ case SMCSWeapon_TMP:
+ return (int)CSGOWeapon_TMP;
+ case SMCSWeapon_UMP45:
+ return (int)CSGOWeapon_UMP45;
+ case SMCSWeapon_XM1014:
+ return (int)CSGOWeapon_XM1014;
+ case SMCSWeapon_BIZON:
+ return (int)CSGOWeapon_BIZON;
+ case SMCSWeapon_MAG7:
+ return (int)CSGOWeapon_MAG7;
+ case SMCSWeapon_NEGEV:
+ return (int)CSGOWeapon_NEGEV;
+ case SMCSWeapon_SAWEDOFF:
+ return (int)CSGOWeapon_SAWEDOFF;
+ case SMCSWeapon_TEC9:
+ return (int)CSGOWeapon_TEC9;
+ case SMCSWeapon_TASER:
+ return (int)CSGOWeapon_TASER;
+ case SMCSWeapon_HKP2000:
+ return (int)CSGOWeapon_HKP2000;
+ case SMCSWeapon_MP7:
+ return (int)CSGOWeapon_MP7;
+ case SMCSWeapon_MP9:
+ return (int)CSGOWeapon_MP9;
+ case SMCSWeapon_NOVA:
+ return (int)CSGOWeapon_NOVA;
+ case SMCSWeapon_P250:
+ return (int)CSGOWeapon_P250;
+ case SMCSWeapon_SCAR17:
+ return (int)CSGOWeapon_SCAR17;
+ case SMCSWeapon_SCAR20:
+ return (int)CSGOWeapon_SCAR20;
+ case SMCSWeapon_SG556:
+ return (int)CSGOWeapon_SG556;
+ case SMCSWeapon_SSG08:
+ return (int)CSGOWeapon_SSG08;
+ case SMCSWeapon_KNIFE_GG:
+ return (int)CSGOWeapon_KNIFE_GG;
+ case SMCSWeapon_KNIFE:
+ return (int)CSGOWeapon_KNIFE;
+ case SMCSWeapon_FLASHBANG:
+ return (int)CSGOWeapon_FLASHBANG;
+ case SMCSWeapon_HEGRENADE:
+ return (int)CSGOWeapon_HEGRENADE;
+ case SMCSWeapon_SMOKEGRENADE:
+ return (int)CSGOWeapon_SMOKEGRENADE;
+ case SMCSWeapon_MOLOTOV:
+ return (int)CSGOWeapon_MOLOTOV;
+ case SMCSWeapon_DECOY:
+ return (int)CSGOWeapon_DECOY;
+ case SMCSWeapon_INCGRENADE:
+ return (int)CSGOWeapon_INCGRENADE;
+ case SMCSWeapon_C4:
+ return (int)CSGOWeapon_C4;
+ case SMCSWeapon_KEVLAR:
+ return (int)CSGOWeapon_KEVLAR;
+ case SMCSWeapon_ASSAULTSUIT:
+ return (int)CSGOWeapon_ASSAULTSUIT;
+ case SMCSWeapon_NIGHTVISION:
+ return (int)CSGOWeapon_NVG;
+ case SMCSWeapon_DEFUSER:
+ return (int)CSGOWeapon_DEFUSER;
+ default:
+ return 0;
+ }
+#else
+ if (weaponId > 33 || weaponId < 0)
+ return 0;
+ else
+ return weaponId;
+#endif
+}
+
+int GetFakeWeaponID(int weaponId)
+{
+#if SOURCE_ENGINE == SE_CSGO
+ switch((CSGOWeapon)weaponId)
+ {
+ case CSGOWeapon_NONE:
+ return (int)SMCSWeapon_NONE;
+ case CSGOWeapon_DEAGLE:
+ return (int)SMCSWeapon_DEAGLE;
+ case CSGOWeapon_ELITE:
+ return (int)SMCSWeapon_ELITE;
+ case CSGOWeapon_FIVESEVEN:
+ return (int)SMCSWeapon_FIVESEVEN;
+ case CSGOWeapon_GLOCK:
+ return (int)SMCSWeapon_GLOCK;
+ case CSGOWeapon_P228:
+ return (int)SMCSWeapon_P228;
+ case CSGOWeapon_USP:
+ return (int)SMCSWeapon_USP;
+ case CSGOWeapon_AK47:
+ return (int)SMCSWeapon_AK47;
+ case CSGOWeapon_AUG:
+ return (int)SMCSWeapon_AUG;
+ case CSGOWeapon_AWP:
+ return (int)SMCSWeapon_AWP;
+ case CSGOWeapon_FAMAS:
+ return (int)SMCSWeapon_FAMAS;
+ case CSGOWeapon_G3SG1:
+ return (int)SMCSWeapon_G3SG1;
+ case CSGOWeapon_GALIL:
+ return (int)SMCSWeapon_GALIL;
+ case CSGOWeapon_GALILAR:
+ return (int)SMCSWeapon_GALILAR;
+ case CSGOWeapon_M249:
+ return (int)SMCSWeapon_M249;
+ case CSGOWeapon_M3:
+ return (int)SMCSWeapon_M3;
+ case CSGOWeapon_M4A1:
+ return (int)SMCSWeapon_M4A1;
+ case CSGOWeapon_MAC10:
+ return (int)SMCSWeapon_MAC10;
+ case CSGOWeapon_MP5NAVY:
+ return (int)SMCSWeapon_MP5NAVY;
+ case CSGOWeapon_P90:
+ return (int)SMCSWeapon_P90;
+ case CSGOWeapon_SCOUT:
+ return (int)SMCSWeapon_SCOUT;
+ case CSGOWeapon_SG550:
+ return (int)SMCSWeapon_SG550;
+ case CSGOWeapon_SG552:
+ return (int)SMCSWeapon_SG552;
+ case CSGOWeapon_TMP:
+ return (int)SMCSWeapon_TMP;
+ case CSGOWeapon_UMP45:
+ return (int)SMCSWeapon_UMP45;
+ case CSGOWeapon_XM1014:
+ return (int)SMCSWeapon_XM1014;
+ case CSGOWeapon_BIZON:
+ return (int)SMCSWeapon_BIZON;
+ case CSGOWeapon_MAG7:
+ return (int)SMCSWeapon_MAG7;
+ case CSGOWeapon_NEGEV:
+ return (int)SMCSWeapon_NEGEV;
+ case CSGOWeapon_SAWEDOFF:
+ return (int)SMCSWeapon_SAWEDOFF;
+ case CSGOWeapon_TEC9:
+ return (int)SMCSWeapon_TEC9;
+ case CSGOWeapon_TASER:
+ return (int)SMCSWeapon_TASER;
+ case CSGOWeapon_HKP2000:
+ return (int)SMCSWeapon_HKP2000;
+ case CSGOWeapon_MP7:
+ return (int)SMCSWeapon_MP7;
+ case CSGOWeapon_MP9:
+ return (int)SMCSWeapon_MP9;
+ case CSGOWeapon_NOVA:
+ return (int)SMCSWeapon_NOVA;
+ case CSGOWeapon_P250:
+ return (int)SMCSWeapon_P250;
+ case CSGOWeapon_SCAR17:
+ return (int)SMCSWeapon_SCAR17;
+ case CSGOWeapon_SCAR20:
+ return (int)SMCSWeapon_SCAR20;
+ case CSGOWeapon_SG556:
+ return (int)SMCSWeapon_SG556;
+ case CSGOWeapon_SSG08:
+ return (int)SMCSWeapon_SSG08;
+ case CSGOWeapon_KNIFE_GG:
+ return (int)SMCSWeapon_KNIFE_GG;
+ case CSGOWeapon_KNIFE:
+ return (int)SMCSWeapon_KNIFE;
+ case CSGOWeapon_FLASHBANG:
+ return (int)SMCSWeapon_FLASHBANG;
+ case CSGOWeapon_HEGRENADE:
+ return (int)SMCSWeapon_HEGRENADE;
+ case CSGOWeapon_SMOKEGRENADE:
+ return (int)SMCSWeapon_SMOKEGRENADE;
+ case CSGOWeapon_MOLOTOV:
+ return (int)SMCSWeapon_MOLOTOV;
+ case CSGOWeapon_DECOY:
+ return (int)SMCSWeapon_DECOY;
+ case CSGOWeapon_INCGRENADE:
+ return (int)SMCSWeapon_INCGRENADE;
+ case CSGOWeapon_C4:
+ return (int)SMCSWeapon_C4;
+ case CSGOWeapon_KEVLAR:
+ return (int)SMCSWeapon_KEVLAR;
+ case CSGOWeapon_ASSAULTSUIT:
+ return (int)SMCSWeapon_ASSAULTSUIT;
+ case CSGOWeapon_NVG:
+ return (int)SMCSWeapon_NIGHTVISION;
+ case CSGOWeapon_DEFUSER:
+ return (int)SMCSWeapon_DEFUSER;
+ default:
+ return 0;
+ }
+#else
+ if (weaponId > 33 || weaponId < 0)
+ return 0;
+ else
+ return weaponId;
+#endif
+}
diff --git a/extensions/cstrike/util_cstrike.h b/extensions/cstrike/util_cstrike.h
new file mode 100644
index 000000000..d63810460
--- /dev/null
+++ b/extensions/cstrike/util_cstrike.h
@@ -0,0 +1,162 @@
+/**
+ * vim: set ts=4 :
+ * =============================================================================
+ * SourceMod Counter-Strike:Source Extension
+ * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
+ * =============================================================================
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, version 3.0, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ *
+ * As a special exception, AlliedModders LLC gives you permission to link the
+ * code of this program (as well as its derivative works) to "Half-Life 2," the
+ * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
+ * by the Valve Corporation. You must obey the GNU General Public License in
+ * all respects for all other code used. Additionally, AlliedModders LLC grants
+ * this exception to all derivative works. AlliedModders LLC defines further
+ * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
+ * or .
+ *
+ * Version: $Id$
+ */
+
+#ifndef _INCLUDE_CSTRIKE_UTIL_H_
+#define _INCLUDE_CSTRIKE_UTIL_H_
+
+#if SOURCE_ENGINE == SE_CSGO
+enum CSGOWeapon
+{
+ CSGOWeapon_NONE,
+ CSGOWeapon_DEAGLE,
+ CSGOWeapon_ELITE,
+ CSGOWeapon_FIVESEVEN,
+ CSGOWeapon_GLOCK,
+ CSGOWeapon_P228,
+ CSGOWeapon_USP,
+ CSGOWeapon_AK47,
+ CSGOWeapon_AUG,
+ CSGOWeapon_AWP,
+ CSGOWeapon_FAMAS,
+ CSGOWeapon_G3SG1,
+ CSGOWeapon_GALIL,
+ CSGOWeapon_GALILAR,
+ CSGOWeapon_M249,
+ CSGOWeapon_M3,
+ CSGOWeapon_M4A1,
+ CSGOWeapon_MAC10,
+ CSGOWeapon_MP5NAVY,
+ CSGOWeapon_P90,
+ CSGOWeapon_SCOUT,
+ CSGOWeapon_SG550,
+ CSGOWeapon_SG552,
+ CSGOWeapon_TMP,
+ CSGOWeapon_UMP45,
+ CSGOWeapon_XM1014,
+ CSGOWeapon_BIZON,
+ CSGOWeapon_MAG7,
+ CSGOWeapon_NEGEV,
+ CSGOWeapon_SAWEDOFF,
+ CSGOWeapon_TEC9,
+ CSGOWeapon_TASER,
+ CSGOWeapon_HKP2000,
+ CSGOWeapon_MP7,
+ CSGOWeapon_MP9,
+ CSGOWeapon_NOVA,
+ CSGOWeapon_P250,
+ CSGOWeapon_SCAR17,
+ CSGOWeapon_SCAR20,
+ CSGOWeapon_SG556,
+ CSGOWeapon_SSG08,
+ CSGOWeapon_KNIFE_GG,
+ CSGOWeapon_KNIFE,
+ CSGOWeapon_FLASHBANG,
+ CSGOWeapon_HEGRENADE,
+ CSGOWeapon_SMOKEGRENADE,
+ CSGOWeapon_MOLOTOV,
+ CSGOWeapon_DECOY,
+ CSGOWeapon_INCGRENADE,
+ CSGOWeapon_C4, //49
+ CSGOWeapon_KEVLAR = 50,
+ CSGOWeapon_ASSAULTSUIT,
+ CSGOWeapon_NVG,
+ CSGOWeapon_DEFUSER
+};
+enum SMCSWeapon
+{
+ SMCSWeapon_NONE = 0,
+ SMCSWeapon_P228,
+ SMCSWeapon_GLOCK,
+ SMCSWeapon_SCOUT,
+ SMCSWeapon_HEGRENADE,
+ SMCSWeapon_XM1014,
+ SMCSWeapon_C4,
+ SMCSWeapon_MAC10,
+ SMCSWeapon_AUG,
+ SMCSWeapon_SMOKEGRENADE,
+ SMCSWeapon_ELITE,
+ SMCSWeapon_FIVESEVEN,
+ SMCSWeapon_UMP45,
+ SMCSWeapon_SG550,
+ SMCSWeapon_GALIL,
+ SMCSWeapon_FAMAS,
+ SMCSWeapon_USP,
+ SMCSWeapon_AWP,
+ SMCSWeapon_MP5NAVY,
+ SMCSWeapon_M249,
+ SMCSWeapon_M3,
+ SMCSWeapon_M4A1,
+ SMCSWeapon_TMP,
+ SMCSWeapon_G3SG1,
+ SMCSWeapon_FLASHBANG,
+ SMCSWeapon_DEAGLE,
+ SMCSWeapon_SG552,
+ SMCSWeapon_AK47,
+ SMCSWeapon_KNIFE,
+ SMCSWeapon_P90,
+ SMCSWeapon_SHIELD,
+ SMCSWeapon_KEVLAR,
+ SMCSWeapon_ASSAULTSUIT,
+ SMCSWeapon_NIGHTVISION,
+ SMCSWeapon_GALILAR,
+ SMCSWeapon_BIZON,
+ SMCSWeapon_MAG7,
+ SMCSWeapon_NEGEV,
+ SMCSWeapon_SAWEDOFF,
+ SMCSWeapon_TEC9,
+ SMCSWeapon_TASER,
+ SMCSWeapon_HKP2000,
+ SMCSWeapon_MP7,
+ SMCSWeapon_MP9,
+ SMCSWeapon_NOVA,
+ SMCSWeapon_P250,
+ SMCSWeapon_SCAR17,
+ SMCSWeapon_SCAR20,
+ SMCSWeapon_SG556,
+ SMCSWeapon_SSG08,
+ SMCSWeapon_KNIFE_GG,
+ SMCSWeapon_MOLOTOV,
+ SMCSWeapon_DECOY,
+ SMCSWeapon_INCGRENADE,
+ SMCSWeapon_DEFUSER
+};
+#endif
+void *GetWeaponInfo(int weaponID);
+
+const char *GetTranslatedWeaponAlias(const char *weapon);
+
+int AliasToWeaponID(const char *weapon);
+
+int GetRealWeaponID(int weaponId);
+
+int GetFakeWeaponID(int weaponId);
+
+#endif
diff --git a/gamedata/core.games/common.games.txt b/gamedata/core.games/common.games.txt
index e1b092f21..f483dd7af 100644
--- a/gamedata/core.games/common.games.txt
+++ b/gamedata/core.games/common.games.txt
@@ -234,6 +234,7 @@
"#supported"
{
"game" "cstrike"
+ "game" "csgo"
}
"Keys"
diff --git a/gamedata/sm-cstrike.games/game.csgo.txt b/gamedata/sm-cstrike.games/game.csgo.txt
new file mode 100644
index 000000000..d4f766638
--- /dev/null
+++ b/gamedata/sm-cstrike.games/game.csgo.txt
@@ -0,0 +1,83 @@
+/**
+ * Do not edit this file. Any changes will be overwritten by the gamedata
+ * updater or by upgrading your SourceMod install.
+ *
+ * To override data in this file, create a subdirectory named "custom" and
+ * place your own gamedata file(s) inside of it. Such files will be parsed
+ * after SM's own.
+ *
+ * For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(SourceMod)
+ */
+
+"Games"
+{
+ //No mac binary yet so no mac gamedata
+ "csgo"
+ {
+ "Offsets"
+ {
+ //Offset of szClassName in CCSWeaponInfo
+ "WeaponName"
+ {
+ "windows" "6"
+ "linux" "6"
+ }
+ "WeaponPrice"
+ {
+ "windows" "2700"
+ "linux" "2700"
+ }
+ }
+ "Signatures"
+ {
+ "RoundRespawn"
+ {
+ "library" "server"
+ "windows" "\x55\x8B\xEC\x83\xEC\x2A\x56\x8B\xF1\x8B\x0D\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x84\xC0\x75"
+ "linux" "@_ZN9CCSPlayer12RoundRespawnEv"
+ }
+ "SwitchTeam"
+ {
+ "library" "server"
+ "windows" "\x55\x8B\xEC\x83\xEC\x2A\x56\x57\x8B\x7D\x2A\x57\x8B\xF1\xE8\x2A\x2A\x2A\x2A\x83\xC4"
+ "linux" "@_ZN9CCSPlayer10SwitchTeamEi"
+ }
+ "HandleCommand_Buy_Internal"
+ {
+ "library" "server"
+ "windows" "\x55\x8B\xEC\x81\xEC\x2A\x2A\x00\x00\x53\x56\x8B\xF1\x80\xBE\x2A\x2A\x00\x00\x00"
+ "linux" "@_ZN9CCSPlayer26HandleCommand_Buy_InternalEPKc"
+ }
+ "CSWeaponDrop"//Wildcard first 6 bytes for CS:S DM
+ {
+ "library" "server"
+ "windows" "\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x53\x56\x8B\x2A\x2A\x32\xDB\x57\x8B\xF9\x85\xF6\x0F\x84"
+ "linux" "@_ZN9CCSPlayer12CSWeaponDropEP17CBaseCombatWeaponbb"
+ }
+ "TerminateRound"
+ {
+ "library" "server"
+ "windows" "\x55\x8B\xEC\x83\xEC\x2A\x53\x8B\x2A\x2A\x56\x57\x33\xFF"
+ "linux" "@_ZN12CCSGameRules14TerminateRoundEfi"
+ }
+ "GetTranslatedWeaponAlias"
+ {
+ "library" "server"
+ "windows" "\x55\x8B\xEC\x56\x57\x8B\x2A\x2A\x33\xF6\x8D\x9B\x2A\x2A\x2A\x2A\x8B\x04\xF5\x2A\x2A\x2A\x2A\x57\x50\xE8\x2A\x2A\x2A\x2A\x83\xC4\x2A\x85\xC0\x74\x2A\x46\x83\xFE\x2A\x72\x2A\x8B\xC7\x5F\x5E\x5D\xC3"
+ "linux" "@_Z24GetTranslatedWeaponAliasPKc"
+ }
+ "GetWeaponInfo"
+ {
+ "library" "server"
+ "windows" "\x55\x8B\xEC\x8B\x4D\x2A\x33\xC0\x85\xC9\x74"
+ "linux" "@_Z13GetWeaponInfo10CSWeaponID"
+ }
+ "AliasToWeaponID"
+ {
+ "library" "server"
+ "windows" "\x55\x8B\xEC\x56\x57\x8B\x2A\x2A\x85\xFF\x74\x2A\x33\xF6\x8B\xFF"
+ "linux" "@_Z15AliasToWeaponIDPKc"
+ }
+ }
+ }
+}
diff --git a/gamedata/sm-cstrike.games.txt b/gamedata/sm-cstrike.games/game.css.txt
similarity index 92%
rename from gamedata/sm-cstrike.games.txt
rename to gamedata/sm-cstrike.games/game.css.txt
index 4d7900aec..f36deb3c8 100644
--- a/gamedata/sm-cstrike.games.txt
+++ b/gamedata/sm-cstrike.games/game.css.txt
@@ -101,6 +101,13 @@
"linux" "@_ZN9CCSPlayer10SetClanTagEPKc"
"mac" "@_ZN9CCSPlayer10SetClanTagEPKc"
}
+ "AliasToWeaponID"
+ {
+ "library" "server"
+ "windows" "\x55\x8B\xEC\x56\x57\x8B\x2A\x2A\x85\xFF\x74\x2A\x33\xF6\x8B\xFF\x8B\x04\x2A\x2A\x2A\x2A\x2A\x57\x50"
+ "linux" "@_Z15AliasToWeaponIDPKc"
+ "mac" "@_Z15AliasToWeaponIDPKc"
+ }
}
}
}
diff --git a/gamedata/sm-cstrike.games/master.games.txt b/gamedata/sm-cstrike.games/master.games.txt
new file mode 100644
index 000000000..42c3576b3
--- /dev/null
+++ b/gamedata/sm-cstrike.games/master.games.txt
@@ -0,0 +1,23 @@
+/**
+ * Do not edit this file. Any changes will be overwritten by the gamedata
+ * updater or by upgrading your SourceMod install.
+ *
+ * To override data in this file, create a subdirectory named "custom" and
+ * place your own gamedata file(s) inside of it. Such files will be parsed
+ * after SM's own.
+ *
+ * For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(SourceMod)
+ */
+
+"Game Master"
+{
+ "game.csgo.txt"
+ {
+ "game" "csgo"
+ }
+
+ "game.css.txt"
+ {
+ "game" "cstrike"
+ }
+}
diff --git a/plugins/include/cstrike.inc b/plugins/include/cstrike.inc
index 88d1f465b..e8a5b59cf 100644
--- a/plugins/include/cstrike.inc
+++ b/plugins/include/cstrike.inc
@@ -67,41 +67,63 @@ enum CSRoundEndReason
enum CSWeaponID
{
- CSWeapon_NONE,
- CSWeapon_P228,
- CSWeapon_GLOCK,
- CSWeapon_SCOUT,
- CSWeapon_HEGRENADE,
- CSWeapon_XM1014,
- CSWeapon_C4,
- CSWeapon_MAC10,
- CSWeapon_AUG,
- CSWeapon_SMOKEGRENADE,
- CSWeapon_ELITE,
- CSWeapon_FIVESEVEN,
- CSWeapon_UMP45,
- CSWeapon_SG550,
- CSWeapon_GALIL,
- CSWeapon_FAMAS,
- CSWeapon_USP,
- CSWeapon_AWP,
- CSWeapon_MP5NAVY,
- CSWeapon_M249,
- CSWeapon_M3,
- CSWeapon_M4A1,
- CSWeapon_TMP,
- CSWeapon_G3SG1,
- CSWeapon_FLASHBANG,
- CSWeapon_DEAGLE,
- CSWeapon_SG552,
- CSWeapon_AK47,
- CSWeapon_KNIFE,
- CSWeapon_P90,
- CSWeapon_SHIELD,
- CSWeapon_KEVLAR,
- CSWeapon_ASSAULTSUIT,
- CSWeapon_NIGHTVISION
+ CSWeapon_NONE = 0,
+ CSWeapon_P228,
+ CSWeapon_GLOCK,
+ CSWeapon_SCOUT,
+ CSWeapon_HEGRENADE,
+ CSWeapon_XM1014,
+ CSWeapon_C4,
+ CSWeapon_MAC10,
+ CSWeapon_AUG,
+ CSWeapon_SMOKEGRENADE,
+ CSWeapon_ELITE,
+ CSWeapon_FIVESEVEN,
+ CSWeapon_UMP45,
+ CSWeapon_SG550,
+ CSWeapon_GALIL,
+ CSWeapon_FAMAS,
+ CSWeapon_USP,
+ CSWeapon_AWP,
+ CSWeapon_MP5NAVY,
+ CSWeapon_M249,
+ CSWeapon_M3,
+ CSWeapon_M4A1,
+ CSWeapon_TMP,
+ CSWeapon_G3SG1,
+ CSWeapon_FLASHBANG,
+ CSWeapon_DEAGLE,
+ CSWeapon_SG552,
+ CSWeapon_AK47,
+ CSWeapon_KNIFE,
+ CSWeapon_P90,
+ CSWeapon_SHIELD,
+ CSWeapon_KEVLAR,
+ CSWeapon_ASSAULTSUIT,
+ CSWeapon_NIGHTVISION,
+ CSWeapon_GALILAR,
+ CSWeapon_BIZON,
+ CSWeapon_MAG7,
+ CSWeapon_NEGEV,
+ CSWeapon_SAWEDOFF,
+ CSWeapon_TEC9,
+ CSWeapon_TASER,
+ CSWeapon_HKP2000,
+ CSWeapon_MP7,
+ CSWeapon_MP9,
+ CSWeapon_NOVA,
+ CSWeapon_P250,
+ CSWeapon_SCAR17,
+ CSWeapon_SCAR20,
+ CSWeapon_SG556,
+ CSWeapon_SSG08,
+ CSWeapon_KNIFE_GG,
+ CSWeapon_MOLOTOV,
+ CSWeapon_DECOY,
+ CSWeapon_INCGRENADE,
+ CSWeapon_DEFUSER
};
+
/**
* Called when a player attempts to purchase an item.
* Return Plugin_Continue to allow the purchase or return a
@@ -224,6 +246,7 @@ native CS_GetWeaponPrice(client, CSWeaponID:id, bool:defaultprice = false);
* @return Number of non-null bytes written.
*
* @error Invalid client.
+ * @note Only supported on CS:S. Writes 0-length string on CS:GO.
*/
native CS_GetClientClanTag(client, String:buffer[], size);
@@ -234,9 +257,19 @@ native CS_GetClientClanTag(client, String:buffer[], size);
* @noreturn
*
* @error Invalid client.
+ * @note Only supported on CS:S. Has no effect on CS:GO.
*/
native CS_SetClientClanTag(client, const String:tag[]);
+/**
+ * Gets a weaponID from a alias
+ * @param alias Weapon alias to attempt to get an id for.
+ * @return Returns a weapon id or 0 if failed to find a match.
+ *
+ * @note For best results use CS_GetTranslatedWeaponAlias on the weapon name before passing it.
+ */
+native CS_AliasToWeaponID(const String:alias[]);
+
/**
* Do not edit below this line!
*/
@@ -263,6 +296,7 @@ public __ext_cstrike_SetNTVOptional()
MarkNativeAsOptional("CS_GetWeaponPrice");
MarkNativeAsOptional("CS_GetClientClanTag");
MarkNativeAsOptional("CS_SetClientClanTag");
+ MakrNativeAsOptional("CS_AliasToWeaponID");
}
#endif