Posts: 1,355
Threads: 68
Joined: Nov 2011
Reputation:
0
Hi Guys.
I have a Working script when you press LMB an object get's created - then moves and then get's destroyed.
What i need is how can i detect if "The object is moving and there's a vehicle/player near him?
Posts: 918
Threads: 125
Joined: Nov 2010
xD, sounds like you want to do the same thing like me and twixx xD?
Well what you can do is, run a timer, get the object position in that timer and use IsPlayerInRangeOfPoint in a loop to detect who is near the object.
Unless there is a function IsVehicleInRangeOfPoint, it is pretty easily creatable by creating a stock
(you will have to use some pythagoras then)
Posts: 1,355
Threads: 68
Joined: Nov 2011
Reputation:
0
No no i'm not creating any ships canons etc..
It's some another, Oh and thanks i'll try your method.
PS: updated my code.
Posts: 918
Threads: 125
Joined: Nov 2010
Well I wasn't actually talking about the cannons, but certain attacks :P, but about that piece of code.
You are doing IsPlayerInRangeOfPoint and use the coordinates or tx, ty and tz. I suppose those are the targetcoordinats. But you are making a mistake over here. You are checking whether a player is near the objectcoordinates. So you should use x, y and z instead.
Edit: this if statement shouldn't be closed like: if(..........; like you did.
the right way: if(IsPlayerInRangeOfPoint(playerid, range, x, y, z))
Edit 2: I also see you forgot to add the range.
Posts: 918
Threads: 125
Joined: Nov 2010
View mistakes. OnObjectMoved gets called when An object has finished with moving. USe a timer instead. Targetid is 0, because you juist created IT. Remove targetid, use i instead, cus you looped through the players (i). and that if statement, dont do ;.
Posts: 2,322
Threads: 260
Joined: Jul 2010
Reputation:
0
IsObjectMoving and a loop