Is this possible
#1

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?
Reply
#2

You can get the Object/Vehicle position and check with IsPlayerInRangeOfPoint + Loop if have a player near the object.
Reply
#3

Hm..
Can you give me example?
Код:
IsPlayerInRangeOfPoint
on a timer
checking missile positions and player positions
and vehicle positiosn
Reply
#4

This is what i tried so far
pawn Код:
new targetid,
                Float:x,
                Float:y,
                Float:z
                                                   Float:tx,
                                                   Float:ty
                                                   Float:tz;

            GetObjectPos(gRocketObj[i], x, y, z);// Get the position of the object
            if(IsPlayerInRangeOfPoint(playerid, tx, ty, tz); //Pos of Target
            {  
                CreateExplosion(x, y, z, 11, 2.50);      // Create an explosion at this position
                DestroyObject(gRocketObj[i]); // Destroy the object
            }
Reply
#5

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)
Reply
#6

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.
Reply
#7

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.
Reply
#8

Oh Right
pawn Код:
public OnObjectMoved(objectid)
{
    for(new i;i<MAX_PLAYERS;i++)                    // Loop through players
    {
        if(objectid == gRocketObj[i])               // If this object is one of those player objects
        {
            new targetid,
                Float:x,
                Float:y,
                Float:z;

            GetObjectPos(gRocketObj[i], x, y, z);
            if(IsPlayerInRangeOfPoint(targetid,3.0, x, y, z)); // Get the position of the object
            {  
                CreateExplosion(x, y, z, 11, 2.50);      // Create an explosion at this position
                DestroyObject(gRocketObj[i]); // Destroy the object
            }          
        }
    }
}

Код:
C:\Users\Warkadang\Desktop\Scripting\Scripting\filterscripts\Test.pwn(54) : error 036: empty statement
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Can't seem to fix it
PS: will it work?
Reply
#9

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 ;.
Reply
#10

IsObjectMoving and a loop
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)