-- Script to handle a pedestrian -- function InitRaceFinishPed () print("initing RaceFinishPed") print("Loading all my models...") -- Change these values back to 3 and 2 for the full compliment of pedestrians -- NumberOfMaleRacePeds=3 -- NumberOfFemaleRacePeds=2 NumberOfMaleRacePeds=1 NumberOfFemaleRacePeds=0 MaleRacePeds = {Object.LoadCharacter("NewYork/NY3"),Object.LoadCharacter("NewYork/NY1"),Object.LoadCharacter("NewYork/NY5")} FemaleRacePeds = {Object.LoadCharacter("NewYork/NY2"),Object.LoadCharacter("NewYork/NY4")} if(MaleRaceFinishPed_Idle1 == nil) then MaleRaceFinishPed_Idle1 = Anim.LoadAnimation("Animations/Pedestrians/man_idle.bac") MaleRaceFinishPed_Clap = Anim.LoadAnimation("Animations/Pedestrians/man_acknowledge.bac") FemaleRaceFinishPed_Idle1 = Anim.LoadAnimation("Animations/Pedestrians/woman_idle.bac") FemaleRaceFinishPed_Clap = Anim.LoadAnimation("Animations/Pedestrians/woman_acknowledge.bac") end end function CreateRaceFinishPed (id) Object.CreateAnimationManager(id,3) return coroutine.create(UpdateRaceFinishPed) end function UpdateRaceFinishPed(myID) local dt=0 local reason=0 local time=0 local RaceFinishPedCharacter=0 local IdleAnim=0 local ClapAnim=0 if math.random(2)==1 then IdleAnim=MaleRaceFinishPed_Idle1 ClapAnim=MaleRaceFinishPed_Clap RaceFinishPedCharacter = MaleRacePeds[math.random(NumberOfMaleRacePeds)] else IdleAnim=FemaleRaceFinishPed_Idle1 ClapAnim=FemaleRaceFinishPed_Clap RaceFinishPedCharacter = FemaleRacePeds[math.random(NumberOfFemaleRacePeds)] end -- Update now... Object.SetUpdateRate(myID,0.001) dt,reason = coroutine.yield() Object.SetUpdateRate(myID,0) -- Wait for activation... Object.UpdateOnReceiveMessage(myID,true) dt,reason = coroutine.yield() Object.SetCharacterSwitchOffDistance(RaceFinishPedCharacter,70) Object.SetCharacter(myID,RaceFinishPedCharacter) Object.UpdateOnAnimFinished(myID,true) local x,y,z,ny local b=0 local cheering=false x,y,z = Object.GetPosition(myID) print("Loaded") while true do -- Lets hang around a bit more... if math.random(3)==1 then Object.PlayAnimation(myID,IdleAnim,false,0.7) else Object.PlayAnimation(myID,ClapAnim,false,0.90+(math.random(10)/10)) end dt,reason = coroutine.yield() end end