Hi! I think this is a stupid question, but is there a command to give ammo to a player? Thanks!
1 Like
This isn’t built in ESX by default. You’ll need to build this yourself.
Made a little example, don’t know if it works though since I just hardcoded it without testing
ESX.RegisterCommand('giveammo', 'admin', function(xPlayer, args, showError)
local playerPed = GetPlayerPed(args.playerId)
currentWeapon = GetCurrentPedWeapon(playerPed, true)
if currentWeapon ~= nil then
local currentAmmo = GetAmmoInPedWeapon(playerPed, currentWeapon)
local newAmmo = currentAmmo + args.count
local maxAmmo = GetMaxAmmo(playerPed, currentWeapon)
if newAmmo < maxAmmo then
TaskReloadWeapon(playerPed)
SetPedAmmo(playerPed, currentWeapon, newAmmo)
else
showError("Weapon player is holding already has max ammo.")
end
else
showError("Player isn't holding a weapon.")
end
end, true, {help = 'Give ammo to weapon player is holding in hands', validate = true, arguments = {
{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'},
{name = 'count', help = _U('command_giveitem_count'), type = 'number'}
}})
You would use the command like this: /giveitem PLAYERID AMMOCOUNT
Think this will do the trick, but I’m not sure if its going to work because I didn’t test it.
1 Like
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.