ULX

Author Topic: ULX Unlimited Ammo  (Read 6264 times)

0 Members and 1 Guest are viewing this topic.

Offline Verequies

  • Newbie
  • *
  • Posts: 5
  • Karma: 1
ULX Unlimited Ammo
« on: March 05, 2014, 01:29:55 AM »
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.
Code: [Select]
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.
Code: [Select]
------------------------------ 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

Offline kem008

  • Newbie
  • *
  • Posts: 5
  • Karma: -2
Re: ULX Unlimited Ammo
« Reply #1 on: March 05, 2015, 10:28:27 AM »
where I should put these lines?

Offline kem008

  • Newbie
  • *
  • Posts: 5
  • Karma: -2
Re: ULX Unlimited Ammo
« Reply #2 on: March 09, 2015, 01:43:20 PM »
this is not working :(

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: ULX Unlimited Ammo
« Reply #3 on: March 09, 2015, 03:29:02 PM »
this is not working :(
Because it isn't a release, it's a question thread.
bw81@ulysses-forums ~ % whoami
Homepage

Offline BobTheDuck69

  • Newbie
  • *
  • Posts: 33
  • Karma: 1
Re: ULX Unlimited Ammo
« Reply #4 on: March 12, 2015, 11:21:47 AM »
I cant help with that its a broken command but i can give you one that works
Code: [Select]
function ulx.ammo( calling_ply, target_plys, amount, should_setammo )

for i=1, #target_plys do

local player = target_plys[ i ]

local actwep = player:GetActiveWeapon()

local curammo = actwep:GetPrimaryAmmoType()

if !should_setammo then
player:GiveAmmo( amount, curammo )
else
player:SetAmmo( amount, curammo )
end

end

if should_setammo then
ulx.fancyLogAdmin( calling_ply, "#A set the ammo for #T to #s", target_plys, amount )
else
ulx.fancyLogAdmin( calling_ply, "#A gave #T #i rounds", target_plys, amount )
end

end
local ammo = ulx.command( "Custom", "ulx giveammo", ulx.ammo, "!giveammo" )
ammo:addParam{ type=ULib.cmds.PlayersArg }
ammo:addParam{ type=ULib.cmds.NumArg, min=0, hint="amount" }
ammo:addParam{ type=ULib.cmds.BoolArg, invisible=true }
ammo:defaultAccess( ULib.ACCESS_ADMIN )
ammo:help( "Set a player's ammo" )
ammo:setOpposite( "ulx setammo", { _, _, _, true }, "!setammo" )
~The friendly neighborhood duckie~

Offline COOLJ

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: ULX Unlimited Ammo
« Reply #5 on: March 14, 2015, 04:16:24 AM »
I cant help with that its a broken command but i can give you one that works
Code: [Select]
function ulx.ammo( calling_ply, target_plys, amount, should_setammo )

for i=1, #target_plys do

local player = target_plys[ i ]

local actwep = player:GetActiveWeapon()

local curammo = actwep:GetPrimaryAmmoType()

if !should_setammo then
player:GiveAmmo( amount, curammo )
else
player:SetAmmo( amount, curammo )
end

end

if should_setammo then
ulx.fancyLogAdmin( calling_ply, "#A set the ammo for #T to #s", target_plys, amount )
else
ulx.fancyLogAdmin( calling_ply, "#A gave #T #i rounds", target_plys, amount )
end

end
local ammo = ulx.command( "Custom", "ulx giveammo", ulx.ammo, "!giveammo" )
ammo:addParam{ type=ULib.cmds.PlayersArg }
ammo:addParam{ type=ULib.cmds.NumArg, min=0, hint="amount" }
ammo:addParam{ type=ULib.cmds.BoolArg, invisible=true }
ammo:defaultAccess( ULib.ACCESS_ADMIN )
ammo:help( "Set a player's ammo" )
ammo:setOpposite( "ulx setammo", { _, _, _, true }, "!setammo" )

Is that already on Releases if not may I use this and upload it?

Offline kem008

  • Newbie
  • *
  • Posts: 5
  • Karma: -2
Re: ULX Unlimited Ammo
« Reply #6 on: January 12, 2016, 05:19:13 AM »
I think this topic got no solution it would be better if a moderator can close it.

Offline WispySkies

  • Full Member
  • ***
  • Posts: 144
  • Karma: 0
  • I make random commands and Lua errors.
Re: ULX Unlimited Ammo
« Reply #7 on: January 12, 2016, 05:59:51 AM »
You don't need to close this thread just because there is no answer, if anyone is interested in wanting this I can make something for it to work.

EDIT: So far all it does is freeze your game.
« Last Edit: January 12, 2016, 01:47:57 PM by WispySkies »