/triggerbomb command
#1

Hey guys, I started with new command.. for now I have only start of /bomb command:

pawn Код:
if(strcmp(cmd, "/plantbomb", true) == 0 || strcmp(cmd, "/pb", true) == 0)
    {
        new Float:X, Float:Y, Float:Z, bool: in_range;
        for(new a = 1; a < MAX_VEHICLES - 1; a++)
    {
    if (!GetVehiclePos(a, X, Y, Z)) continue; // vehicle does not exist
    if (IsPlayerInRangeOfPoint(playerid, 4.0, X, Y, Z))
    {
        in_range = true;
        break;
    }
    }
        SendClientMessage(playerid, -1, (in_range) ? ("{FF6A22}INFO:{FFFFFF} Bomb planted!") : ("{FF6A22}INFO:{FFFFFF} No vehicles near you to plant bomb."));
        return 1;
    }
How can I make /triggerbomb command that will make explosion at car coordinates that bomb is planted on?

rep+
Reply
#2

This Will Help You :
https://sampwiki.blast.hk/wiki/CreateExplosion
+Rep If I helped You !
Reply
#3

Umm yes I checked that already, but two commands I need to save coordinates of vehicles to variable and use it in other command so explosion will be at same coordinates ?
Reply
#4

Yes!!! Directly CreateExplosion X Y Z 10.0 etcc..
Reply
#5

pawn Код:
if(strcmp(cmd, "/plantbomb", true) == 0 || strcmp(cmd, "/pb", true) == 0)
    {
        new Float:X, Float:Y, Float:Z, bool: in_range;
        for(new a = 1; a < MAX_VEHICLES - 1; a++)
        {
        if (!GetVehiclePos(a, X, Y, Z)) continue; // vehicle does not exist
        if (IsPlayerInRangeOfPoint(playerid, 4.0, X, Y, Z))
        {
            in_range = true;
            break;
        }
        }
        SendClientMessage(playerid, -1, (in_range) ? ("{FF6A22}INFO:{FFFFFF} Bomb planted!") : ("{FF6A22}INFO:{FFFFFF} No vehicles near you to plant bomb."));
        return 1;
    }
   
    if(strcmp(cmd, "/triggerbomb", true) == 0 || strcmp(cmd, "/tb", true) == 0)
    {
        new Float:X, Float:Y, Float:Z;
        for(new a = 1; a < MAX_VEHICLES - 1; a++)
        {
            GetVehiclePos(a, X, Y, Z);
            CreateExplosion(X, Y, Z, 12, 10.0);
        }
        return 1;
    }
Well I tried this and it's not working.
Reply
#6

pawn Код:
new Float:pbX, Float:pbY, Float:pbZ; // At the top of your gamemode.
Use these.

Also if you want them to be assigned to a player, add MAX_PLAYERS to them.
Reply
#7

okay now explosion is at coordinates I wrote /plantbomb but it doesn't move with vehicle? :/

pawn Код:
if(strcmp(cmd, "/plantbomb", true) == 0 || strcmp(cmd, "/pb", true) == 0)
    {
        new bool: in_range;
        for(new a = 1; a < MAX_VEHICLES - 1; a++)
        {
        if (!GetVehiclePos(a, pX, pY, pZ)) continue; // vehicle does not exist
        if (IsPlayerInRangeOfPoint(playerid, 4.0, pX, pY, pZ))
        {
            in_range = true;
            break;
        }
        }
        SendClientMessage(playerid, -1, (in_range) ? ("{FF6A22}INFO:{FFFFFF} Bomb planted!") : ("{FF6A22}INFO:{FFFFFF} No vehicles near you to plant bomb."));
        return 1;
    }
   
    if(strcmp(cmd, "/triggerbomb", true) == 0 || strcmp(cmd, "/tb", true) == 0)
    {
        CreateExplosion(pX, pY, pZ, 12, 10.0);
        return 1;
    }
Reply
#8

Sorry but I can't make it work, can I get some more help?
Reply
#9

I've never done this before, but maybe this should help.
https://sampwiki.blast.hk/wiki/AttachObjectToVehicle

Try attaching and then getting the object's position.
NOTE: The object must be created then attached.
Reply
#10

Well I wanted to do that but which is best attach object to vehicle editor?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)