SA-MP Forums Archive
drop bombs - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: drop bombs (/showthread.php?tid=292315)



drop bombs - jiwan - 23.10.2011

i want to make a FS that drops bombs from plane i want to make it myself.... So please help me by giving hints that how can i do that !!!


Re: drop bombs - grand.Theft.Otto - 23.10.2011

You need to create a timer. Something like this for example:

pawn Код:
// in a /bomb command for example:

if(strcmp("/bomb", cmdtext, true, 5) == 0)
{
    GameTextForAll("~w~the bomb has been ~r~~n~dropped ~n~~w~exploding in ~p~10 sec",5000,3);

    SetTimerEx("Bomb",10000,false,"d",playerid); // bomb timer set for 10sec, will not repeat
   
    return 1;
}

// bottom of script

forward Bomb(playerid);
public Bomb(playerid)
{
    GameTextForAll("~w~the ~r~bomb ~w~has ~r~exploded!",5000,3);
   
    CreateExplosion(x,y,z,type,Float:Radius);
   
    return 1;
}



Re: drop bombs - jiwan - 23.10.2011

Thank You for your help

BUT

i want to drop this bomb from a plane in that case what can i do ?


Re: drop bombs - grand.Theft.Otto - 23.10.2011

You need the plane interior coordinates. If they are in range, the bomb will drop, if not it will return an error message.

When you use the CreateExplosion function, make the coordinates somewhere on the ground or something, since it's falling from a plane, downward.

pawn Код:
// in a /bomb command for example:
if(strcmp("/bomb", cmdtext, true, 5) == 0)
{
    if(IsPlayerInRangeOfPoint(playerid,10,x,y,z)) // plane interior coordinates
    {
        GameTextForAll("~w~the bomb has been ~r~~n~dropped ~n~~w~exploding in ~p~10 sec",5000,3);

        SetTimerEx("Bomb",10000,false,"d",playerid);

        return 1;
    } else return SendClientMessage(playerid,-1,"You Must Be In A Plane To Use This Command.");
}

// bottom of script

forward Bomb(playerid);
public Bomb(playerid)
{
    GameTextForAll("~w~the ~r~bomb ~w~has ~r~exploded!",5000,3);

    CreateExplosion(x,y,z,type,Float:Radius);

    return 1;
}



Re: drop bombs - jiwan - 23.10.2011

yeah that was helpful but i want that when a player in a plane (assume Neavada) presses fire button it drops a bomb(Visible) to ground which explodes when it hit ground.. bombs ammo should be 40-60 and plane can drop 20 bombs constantly and then a delay period of 5 sec. saying that reloading bombs !!

is it is possible or not ?


Re: drop bombs - grand.Theft.Otto - 23.10.2011

Yes it's possible, you would have to use SetPlayerPos a lot to make the bomb drop in mid air.

I'm not too sure how to make it properly though, sorry.


Re: drop bombs - Zonoya - 23.10.2011

u use this here is an example using ur script Otto
pawn Код:
// top of script
new bomb;
// in a /bomb command for example:
if(strcmp("/bomb", cmdtext, true, 5) == 0)
{
    if(IsPlayerInRangeOfPoint(playerid,10,x,y,z)) // plane interior coordinates
    {
        new float: x, y, z, a, VID;
        VID = GetPlayerVehicleID(playerid);
        GameTextForAll("~w~the bomb has been ~r~~n~dropped ~n~~w~exploding in ~p~10 sec",5000,3);
        GetVehiclePos(VID, x, y, z);
        GetVehicleZAngle(VID, a);
        Bomb = CreateObject(bombobjectid, x, y, z, RotX, RotY, a);
        MoveObject(Bomb, x, y, z, speed);
        SetTimerEx("Bomb",10000,false,"d",playerid);

        return 1;
    } else return SendClientMessage(playerid,-1,"You Must Be In A Plane To Use This Command.");
}

// bottom of script

forward Bomb(playerid);
public Bomb(playerid)
{
    GameTextForAll("~w~the ~r~bomb ~w~has ~r~exploded!",5000,3);

    CreateExplosion(x,y,z,type,Float:Radius);

    return 1;
}
thats how u get the vehicle rotation position and create the bomb and move it i think lol

Not 100% sure though may not work!


Re: drop bombs - jiwan - 23.10.2011

is that the command that i need to use when i want to drop bombs by just pressing fire button my keyboard


Re: drop bombs - austin070 - 23.10.2011

Quote:
Originally Posted by jiwan
Посмотреть сообщение
is that the command that i need to use when i want to drop bombs by just pressing fire button my keyboard
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_FIRE)
    {
        if(IsPlayerInRangeOfPoint(playerid,10,x,y,z)) // plane interior coordinates
        {
            new float: x, y, z, a, VID;
            VID = GetPlayerVehicleID(playerid);
            GameTextForAll("~w~the bomb has been ~r~~n~dropped ~n~~w~exploding in ~p~10 sec",5000,3);
            GetVehiclePos(VID, x, y, z);
            GetVehicleZAngle(VID, a);
            Bomb = CreateObject(bombobjectid, x, y, z, RotX, RotY, a);
            MoveObject(Bomb, x, y, z, speed);
            SetTimerEx("Bomb",10000,false,"d",playerid);
        } else return SendClientMessage(playerid,-1,"You Must Be In A Plane To Use This Command.");
    }
    return 1;
}
If you want it using KEY_FIRE


Re: drop bombs - cruising - 23.10.2011

To make the bomb explode when hitting ground, use mapandreas.