Added WeaponIDToAlias native to CStrike extension (bug 5460, r=psychonic).
This commit is contained in:
parent
eb230a45f6
commit
2e3c5e367e
@ -294,6 +294,22 @@ static cell_t CS_TerminateRound(IPluginContext *pContext, const cell_t *params)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell_t CS_WeaponIDToAlias(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
char *dest;
|
||||||
|
|
||||||
|
pContext->LocalToString(params[2], &dest);
|
||||||
|
|
||||||
|
const char *ret = WeaponIDToAlias(params[1]);
|
||||||
|
|
||||||
|
if (ret == NULL)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return strncopy(dest, ret, params[3]);
|
||||||
|
}
|
||||||
|
|
||||||
static cell_t CS_GetTranslatedWeaponAlias(IPluginContext *pContext, const cell_t *params)
|
static cell_t CS_GetTranslatedWeaponAlias(IPluginContext *pContext, const cell_t *params)
|
||||||
{
|
{
|
||||||
char *weapon;
|
char *weapon;
|
||||||
@ -669,6 +685,7 @@ sp_nativeinfo_t g_CSNatives[] =
|
|||||||
{"CS_SetTeamScore", CS_SetTeamScore},
|
{"CS_SetTeamScore", CS_SetTeamScore},
|
||||||
{"CS_GetMVPCount", CS_GetMVPCount},
|
{"CS_GetMVPCount", CS_GetMVPCount},
|
||||||
{"CS_SetMVPCount", CS_SetMVPCount},
|
{"CS_SetMVPCount", CS_SetMVPCount},
|
||||||
|
{"CS_WeaponIDToAlias", CS_WeaponIDToAlias},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -130,6 +130,35 @@ int AliasToWeaponID(const char *weapon)
|
|||||||
|
|
||||||
return weaponID;
|
return weaponID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *WeaponIDToAlias(int weaponID)
|
||||||
|
{
|
||||||
|
static ICallWrapper *pWrapper = NULL;
|
||||||
|
|
||||||
|
if (!pWrapper)
|
||||||
|
{
|
||||||
|
REGISTER_ADDR("WeaponIDToAlias", 0,
|
||||||
|
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(const char *); \
|
||||||
|
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, pass, 1))
|
||||||
|
}
|
||||||
|
const char *ret = NULL;
|
||||||
|
|
||||||
|
unsigned char vstk[sizeof(int)];
|
||||||
|
unsigned char *vptr = vstk;
|
||||||
|
|
||||||
|
*(int *)vptr = GetRealWeaponID(weaponID);
|
||||||
|
|
||||||
|
pWrapper->Execute(vstk, &ret);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
int GetRealWeaponID(int weaponId)
|
int GetRealWeaponID(int weaponId)
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE == SE_CSGO
|
#if SOURCE_ENGINE == SE_CSGO
|
||||||
|
@ -155,6 +155,8 @@ const char *GetTranslatedWeaponAlias(const char *weapon);
|
|||||||
|
|
||||||
int AliasToWeaponID(const char *weapon);
|
int AliasToWeaponID(const char *weapon);
|
||||||
|
|
||||||
|
const char *WeaponIDToAlias(int weaponID);
|
||||||
|
|
||||||
int GetRealWeaponID(int weaponId);
|
int GetRealWeaponID(int weaponId);
|
||||||
|
|
||||||
int GetFakeWeaponID(int weaponId);
|
int GetFakeWeaponID(int weaponId);
|
||||||
|
@ -129,6 +129,13 @@
|
|||||||
"linux" "@_Z15AliasToWeaponIDPKc"
|
"linux" "@_Z15AliasToWeaponIDPKc"
|
||||||
"mac" "@_Z15AliasToWeaponIDPKc"
|
"mac" "@_Z15AliasToWeaponIDPKc"
|
||||||
}
|
}
|
||||||
|
"WeaponIDToAlias"
|
||||||
|
{
|
||||||
|
"library" "server"
|
||||||
|
"windows" "\x55\x8B\xEC\x8B\x4D\x08\x33\xC0\xEB\x2A\x8D\x9B\x00\x00\x00\x00\x39\x0C\xC5\x2A\x2A\x2A\x2A\x74\x2A\x40\x83\xF8\x37\x72\x2A\x33\xC0\x5D"
|
||||||
|
"linux" "@_Z15WeaponIDToAliasi"
|
||||||
|
"mac" "@_Z15WeaponIDToAliasi"
|
||||||
|
}
|
||||||
"SetClanTag"
|
"SetClanTag"
|
||||||
{
|
{
|
||||||
"library" "server"
|
"library" "server"
|
||||||
|
@ -129,6 +129,13 @@
|
|||||||
"linux" "@_Z15AliasToWeaponIDPKc"
|
"linux" "@_Z15AliasToWeaponIDPKc"
|
||||||
"mac" "@_Z15AliasToWeaponIDPKc"
|
"mac" "@_Z15AliasToWeaponIDPKc"
|
||||||
}
|
}
|
||||||
|
"WeaponIDToAlias"
|
||||||
|
{
|
||||||
|
"library" "server"
|
||||||
|
"windows" "\x55\x8B\xEC\x8B\x4D\x08\x33\xC0\xEB\x2A\x8D\x9B\x00\x00\x00\x00\x39\x0C\xC5\x2A\x2A\x2A\x2A\x74\x2A\x40\x83\xF8\x26\x72\x2A\x33\xC0\x5D"
|
||||||
|
"linux" "@_Z15WeaponIDToAliasi"
|
||||||
|
"mac" "@_Z15WeaponIDToAliasi"
|
||||||
|
}
|
||||||
|
|
||||||
//For mac we use think since CheckWinLimit dosnt exist on mac.
|
//For mac we use think since CheckWinLimit dosnt exist on mac.
|
||||||
"CheckWinLimit"
|
"CheckWinLimit"
|
||||||
|
@ -311,6 +311,15 @@ native CS_SetMVPCount(client, value);
|
|||||||
*/
|
*/
|
||||||
native CSWeaponID:CS_AliasToWeaponID(const String:alias[]);
|
native CSWeaponID:CS_AliasToWeaponID(const String:alias[]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a alias from a weaponID
|
||||||
|
* @param weaponID WeaponID to get alias for.
|
||||||
|
* @param destination Destination string to hold the weapon alias.
|
||||||
|
* @param len Length of the destination array.
|
||||||
|
* @return Returns number of cells written.
|
||||||
|
*/
|
||||||
|
native CS_WeaponIDToAlias(weaponID, String:destination[], len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do not edit below this line!
|
* Do not edit below this line!
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user