Added user_has_weapon() native

This commit is contained in:
David Anderson 2004-05-26 08:28:54 +00:00
parent 7853e0c3e8
commit f88bd58919
4 changed files with 126 additions and 45 deletions

View File

@ -546,6 +546,46 @@ static cell AMX_NATIVE_CALL get_user_attacker(AMX *amx, cell *params) /* 2 param
return (enemy ? pPlayer->index : 0);
}
static cell AMX_NATIVE_CALL user_has_weapon(AMX *amx,cell *params)
{
int index = params[1];
if (index < 1 || index > gpGlobals->maxClients){
amx_RaiseError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
edict_t *pEntity = pPlayer->pEdict;
if (params[3] == -1)
{
if ((pEntity->v.weapons & (1<<params[2])) > 0)
{
return 1;
}
}
else
{
if ((pEntity->v.weapons & (1<<params[2])) > 0)
{
if (params[3] == 0)
{
pEntity->v.weapons &= ~(1<<params[2]);
return 1;
}
return 0;
}
else
{
if (params[3] == 1)
{
pEntity->v.weapons |= (1<<params[2]);
return 1;
}
}
return 0;
}
return 0;
}
static cell AMX_NATIVE_CALL get_user_weapon(AMX *amx, cell *params) /* 3 param */
{
int index = params[1];
@ -2502,6 +2542,7 @@ AMX_NATIVE_INFO amxmod_Natives[] = {
{ "get_user_team", get_user_team },
{ "get_user_time", get_user_time },
{ "get_user_userid", get_user_userid },
{ "user_has_weapon", user_has_weapon },
{ "get_user_weapon", get_user_weapon},
{ "get_user_weapons", get_user_weapons},
{ "get_weaponname", get_weaponname},

View File

@ -1,30 +1,28 @@
Microsoft Visual Studio Solution File, Format Version 7.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "amxmodx_mm", "amxmodx_mm.vcproj", "{CDD792EF-ABC5-4C61-803F-616E209C03D6}"
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "amxmodx_mm", "amxmodx_mm.vcproj", "{7A2555A6-CBA6-4BD0-96AE-72DA57B995DF}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
ConfigName.0 = Debug
ConfigName.1 = JITDebug
ConfigName.2 = JITRelease
ConfigName.3 = MemtestDebug
ConfigName.4 = MemtestRelease
ConfigName.5 = Release
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
Debug = Debug
JITDebug = JITDebug
JITRelease = JITRelease
MemtestDebug = MemtestDebug
MemtestRelease = MemtestRelease
Release = Release
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{CDD792EF-ABC5-4C61-803F-616E209C03D6}.Debug.ActiveCfg = Debug|Win32
{CDD792EF-ABC5-4C61-803F-616E209C03D6}.Debug.Build.0 = Debug|Win32
{CDD792EF-ABC5-4C61-803F-616E209C03D6}.JITDebug.ActiveCfg = JITDebug|Win32
{CDD792EF-ABC5-4C61-803F-616E209C03D6}.JITDebug.Build.0 = JITDebug|Win32
{CDD792EF-ABC5-4C61-803F-616E209C03D6}.JITRelease.ActiveCfg = JITRelease|Win32
{CDD792EF-ABC5-4C61-803F-616E209C03D6}.JITRelease.Build.0 = JITRelease|Win32
{CDD792EF-ABC5-4C61-803F-616E209C03D6}.MemtestDebug.ActiveCfg = MemtestDebug|Win32
{CDD792EF-ABC5-4C61-803F-616E209C03D6}.MemtestDebug.Build.0 = MemtestDebug|Win32
{CDD792EF-ABC5-4C61-803F-616E209C03D6}.MemtestRelease.ActiveCfg = MemtestRelease|Win32
{CDD792EF-ABC5-4C61-803F-616E209C03D6}.MemtestRelease.Build.0 = MemtestRelease|Win32
{CDD792EF-ABC5-4C61-803F-616E209C03D6}.Release.ActiveCfg = Release|Win32
{CDD792EF-ABC5-4C61-803F-616E209C03D6}.Release.Build.0 = Release|Win32
{7A2555A6-CBA6-4BD0-96AE-72DA57B995DF}.Debug.ActiveCfg = Debug|Win32
{7A2555A6-CBA6-4BD0-96AE-72DA57B995DF}.Debug.Build.0 = Debug|Win32
{7A2555A6-CBA6-4BD0-96AE-72DA57B995DF}.JITDebug.ActiveCfg = JITDebug|Win32
{7A2555A6-CBA6-4BD0-96AE-72DA57B995DF}.JITRelease.ActiveCfg = JITRelease|Win32
{7A2555A6-CBA6-4BD0-96AE-72DA57B995DF}.MemtestDebug.ActiveCfg = MemtestDebug|Win32
{7A2555A6-CBA6-4BD0-96AE-72DA57B995DF}.MemtestDebug.Build.0 = MemtestDebug|Win32
{7A2555A6-CBA6-4BD0-96AE-72DA57B995DF}.MemtestRelease.ActiveCfg = MemtestRelease|Win32
{7A2555A6-CBA6-4BD0-96AE-72DA57B995DF}.MemtestRelease.Build.0 = MemtestRelease|Win32
{7A2555A6-CBA6-4BD0-96AE-72DA57B995DF}.Release.ActiveCfg = Release|Win32
{7A2555A6-CBA6-4BD0-96AE-72DA57B995DF}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding = "Windows-1252"?>
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.00"
Version="7.10"
Name="amxmodx_mm"
SccProjectName=""
SccLocalPath="">
@ -73,8 +73,14 @@
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
@ -138,8 +144,14 @@
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="MemtestDebug|Win32"
@ -204,8 +216,14 @@
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="MemtestRelease|Win32"
@ -269,8 +287,14 @@
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="JITDebug|Win32"
@ -335,8 +359,14 @@
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="JITRelease|Win32"
@ -400,14 +430,37 @@
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath="..\amx.cpp">
</File>
<File
RelativePath="..\amxcore.cpp">
</File>
<File
RelativePath="..\amxmodx.cpp">
</File>
<File
RelativePath="..\amxtime.cpp">
</File>
<File
RelativePath="..\amxxlog.cpp">
</File>
<File
RelativePath="..\CCmd.cpp">
</File>
@ -444,21 +497,6 @@
<File
RelativePath="..\CVault.cpp">
</File>
<File
RelativePath="..\amx.cpp">
</File>
<File
RelativePath="..\amxcore.cpp">
</File>
<File
RelativePath="..\amxmodx.cpp">
</File>
<File
RelativePath="..\amxtime.cpp">
</File>
<File
RelativePath="..\amxxlog.cpp">
</File>
<File
RelativePath="..\emsg.cpp">
</File>
@ -536,6 +574,12 @@
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath="..\amx.h">
</File>
<File
RelativePath="..\amxmodx.h">
</File>
<File
RelativePath="..\CCmd.h">
</File>
@ -578,12 +622,6 @@
<File
RelativePath="..\CVector.h">
</File>
<File
RelativePath="..\amx.h">
</File>
<File
RelativePath="..\amxmodx.h">
</File>
<File
RelativePath="..\fakemeta.h">
</File>

View File

@ -211,6 +211,10 @@ native get_user_index(const name[]);
/* Returns ip. */
native get_user_ip(index,ip[],len, without_port = 0);
/* Returns if the player has the weapon or not in their pev->weapons field.
set "setweapon" to 0 to turn the bit off, set to 1 to turn it on. */
native has_weapon(index,weapon,setweapon=-1);
/* Returns id of currently carried weapon. Gets also
* ammount of ammo in clip and backpack. */
native get_user_weapon(index,&clip,&ammo);