Possible Anti-Aircraft?
#1

I was wondering if this is possible?

Create a cannon object (might be a customized heat-seeker rocket or minigun) when player press F key (or ALT key). He will attached to that object and cannot be moved (Only the cursor or mouse will work to target the enemy) just like a anti-aircraft.

EDIT: I know there is an anti-aircraft but it's a missile. and I was referring to cannon that explodes in the air.


Reply
#2

https://sampforum.blast.hk/showthread.php?tid=115695
Reply
#3

thanks but not this. OR maybe i'm not good enough to make a script similar to this.
Reply
#4

Yes, it is possible with GetPlayerCameraFrontVector
Reply
#5

EDIT
Reply
#6

Quote:
Originally Posted by newbienoob
Посмотреть сообщение
Yes, it is possible with GetPlayerCameraFrontVector
thanks I think it's becoming clear now. So I found this on sa-mp wiki. So how about if I will change the hydra missile to explosion. How do I do that? Also from left of the football field to right before the explosion.

Код:
// A simple command to manipulate this vector using the
// positions from GetPlayerCameraPos. This command will create
// a hydra missile in the direction of where the player is looking.
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (!strcmp(cmdtext, "/test camera vector"))
	{
		new
			Float:fPX, Float:fPY, Float:fPZ,
			Float:fVX, Float:fVY, Float:fVZ,
			Float:object_x, Float:object_y, Float:object_z;
 
		// Change me to change the scale you want. A larger scale increases the distance from the camera.
		// A negative scale will inverse the vectors and make them face in the opposite direction.
		const
			Float:fScale = 5.0;
 
		GetPlayerCameraPos(playerid, fPX, fPY, fPZ);
		GetPlayerCameraFrontVector(playerid, fVX, fVY, fVZ);
 
		object_x = fPX + floatmul(fVX, fScale);
		object_y = fPY + floatmul(fVY, fScale);
		object_z = fPZ + floatmul(fVZ, fScale);
 
		CreateObject(345, object_x, object_y, object_z, 0.0, 0.0, 0.0);
 
		return 1;
	}
 
	return 0;
}
Reply
#7

Can you please give me idea or a simple script demo on how to do this?

A player who is able to use his mouse cursor to aim the enemy while he is standing with the cannon?
Reply
#8

https://sampforum.blast.hk/showthread.php?tid=484765
You can use some of it's implementation to look at how it follows aircrafts, etc.

And yes, GetPlayerCameraFrontVector - the WIKI example creates an object where you shoot, here you would create an explosion. You could freeze the player (if camera freezes, then just reset his position each time he moves) and..

EDITING
Reply
#9

Thanks Rajat but actually i'm not doing a rocket that follows the airlcrafts. What I suppose to do is a FLAK CANNON. I would probably using GetPlayerCameraFrontVector for this.

Do you know how do I get the distance of a player above the clouds?

For sure i'm going to use CreateExplosion as my flak cannon explosion.
Reply
#10

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp(cmdtext, "/test"))
    {
        new
            Float:fPX, Float:fPY, Float:fPZ,
            Float:fVX, Float:fVY, Float:fVZ,
            Float:object_x, Float:object_y, Float:object_z;
 
        // Change me to change the scale you want. A larger scale increases the distance from the camera.
        // A negative scale will inverse the vectors and make them face in the opposite direction.
        const
            Float:fScale = 5.0;
 
        GetPlayerCameraPos(playerid, fPX, fPY, fPZ);
        GetPlayerCameraFrontVector(playerid, fVX, fVY, fVZ);
       
 
        object_x = fPX + floatmul(fVX, fScale);
        object_y = fPY + floatmul(fVY, fScale);
        object_z = fPZ + floatmul(fVZ, fScale);
 
        for(new i = 0 ; i < MAX_PLAYERS ; i++ )
        {
            if( IsPlayerInAnAircraft( i ) )
            {
                new Float: vX, vY, vZ;
                GetVehiclePos( GetPlayerVehicleID( i ), vX, vY, vZ);
                if( IsPointInRangeOf( object_x, object_y, object_z, vX, vY, vZ, fScale units .. ) )
                {
                    SetVehicleHealth( Aircraft, EARLIER_HEALTH - (SOME_CONSTANT/DISTANCE_BETWEEN_THE_TWO_COORDINATE_SETS) );
                    // The shorter the distance, more is the damage
                    ......
                                        CreateExplosion( .. );
                    ......
 
        return 1;
    }
 
    return 0;
}
Used some fake functions and psuedo code, but you should get my point!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)