Setting Keyvalue for spawned npc

I’m having trouble setting a key value to an npc spawned in my gamemode.

The code:
[lua]function spawnrifleman(ply)
if ply:Team() == 1 then
RunConsoleCommand( “npc_create_equipment”, “weapon_SMG1” )
RunConsoleCommand( “npc_create”, “npc_citizen” )

end[/lua]

What I want to do is spawn the citizen with another key value (to make him a rebel). In another instance I also want to spawn one as a medic too.

How could I do this?

[lua]
ent:SetKeyValue(“spawnflags”, “SPAWNFLAGSHERE”)
ent:Spawn()
[/lua]

Should do it.

What do I put instead of ‘ent.’? Do I have to name the citizen or do I put in npc_citizen?

[lua]
local ent = ents.Create(“npc_citizen”)
ent:SetKeyValue(“spawnflags”, “SPAWNFLAGSHERE”)
ent:Spawn()
[/lua]

Instead of console commands.

Thanks. This will help me a lot in the future too.