Solved with this script (for the card reader):

-- LUA Script - precede every function and global member with lowercase name of script + '_main'
function door_keycard2_init(e)
end
function door_keycard2_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 100 and g_KeyPressE == 1 then
Spawn(e)
end
end

I've used two separate entities with same script but separate texture - "EntityOFF"-red light texture, and "EntityON" -green light texture), and set on the entities option:

for the EntityOFF set: Static Mode = NO, Use key = key card, If Used = EntityON, Spawn At Start = YES.

for the EntityON (put to cover EntityOFF at exactly match for cover it) set: Static Mode = NO, Spawn At Start = NO.

Short video example here:

This scrip for the door (set in the door options Use key = key card, If Used = open door):

-- Door Prompts 'Closed' can be opened with entity collected a key card specified by 'USE KEY' = key card
-- state to ensure user must release E key before can open/close again
door_pressed = 0
function door_keycard_init(e)
end
function door_keycard_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 100 and g_PlayerHealth > 0 then
GetEntityPlayerVisibility(e)
if g_Entity[e]['plrvisible'] == 1 then
if g_Entity[e]['activated'] == 0 then
if g_Entity[e]['haskey'] == -1 then
SetActivated(e,1)
else
if g_Entity[e]['haskey'] == 1 then
PromptDuration("The door is locked. Press E to use key card", 2000)
if g_KeyPressE == 1 then
SetActivated(e,1)
end
else
Prompt("The door is locked. Find a key card to unlock door")
end
end
else
if g_Entity[e]['activated'] == 1 then
--ShowImage(i)
-- door is unlocked and closed
PromptDuration("Valid card. Press E to open door" , 2000)
if g_KeyPressE == 1 and g_Entity[e]['animating'] == 0 and door_pressed == 0 then
SetAnimation(0)
PlayAnimation(e)
g_Entity[e]['animating'] = 1
SetActivated(e,2)
ActivateIfUsed(e)
PlaySound(e,0)
StartTimer(e)
door_pressed = 1
end
else
if g_Entity[e]['activated'] == 2 then
-- door collision off after 1 second
if GetTimer(e)> 1000 then
CollisionOff(e)
else
PromptDuration("To close door press E again",2000)
end
-- door is open
if g_KeyPressE == 1 and g_Entity[e]['animating'] == 0 and door_pressed == 0 then
SetAnimation(1)
PlayAnimation(e)
g_Entity[e]['animating'] = 1
SetActivated(e,1)
PlaySound(e,1)
CollisionOn(e)
door_pressed = 1
end
end
end
end
end
end
if g_KeyPressE == 0 then
door_pressed = 0
end
end

This script for keycard:

-- Player Collects Key
function keycard_init(e)
end
function keycard_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 80 and g_PlayerHealth > 0 then
SourceAngle = g_PlayerAngY
while SourceAngle < 0.0 do
SourceAngle = SourceAngle + 360.0
end
while SourceAngle > 340.0 do
SourceAngle = SourceAngle - 360.0
end
PlayerDX = (g_Entity[e]['x'] - g_PlayerPosX)
PlayerDZ = (g_Entity[e]['z'] - g_PlayerPosZ)
DestAngle = math.atan2( PlayerDZ , PlayerDX )
-- Convert to degrees
DestAngle = (DestAngle * 57.2957795) - 90.0
Result = math.abs(math.abs(SourceAngle)-math.abs(DestAngle))
if Result > 100 then
Result = 0
end
if Result < 20.0 then
--[[
SourceAngle = g_PlayerAngX
while SourceAngle < 0.0 do
SourceAngle = SourceAngle + 360.0
end
while SourceAngle > 335.0 do
SourceAngle = SourceAngle - 360.0
end
DestAngle = math.atan2( PlayerDZ , PlayerDY )
-- Convert to degrees
DestAngle = (DestAngle * 57.2957795) - 90.0
Result = math.abs(math.abs(SourceAngle)-math.abs(DestAngle))
if Result > 100 then
Result = 0
end
if Result < 25.0 then
--]]
Prompt ("Press E To pick up key card")
if g_KeyPressE == 1 then
PromptDuration("Collected key card",3000)
PlaySound(e,0)
Collected(e)
Destroy(e)
ActivateIfUsed(e)
end
end
end
end

So, the card reader unit is used just to have more realistic scene, because the door can be opened anyway without that unit, just using the key card

Smile today, tomorrow could be worse

http://bestradiolarry.ro/fpsarea/
"The best forum, game software, operating system or web platform, it's that software which can give you most of the features and speed, not just amazing graphics."