Skip to content

Commit 903f1ff

Browse files
Add GetPlayerWeaponState (#41)
1 parent 7b82cd2 commit 903f1ff

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

amx/client/client.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,8 +1743,8 @@ function ShowPlayerDialog(dialogid, dialogtype, caption, info, button1, button2)
17431743
end
17441744
end
17451745

1746-
addEvent ( "onPlayerClickPlayer" )
1747-
function OnPlayerClickPlayer ( element )
1746+
addEvent("onPlayerClickPlayer")
1747+
function OnPlayerClickPlayer(element)
17481748
serverAMXEvent('OnPlayerClickPlayer', getElemID(localPlayer), getElemID(element), 0)
17491749
end
1750-
addEventHandler ( "onPlayerClickPlayer", root, OnPlayerClickPlayer )
1750+
addEventHandler("onPlayerClickPlayer", root, OnPlayerClickPlayer)

amx/server/syscalls.lua

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2941,6 +2941,31 @@ function GetVehicleParamsSirenState(amx, vehicle)
29412941
return 0
29422942
end
29432943
end
2944+
2945+
2946+
-- Weapon
2947+
function GetPlayerWeaponState(amx, player)
2948+
-- -1 WEAPONSTATE_UNKNOWN
2949+
-- 0 WEAPONSTATE_NO_BULLETS
2950+
-- 1 WEAPONSTATE_LAST_BULLET
2951+
-- 2 WEAPONSTATE_MORE_BULLETS
2952+
-- 3 WEAPONSTATE_RELOADING
2953+
2954+
local vehicle = getPedOccupiedVehicle(player)
2955+
if vehicle ~= nil then return -1 end
2956+
2957+
-- TODO: Function don't return 3 because a isPedReloadingWeapon function only client-side
2958+
local ammo = getPedAmmoInClip(player)
2959+
if ammo == 0 then
2960+
return 0
2961+
elseif ammo == 1 then
2962+
return 1
2963+
elseif ammo >= 2 then
2964+
return 2
2965+
else
2966+
return -1
2967+
end
2968+
end
29442969
-----------------------------------------------------
29452970
-- List of the functions and their argument types
29462971

@@ -3536,5 +3561,8 @@ g_SAMPSyscallPrototypes = {
35363561
SHA256_PassHash = {'s', 's', 'r', 'i'},
35373562

35383563
-- siren
3539-
GetVehicleParamsSirenState = {'v'}
3564+
GetVehicleParamsSirenState = {'v'},
3565+
3566+
3567+
GetPlayerWeaponState = {'p'}
35403568
}

0 commit comments

Comments
 (0)