-- LUA Script - precede every function and global member with lowercase name of script + '_main' local U = require "scriptbank\\utillib" local Q = require "scriptbank\\quatlib" local rad = math.rad local deg = math.deg local truck_plus_list = {} function truck_plus_init( e ) Include( "utillib.lua" ) truck_plus_list[ e ] = nil end local function RePosTruck( e, pos ) -- get new Euler angles local xa, ya, za = Q.ToEuler( pos.quat ) -- reposition truck_plus CollisionOff( e ) ResetRotation( e, deg( xa ), deg( ya ), deg( za ) ) ResetPosition( e, pos.x, pos.y, pos.z ) CollisionOn( e ) -- update 'attached' decals DE_Update( e, pos.x, pos.y, pos.z, pos.quat ) end function truck_plus_main( e ) local de = truck_plus_list[ e ] local Ent = g_Entity[e] if de == nil then truck_plus_list[ e ] = { state = 'init' } return end if de.state == 'init' then -- register for dynamic entities if DE_Register == nil then return end for i = 1, 4 do DE_Register( e, 'SIGN DECO' ) DE_Register( e, 'SIGN DECO2' ) DE_Register( e, 'Barrel1' ) DE_Register( e, 'Barrel2' ) end de.state = 'show' return end if de.state == 'show' then -- show first truck DE_Show( e, 'SIGN DECO' ) DE_Show( e, 'Barrel1' ) de.state = 'tp1' end if U.PlayerLookingNear( e, 2000, 180 ) or U.PlayerCloserThan( e, 500) then return end if de.state == 'tp1' then if not PlayerCanSeeTruck( 'tp1' ) then DE_Hide( e, 'SIGN DECO' ) DE_Hide( e, 'Barrel1' ) DE_Show( e, 'SIGN DECO2' ) DE_Show( e, 'Barrel2' ) RePosTruck( e, GetTruckPos( 'tp2' ) ) de.state = 'tp2' end elseif de.state == 'tp2' then if not PlayerCanSeeTruck( 'tp2' ) then DE_Show( e, 'SIGN DECO' ) DE_Show( e, 'Barrel1' ) DE_Hide( e, 'SIGN DECO2' ) DE_Hide( e, 'Barrel2' ) RePosTruck( e, GetTruckPos( 'tp1' ) ) de.state = 'tp1' end end end