Ammo Timer

my next problem is a timer that shut give players ammo and health.

i placed the code in init.lua i have also tryd whit cl_inint.lua no 1 works that means its my code!

but whats wrong?

timer.Create( “AmmoTimer”, 30, 0, function( ply )

ply:Give( "item_ammo_smg1")
ply:Give( "item_ammo_pistol")
ply:Give( "item_healthvial")


A littel help plz!

(sry for bad eng)

Well, you didn’t specified the player argument (ply) but what do you want to do, give the ammos to all players or give them to a specified player?

You need an extra argument.

I’ll also organize some of the code slightly better.

local function GiveItems( ply )
ply:Give( “item_ammo_smg1”)
ply:Give( “item_ammo_pistol”)
ply:Give( “item_healthvial”)

timer.Create( “AmmoTimer”, 30, 0, GiveItems, ply)


timer.Create Wiki Page

Still you need to get that ply argument from somewhere

ply=player ?

Where are you creating this timer?

If you want to give ammo to every player in the timer, you can loop through them all.

[lua]timer.Create(“AmmoTimer”, 30, 0, function()
for _, ply in ipairs(player.GetAll()) do

He means you need to get the players entity/object, it does not know what ply is until you tell it.

This will work, but you pot reps at 0 so it will give this stuff every 30 seconds

I know, that is what the OP did, so I assumed that is what he wanted.


i need the timer for my gamemode so that players have to wait to get ammo to there weapons i created a mp5 and deagle working on my knife and so on

thanks for the help whit the timer

works great