-- LUA Script - precede every function and global member with lowercase name of script + '_main' g_fiberscollected = g_fiberscollected or 0 local U = require "scriptbank\\utillib" math.randomseed(os.time()) math.random(); math.random(); math.random() local zone = {} function collect_fibers_init(e) Include( "utillib.lua" ) end function collect_fibers_main(e) local inZone = zone[e] if inZone == nil then if ZonePointIn ~= nil then local Ent = g_Entity[e] local zName = ZonePointIn( Ent.x, Ent.z ) if zName ~= 'None' then zone[e] = zName end end else if PlayerIsInZone( inZone ) then if U.PlayerLookingNear( e, 90, 30 ) then Prompt("Press E to collect Fibers.") if g_KeyPressE == 1 then PlaySound(e,0) g_fiberscollected = g_fiberscollected + math.random(1 , 5) -- get new position for this entity local otherZone = 'Zone2' if inZone == 'Zone2' then otherZone = 'Zone1' end local x,y,z = RandomPointInZone(otherZone) if x ~= 0 then CollisionOff(e) SetPosition( e, x, y, z ) CollisionOn(e) zone[e] = otherZone else Destroy(e) end end end end end end