-- LUA Script - precede every function and global member with lowercase name of script + '_main' local Utils = require "scriptbank\\utillib" local examples = {} local numExamples = 7 function utils_example_init( e ) -- adding this line to the init function should ensure the -- library is copyed over to the stand alone Include( "utillib.lua" ) end function utils_example_main( e ) local Ent = g_Entity[e] if #examples < numExamples then local found = false for k,v in pairs( examples ) do if v == e then found = true end end if not found then examples[ #examples + 1 ] = e end end if examples[ 1 ] == e then -- Example 1: Demonstrate returning object id of entity player is looking at -- PromptLocal( e, Utils.ObjectPlayerLookingAt() or "None" ) return end if examples[ 2 ] == e then -- Example 2: Check to see if player looking at this entity -- if Utils.PlayerLookingAt( e ) then PromptLocal( e, "It's rude to stare!" ) end return end if examples[ 3 ] == e then -- Example 3: Check to see if player looking in the direction of entity -- if Utils.PlayerLookingNear( e ) then PromptLocal( e, "You looking at me kid!" ) end return end if examples[ 4 ] == e then -- Example 4: Fast check if player is closer than a given distance -- if Utils.PlayerCloserThan( e, 200 ) then PromptLocal( e, "Keep your distance!" ) end return end if examples[ 5 ] == e then -- Example 5: Pick random position wrt current position -- if Utils.PlayerCloserThan( e, 200 ) then PromptLocal( e, "Catch me if you can!" ) local newX, newZ = Utils.RandomPos( 50, Ent.x, Ent.z ) local newY = GetTerrainHeight( newX, newZ ) CollisionOff( e ) ResetPosition( e, newX, newY, newZ ) CollisionOn( e) end return end if examples[ 6 ] == e then -- Example 6: Find closest entity to player -- if Utils.ClosestEntToPlayer() == e then PromptLocal( e, "I'm the closest!" ) return end end if examples[ 7 ] == e then -- Example 7: List healthy entities -- local ents = '' for _, v in pairs(Utils.ClosestEntities()) do ents = ents .. v .. " " end PromptLocal( e, ents ) return end end