Make an NPC reloading

Hey all.
I’ve got a little problem.
In my new gamemode i spawn some NPC’s which should work as a guard. For this i use own NPC’s and they shoot with projectileweapons. Now is my problem that the clip is sometimes empty. So how can i make my NPC’s reloading?

Greetings Obstsalat


	// Shoot it (third objective in task)
	schdChase:EngTask( "TASK_STOP_MOVING", 			0 )
	schdChase:EngTask( "TASK_FACE_ENEMY", 			0 )
	schdChase:EngTask( "TASK_ANNOUNCE_ATTACK", 		0 )
	schdChase:EngTask( "TASK_RANGE_ATTACK1", 		0 )
	schdChase:EngTask( "TASK_RELOAD", 			0 )

ok, stupid question.
With thisone he only shoots one time or until the clip is empty?

Shoots a couple of times, I think. Just add more attack tasks before reloading.

I tried it and it dont worked. Here is the code i used.



for k, v in pairs( ents.GetAll() ) do
			if v:IsNPC() then
				if v:GetModel() == "models/players/soldier.mdl" then
					if v:GetNPCState() == NPC_STATE_COMBAT then
							local schdChase= ai_schedule.New( "AI Attack" )
							schdChase:EngTask( "TASK_STOP_MOVING", 0 )
							schdChase:EngTask( "TASK_FACE_ENEMY", 0 )
							schdChase:EngTask( "TASK_RANGE_ATTACK1", 0 )
							schdChase:EngTask( "TASK_RELOAD", 0 )
							v:SetSchedule(schdChase)
					end
				end
			end	
		end

I also tried with StartSchedule. But nothing worked. I just want these NPCS to reload.

I thought you were using SNPC’s. I dont know if it’ll work like that.

[editline]05:04PM[/editline]

Well, it didnt - but you know…