Hi guys, so I am attempting to use an NPC to open a door, not entirely sure if this is possible, but if so, I would love to know how. Below is the script I have used to speak with an NPC and currently have only set the option of 'E'.
g_KeyPressE = 0
g_KeyPressQ = 0
function questnpc_init(e)
CharacterControlUnarmed(e)
end
function questnpc_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 200 then
LookAtPlayer(e)
if g_KeyPressE == 0 then
Prompt ( "Mr Detective, you must select one of the following paths, 'E' will send you down a path of failure and 'Q' will send you on a path of fortune" )
else
if g_KeyPressE == 1 then
Prompt ( "Congrats Mr Detective" )
end
end
end
--if string.find(string.lower(g_Entity[e]['limbhit']), "head" ~= nil then
-- SetEntityHealth(e,0)
-- ResetLimbHit(e)
-- end
end
Here is the script for the door, however, I can press 'E' at spawn and this door will just open without having the prompt from the NPC, I am stuck and am getting frustrated.
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
g_KeyPressE = 0
door_pressed = 0
function dooropen_init(e)
end
function dooropen_main(e)
PlayerDist = GetPlayerDistance(e)
if g_KeyPressE == 1 and g_Entity[e]['animating'] == 0 and door_pressed == 0 then
--GetEntityPlayerVisibility(e)
--if 1 then
if g_Entity[e]['activated'] == 0 then
SetAnimation(0)
PlayAnimation(e)
g_Entity[e]['animating'] = 1
CollisionOff(e)
ActivateIfUsed(e)
PlaySound(e,0)
StartTimer(e)
door_pressed = 1
end
--end
if g_Entity[e]['activated'] == 1 then
if GetTimer(e)>1000 then
CollisionOff(e)
door_pressed = 1
end
end
else
if g_Entity[e]['activated'] == 2 then
SetAnimation(1)
PlayAnimation(e)
g_Entity[e]['animating'] = 1
PlaySound(e,1)
CollisionOn(e)
door_pressed = 1
end
end
end
Any help would be much appreciated, not expecting anyone to write the script for me, just guidance will be appreciated.