Hey Guys
I'm back again with another question. I'm trying to get unlimited ammo on my server and I found this script on pastebin.
local CATEGORY_NAME = "Fun"
function ulx.uammo( calling_ply, target_plys )
for _, pl in ipairs( target_plys ) do
pl.UnlimitedAmmo = enabled
if ( enabled ) then
for _, wep in ipairs( pl:GetWeapons() ) do
FillClips( pl, wep )
end
end
end
end
function FillClips( ply, wep )
if wep:Clip1() < 255 then wep:SetClip1( 250 ) end
if wep:Clip2() < 255 then wep:SetClip2( 250 ) end
if wep:GetPrimaryAmmoType() == 10 or wep:GetPrimaryAmmoType() == 8 then
ply:GiveAmmo( 9 - ply:GetAmmoCount( wep:GetPrimaryAmmoType() ), wep:GetPrimaryAmmoType() )
elseif wep:GetSecondaryAmmoType() == 9 or wep:GetSecondaryAmmoType() == 2 then
ply:GiveAmmo( 9 - ply:GetAmmoCount( wep:GetSecondaryAmmoType() ), wep:GetSecondaryAmmoType() )
end
end
function Think()
for _, ply in ipairs( player.GetAll() ) do
if ( ply.UnlimitedAmmo and ply:Alive() and ply:GetActiveWeapon() != NULL ) then
self:FillClips( ply, ply:GetActiveWeapon() )
end
end
end
local uammo = ulx.command( CATEGORY_NAME, "ulx uammo", ulx.uammo, "!uammo" )
uammo:addParam{ type=ULib.cmds.PlayersArg }
uammo:defaultAccess( ULib.ACCESS_ADMIN )
uammo:help( "Gives Unlimited Ammo To Target(s)" )
uammo:logString( "#1s allowed unlimited ammo for #2s ." )
ulx.addToMenu( ulx.ID_MCLIENT, "Unlimited Ammo", "ulx uammo" )
However it doesn't work, believe I have fixed some of it up, but it still doesn't work. Heres my modified version of it.
------------------------------ Uammo ------------------------------
function ulx.uammo( calling_ply, target_plys )
for i, ply in ipairs( target_plys ) do
ply.UnlimitedAmmo = enabled
if ( enabled ) then
for i, wep in ipairs( ply:GetWeapons() ) do self:FillClips( ply, wep )
end
end
end
end
function FillClips( ply, wep )
if wep:Clip1() < 255 then wep:SetClip1( 250 ) end
if wep:Clip2() < 255 then wep:SetClip2( 250 ) end
if wep:GetPrimaryAmmoType() == 10 or wep:GetPrimaryAmmoType() == 8 then
ply:GiveAmmo( 9 - ply:GetAmmoCount( wep:GetPrimaryAmmoType() ), wep:GetPrimaryAmmoType() )
elseif wep:GetSecondaryAmmoType() == 9 or wep:GetSecondaryAmmoType() == 2 then
ply:GiveAmmo( 9 - ply:GetAmmoCount( wep:GetSecondaryAmmoType() ), wep:GetSecondaryAmmoType() )
end
end
function tick()
for i, ply in ipairs( player.GetAll() ) do
if ( ply.UnlimitedAmmo and ply:Alive() and ply:GetActiveWeapon() != NULL ) then
self:FillClips( ply, ply:GetActiveWeapon() )
end
end
end
local uammo = ulx.command( CATEGORY_NAME, "ulx uammo", ulx.uammo, "!uammo" )
uammo:addParam{ type=ULib.cmds.PlayersArg }
uammo:defaultAccess( ULib.ACCESS_ADMIN )
uammo:help( "Gives Unlimited Ammo To Target(s)" )
uammo:logString( "#1s allowed unlimited ammo for #2s ." )
ulx.addToMenu( ulx.ID_MCLIENT, "Unlimited Ammo", "ulx uammo" )
Thanks
Hamish