Skip to content

Commit

Permalink
Move GetPlayerWeaponAmmo and GetPlayerWeaponAmmoInClip to WeaponFunct…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
Marcel Gerber committed Apr 26, 2016
1 parent fbc5765 commit 1d960ab
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 49 deletions.
Binary file modified bin/Open-SAMP-API.dll
Binary file not shown.
Binary file modified bin/Open-SAMP-API.lib
Binary file not shown.
28 changes: 14 additions & 14 deletions include/AHK/SAMP_API.ahk
Expand Up @@ -25,8 +25,6 @@ GetPlayerHealth_func := DllCall("GetProcAddress", "UInt", hModule, "Str", "GetPl
GetPlayerArmor_func := DllCall("GetProcAddress", "UInt", hModule, "Str", "GetPlayerArmor")
GetPlayerMoney_func := DllCall("GetProcAddress", "UInt", hModule, "Str", "GetPlayerMoney")
GetPlayerSkinID_func := DllCall("GetProcAddress", "UInt", hModule, "Str", "GetPlayerSkinID")
GetPlayerWeaponAmmo_func := DllCall("GetProcAddress", "UInt", hModule, "Str", "GetPlayerWeaponAmmo")
GetPlayerWeaponAmmoInClip_func := DllCall("GetProcAddress", "UInt", hModule, "Str", "GetPlayerWeaponAmmoInClip")
IsPlayerInAnyVehicle_func := DllCall("GetProcAddress", "UInt", hModule, "Str", "IsPlayerInAnyVehicle")
IsPlayerDriver_func := DllCall("GetProcAddress", "UInt", hModule, "Str", "IsPlayerDriver")
IsPlayerPassenger_func := DllCall("GetProcAddress", "UInt", hModule, "Str", "IsPlayerPassenger")
Expand Down Expand Up @@ -123,6 +121,8 @@ GetPlayerWeaponName_func := DllCall("GetProcAddress", "UInt", hModule, "Str", "G
GetPlayerWeaponClip_func := DllCall("GetProcAddress", "UInt", hModule, "Str", "GetPlayerWeaponClip")
GetPlayerWeaponTotalClip_func := DllCall("GetProcAddress", "UInt", hModule, "Str", "GetPlayerWeaponTotalClip")
GetPlayerWeaponState_func := DllCall("GetProcAddress", "UInt", hModule, "Str", "GetPlayerWeaponState")
GetPlayerWeaponAmmo_func := DllCall("GetProcAddress", "UInt", hModule, "Str", "GetPlayerWeaponAmmo")
GetPlayerWeaponAmmoInClip_func := DllCall("GetProcAddress", "UInt", hModule, "Str", "GetPlayerWeaponAmmoInClip")

Init()
{
Expand Down Expand Up @@ -191,18 +191,6 @@ GetPlayerSkinID()
return DllCall(GetPlayerSkinID_func)
}

GetPlayerWeaponAmmo(weaponType)
{
global GetPlayerWeaponAmmo_func
return DllCall(GetPlayerWeaponAmmo_func, "Int", weaponType)
}

GetPlayerWeaponAmmoInClip(weaponType)
{
global GetPlayerWeaponAmmoInClip_func
return DllCall(GetPlayerWeaponAmmoInClip_func, "Int", weaponType)
}

IsPlayerInAnyVehicle()
{
global IsPlayerInAnyVehicle_func
Expand Down Expand Up @@ -738,6 +726,18 @@ GetPlayerWeaponState()
return DllCall(GetPlayerWeaponState_func)
}

GetPlayerWeaponAmmo(weaponType)
{
global GetPlayerWeaponAmmo_func
return DllCall(GetPlayerWeaponAmmo_func, "Int", weaponType)
}

GetPlayerWeaponAmmoInClip(weaponType)
{
global GetPlayerWeaponAmmoInClip_func
return DllCall(GetPlayerWeaponAmmoInClip_func, "Int", weaponType)
}


PathCombine(abs, rel) {
VarSetCapacity(dest, (A_IsUnicode ? 2 : 1) * 260, 1) ; MAX_PATH
Expand Down
8 changes: 4 additions & 4 deletions include/C#/SAMP_API.cs
Expand Up @@ -36,10 +36,6 @@ class API
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerSkinID();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerWeaponAmmo(int weaponType);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerWeaponAmmoInClip(int weaponType);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int IsPlayerInAnyVehicle();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int IsPlayerDriver();
Expand Down Expand Up @@ -223,6 +219,10 @@ class API
public static extern int GetPlayerWeaponTotalClip(int dwWeapSlot);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerWeaponState();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerWeaponAmmo(int weaponType);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerWeaponAmmoInClip(int weaponType);

/// <summary>
/// Send a message/command to the server
Expand Down
4 changes: 2 additions & 2 deletions include/C++/SAMP_API.h
Expand Up @@ -17,8 +17,6 @@ IMPORT int GetPlayerHealth();
IMPORT int GetPlayerArmor();
IMPORT int GetPlayerMoney();
IMPORT int GetPlayerSkinID();
IMPORT int GetPlayerWeaponAmmo(int weaponType);
IMPORT int GetPlayerWeaponAmmoInClip(int weaponType);
IMPORT int IsPlayerInAnyVehicle();
IMPORT int IsPlayerDriver();
IMPORT int IsPlayerPassenger();
Expand Down Expand Up @@ -115,3 +113,5 @@ IMPORT int GetPlayerWeaponName(int dwWeapSlot, char* &_szWeapName, int max_len);
IMPORT int GetPlayerWeaponClip(int dwWeapSlot);
IMPORT int GetPlayerWeaponTotalClip(int dwWeapSlot);
IMPORT int GetPlayerWeaponState();
IMPORT int GetPlayerWeaponAmmo(int weaponType);
IMPORT int GetPlayerWeaponAmmoInClip(int weaponType);
26 changes: 0 additions & 26 deletions src/Open-SAMP-API/Client/PlayerFunctions.cpp
Expand Up @@ -60,32 +60,6 @@ EXPORT int Client::PlayerFunctions::GetPlayerSkinID()
return (int)skin;
}

EXPORT int Client::PlayerFunctions::GetPlayerWeaponAmmo(int weaponType)
{
DWORD pedPtr = GetPlayerCPed();
if (pedPtr == NULL)
return -1;

int ammo = 0;
if (MemoryFunctions::ReadMemory(pedPtr + 0x5A0 + (weaponType * 0x1C) + 0x0C, 4, &ammo) != 4)
return -1;

return ammo;
}

EXPORT int Client::PlayerFunctions::GetPlayerWeaponAmmoInClip(int weaponType)
{
DWORD pedPtr = GetPlayerCPed();
if (pedPtr == NULL)
return -1;

int ammo = 0;
if (MemoryFunctions::ReadMemory(pedPtr + 0x5A0 + (weaponType * 0x1C) + 0x08, 4, &ammo) != 4)
return -1;

return ammo;
}

EXPORT int Client::PlayerFunctions::IsPlayerInAnyVehicle()
{
return (int)(VehicleFunctions::GetVehiclePointer() != 0);
Expand Down
2 changes: 0 additions & 2 deletions src/Open-SAMP-API/Client/PlayerFunctions.hpp
Expand Up @@ -10,8 +10,6 @@ namespace Client
EXPORT int GetPlayerArmor();
EXPORT int GetPlayerMoney();
EXPORT int GetPlayerSkinID();
EXPORT int GetPlayerWeaponAmmo(int weaponType);
EXPORT int GetPlayerWeaponAmmoInClip(int weaponType);
EXPORT int IsPlayerInAnyVehicle();
EXPORT int IsPlayerDriver();
EXPORT int IsPlayerPassenger();
Expand Down
26 changes: 26 additions & 0 deletions src/Open-SAMP-API/Client/WeaponFunctions.cpp
Expand Up @@ -136,3 +136,29 @@ EXPORT int Client::WeaponFunctions::GetPlayerWeaponState()

return pws->state;
}

EXPORT int Client::WeaponFunctions::GetPlayerWeaponAmmo(int weaponType)
{
DWORD pedPtr = PlayerFunctions::GetPlayerCPed();
if (pedPtr == NULL)
return -1;

int ammo = 0;
if (MemoryFunctions::ReadMemory(pedPtr + 0x5A0 + (weaponType * 0x1C) + 0x0C, 4, &ammo) != 4)
return -1;

return ammo;
}

EXPORT int Client::WeaponFunctions::GetPlayerWeaponAmmoInClip(int weaponType)
{
DWORD pedPtr = PlayerFunctions::GetPlayerCPed();
if (pedPtr == NULL)
return -1;

int ammo = 0;
if (MemoryFunctions::ReadMemory(pedPtr + 0x5A0 + (weaponType * 0x1C) + 0x08, 4, &ammo) != 4)
return -1;

return ammo;
}
3 changes: 2 additions & 1 deletion src/Open-SAMP-API/Client/WeaponFunctions.hpp
Expand Up @@ -12,6 +12,7 @@ namespace Client
EXPORT int GetPlayerWeaponClip(int dwWeapSlot);
EXPORT int GetPlayerWeaponTotalClip(int dwWeapSlot);
EXPORT int GetPlayerWeaponState();

EXPORT int GetPlayerWeaponAmmo(int weaponType);
EXPORT int GetPlayerWeaponAmmoInClip(int weaponType);
}
}

0 comments on commit 1d960ab

Please sign in to comment.