Car bomb
#1

So i made this suicide bomber system, works like a charm.But then when i used the same structure to make a car bombb it didnt turn out so good:
pawn Код:
public CarBomb(playerid, vehicleid)
{
         new Float: Pos[3];
         new pname[246];
         GetPlayerName(playerid, pname, sizeof(pname));
         GetVehiclePos(vehicleid, Pos[0], Pos[1], Pos[2]);
         CreateLoopingExplosion(Pos[0], Pos[1], Pos[2], 6, 60.0, 5);
         SendClientMessageToAll(COLOR_RED, "lol");
         return 1;
}
That is my Car Bomb timer and this is the cmd (also works for the onfoot):
pawn Код:
if (strcmp("/explode", cmdtext, true, 10) == 0)
    {
         if(IsPlayerInAnyVehicle(playerid))
            {
                 new pname[245];
                 SetTimer("CarBomb", 5000, false);
                 format(pname, sizeof(pname),"%s Detonated a Car bomb!", pname);
                 SendClientMessageToAll(COLOR_RED, pname);
                 return 1;
            }
            else
            {
                 new Float: Pos[3];
                 new pname[246];
                 GetPlayerName(playerid, pname, sizeof(pname));
                 GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
                 CreateLoopingExplosion(Pos[0], Pos[1], Pos[2], 6, 60.0, 5);
                 format(pname, sizeof(pname),"%s Exploded himself (Suicide Bomber)", pname);
                 SendClientMessageToAll(COLOR_RED, pname);
            }
         return 1;
    }
Help pl0x
Reply
#2

pawn Код:
if (strcmp("/explode", cmdtext, true, 10) == 0)
    {
         if(IsPlayerInAnyVehicle(playerid))
            {
                 new pname[25], vehid = GetPlayerVehicleID(playerid);
                 SetTimerEx("CarBomb", 5000, false, "ii", playerid, vehid);
                 format(pname, 25,"%s Detonated a Car bomb!", pname);
                 SendClientMessageToAll(COLOR_RED, pname);
                 return 1;
            }
            else
            {
                 new Float: Pos[3];
                 new pname[25];
                 GetPlayerName(playerid, pname, sizeof(pname));
                 GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
                 CreateLoopingExplosion(Pos[0], Pos[1], Pos[2], 6, 60.0, 5);
                 format(pname, 25,"%s Exploded himself (Suicide Bomber)", pname);
                 SendClientMessageToAll(COLOR_RED, pname);
            }
         return 1;
    }
You lol'ed at you pname string size, you should read ****** post about strings..

And for the explosion, you have to use SetTimerEx like I did there.
Reply
#3

Aww thanks dude, your a life saver.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)