Hey guys! I was looking for a script for deathrun for infinite ammo, Deathrun has a default inf ammo but it dosent work for HL2 Weapons! Please help me with an infinite ammo script and where to place it! Thanks!
[code]for k, v in pairs( player.GetAll() ) do
ply:ConCommand( "givecurrentammo" )
end[/code]
Won't work since it's classified as a cheat
Would be better off just making a table of HL2 guns and their ammo types and giving 999 of them every second or so with GiveAmmo
[QUOTE=BFG9000;47344610]Won't work since it's classified as a cheat
Would be better off just making a table of HL2 guns and their ammo types and giving 999 of them every second or so with GiveAmmo[/QUOTE]
You don't really need a table, you can just do something like this.
I pulled this out of one of my gamemodes.
[lua]
local plyMeta = FindMetaTable( "Player" )
function plyMeta:GiveCurrentPrimaryAmmo( amt )
local activeWep = self:GetActiveWeapon( )
if ( IsValid( activeWep ) and activeWep:GetPrimaryAmmoType( ) ) then
self:GiveAmmo( amt, activeWep:GetPrimaryAmmoType( ) )
end
end
function plyMeta:GiveCurrentSecondaryAmmo( amt )
local activeWep = self:GetActiveWeapon( )
if ( IsValid( activeWep ) and activeWep:GetSecondaryAmmoType( ) ) then
self:GiveAmmo( amt, activeWep:GetSecondaryAmmoType( ) )
end
end
[/lua]
[QUOTE=Jeezy;47344751]You don't really need a table, you can just do something like this.
I pulled this out of one of my gamemodes.
[lua]
local plyMeta = FindMetaTable( "Player" )
function plyMeta:GiveCurrentPrimaryAmmo( amt )
local activeWep = self:GetActiveWeapon( )
if ( IsValid( activeWep ) and activeWep:GetPrimaryAmmoType( ) ) then
self:GiveAmmo( amt, activeWep:GetPrimaryAmmoType( ) )
end
end
function plyMeta:GiveCurrentSecondaryAmmo( amt )
local activeWep = self:GetActiveWeapon( )
if ( IsValid( activeWep ) and activeWep:GetSecondaryAmmoType( ) ) then
self:GiveAmmo( amt, activeWep:GetSecondaryAmmoType( ) )
end
end
[/lua][/QUOTE]
Thank you so much, Where should I put that in my FTP?
[QUOTE=dylanr423;47348693]Thank you so much, Where should I put that in my FTP?[/QUOTE]
Just put it in whichever script you're already working on. You'll still need to call the functions there for it to work.
[QUOTE=Greetings;47348757]Just put it in whichever script you're already working on. You'll still need to call the functions there for it to work.[/QUOTE]
Im not working on a script? I need to know where to place this hahah
[QUOTE=dylanr423;47352061]Im not working on a script? I need to know where to place this hahah[/QUOTE]
Put it in a server side file. For example, create a file with any name and .lua extenstion in /lua/autorun/server/
However, you still need to call the functions. To do this you should use a hook. You can read up about hooks here: [url]http://wiki.garrysmod.com/page/Hook_Library_Usage[/url]
Sorry, you need to Log In to post a reply to this thread.