Hi Smallg , i have started to use your inventory scrip, i have placed all files in the inventory2 folder, i have attached the inventory _pickup script to my battery and added my original script " collect_battery.lua " in the inventory2 folder but then i can not use it to access my fault door.
i have added collect_battery in the script see below script.
local script_name = {}
function inventory_pickup_init_name(e,name)
item_name[e] = name
useitem[e] = 0
if string.find(string.lower(item_name[e]),"med") ~= nil then
require "scriptbank//health"
script_name[e] = "health"
elseif string.find(string.lower(item_name[e]),"ammo") ~= nil then
require "scriptbank//ammo"
script_name[e] = "ammo"
elseif string.find(string.lower(item_name[e]),"weapon") ~= nil then
require "scriptbank//inventory2//weapon_pickup"
script_name[e] = "weapon_pickup"
elseif string.find(string.lower(item_name[e]),"key") ~= nil then
require "scriptbank//inventory2//key_pickup"
script_name[e] = "key_pickup"
elseif string.find(string.lower(item_name[e]),"Battery") ~= nil then
require "scriptbank//inventory2//collect_battery"
script_name[e] = "collect_battery"
end
end
function inventory_pickup_main(e)
if useitem[e] == 0 then
if PlayerLooking(e,100,10) == 1 then
PromptLocal(e,"Pick up "..item_name[e].."?")
--fpath = GetEntityFilePath(e)
--Prompt(string.gsub(fpath,"fpe","bmp"))
if g_Scancode == 0 then
pressed = 0
end
if g_Scancode == 18 and pressed == 0 then
pressed = 1
for b = 1, g_invpages do
for a = 1, inv_slots_total do
if g_invslot[b][a] == 0 then
PlaySound(e,0)
g_invslot[b][a] = e
SetPosition(e,-100000,-100000,-100000)
ResetPosition(e,-100000,-100000,-100000)
Hide(e)
return
end
end
end
PromptDuration("Inventory is full",2000)
end
end
else
SwitchScript(e,script_name[e])
end
end
function inventory_pickup_exit(e)
end
here is my original collect_battery script.
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
function collect_battery_init(e)
have_batery = 0
end
function collect_battery_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 80 and g_PlayerHealth > 0 and have_batery == 0 then
Prompt(" Press E to collect Battery ")
if GetInKey() == "e" or GetInKey() == "E" then
have_batery = 1
PromptDuration("Collected a Battery",3000)
PlaySound(e,0)
Destroy(e)
ActivateIfUsed(e)
end
end
end
please help me .
Pcs.
Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11