The code I posted previously did exactly what you needed it to.
I've added a few comments to the code so that you can see the reasoning.
PlayerX# = camera position x ()
PlayerZ# = camera position z ()
Box_X# = object position x (1)
Box_Z# = object position z (1)
print playerx#
print playerz#
disX# = Abs(Box_X# - PlayerX#)
disZ# = Abs(Box_Z# - PlayerZ#)
print disX#
print disZ#
Test_waypoint = 0 : waypoint = 0
AnimPlaying = 0 : AnimPlayed = 0
` If the animation hasn't already been played (flag not set)
if AnimPlayed = 0
` If we haven't already started the animation playing (flag not set)
if AnimPlaying = 0
` Calculate the distances for each axis
disX# = Abs(Box_X# - PlayerX#)
disZ# = Abs(Box_Z# - PlayerZ#)
` If within the required distance
if disX# <200 and disZ# <200
` Set a flag to say that we are playing the animation, and then play it
AnimPlaying = 1
play animation 1
endif
else
` If we got here, then the animation has been started sometime in the past
` If the animation is no longer playing
if animation playing(1) = 0
` Set the 'Played' flag so that we never play it again
AnimPlayed = 1
AnimPlaying = 0
` Delete the animation
delete animation 1
endif
endif
endif
Oh, and a flag is just a variable that usually holds an on/off type value
*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++
http://www.matrix1.demon.co.uk