-- Script to handle a cancun girl -- -- This object will -- o Play an animation at random time intervals -- o Become 'collected' when a player enters a certain radius -- o Make the rider and bike invisible for duration of cutscene -- o Pause the game, switch cameras and display a cutscene on collection -- o Deactivate and remove from view once collected -- -- *WARNING* -- This script is currently hardocoded to player/viewport 0. It won't -- work in a multiplayer environment. If this is required, the script will -- need to be extended. function InitGirlfriend () print("initing girlfriend") print("Loading all my models...") end function UninitGirlfriend () print("Uniniting girlfriend") Anim.RemoveAnimation(girlfriend_clip1); Anim.RemoveAnimation(girlfriend_clip2); end function CreateGirlfriend (id) Object.CreateAnimationManager(id,3) return coroutine.create(UpdateGirlfriend) end function UpdateGirlfriend(myID) local dt=0 local reason=0 local time=0 local closeto=false local collected = false local model1,model2 local GirlFriendCharacter = Object.LoadCharacter("Cancun/Can2") girlfriend_clip1 = Anim.LoadAnimation("Animations/HotChicks/hotchick1_idle.bac") girlfriend_clip2 = Anim.LoadAnimation("Animations/HotChicks/hotchick1_clapping.bac") Object.SetCharacter(myID,GirlFriendCharacter) Object.PlayAnimation(myID,girlfriend_clip1,true,0.1) Object.CreateSphereTouchfield(myID,0,0,0,1.7) Object.UpdateOnSphereTouchfield(myID,true) Object.SetUpdateRate(myID,0) while true do dt,reason = coroutine.yield() if collected == false and reason == 1 then ShowVehicle(0, 0) Sound.PlayPedsSound(1,Object.GetPosition(myID)) Object.SetUpdateRate(myID,0) Object.UpdateOnSphereTouchfield(myID,false) Object.StopAnimation(myID) Object.UpdateOnAnimFinished(myID,true) -- Setup the cutscene camera local lastCamera lastCamera = Camera.GetType(0) -- Hardcoding viewport Camera.SetScriptedCameraPosition( 0, Object.TransformToWorldPosition(myID,1.5,2,6) ) Camera.SetScriptedCameraLookat(0,Object.GetPosition(myID)) Camera.SetScriptedCamera(0) -- Enter a cutscene State.PauseForCutscene() -- Play my animation Object.PlayAnimation(myID,girlfriend_clip2,false,1.0) -- Wait till its done dt, reason = coroutine.yield() Camera.SetType(0,lastCamera) Object.ClearCharacter(myID) ShowVehicle(0, 1) State.ResumeAfterCutscene() Object.Deactivate(myID) Object.SetCollected(myID,0) -- Hardcoding collector collected = true end end end