Ulysses
General => Developers Corner => Topic started by: Verequies 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.
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
-
where I should put these lines?
-
this is not working :(
-
this is not working :(
Because it isn't a release, it's a question thread.
-
I cant help with that its a broken command but i can give you one that works
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" )
-
I cant help with that its a broken command but i can give you one that works 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?
-
I think this topic got no solution it would be better if a moderator can close it.
-
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.