CreateExplosion help!
#1

Hello! I want to create Explossion for Medics Factions. I create a Timer who make Explossion every 5 minutes[for testing], but my problem is cause, thats explossion happends all together in all places i have put coordinates.
How to make explosion to start at a time, not all togheter.
Sorry for my english.
Код:
forward OnBurgerExplosion();
public OnBurgerExplosion(playerid)
{
    static explode2; // Defining the explode
    if(explode2 == 0) { // If explode2 is just going to start, get prepared and alert!
    if(IsPlayerConnected(playerid))
         {
                if(PlayerInfo[playerid][pMember] == 14 || PlayerInfo[playerid][pLeader] == 14)
                {
                      new string[300];
                      new turnmes[128];
                      format(cbjstore, sizeof(turnmes), "HQ: All Units APB, Reporter: {FFFFFF} Un Incediu a fost depistat! Mergeti pentru a-l stinge.",PlayerInfo[playerid],playerid);
		              SendClientMessage(playerid, COLOR_DBLUE, cbjstore);
                      
                }
          }    // Add your Dispatch message here!
    }
    explode2++; // Every explosion, this will go up
    if(explode2 < 6) // once it explodes 100 times, it will disable itself
        SetTimer("OnBurgerExplosion", 3000, false); // This makes it disable itself
    else
        explode2 = 0; // If this is 0, it will start exploding, because fo the timer
    CreateExplosion(2438.04688, -1271.21838, 23.22764,2,100);
    SetPlayerCheckpoint(playerid,2438.04688, -1271.21838, 23.22764,1.0);
  	//CreateExplosion(432.4224, -1297.9946, 25.0137,1,100);
  	//CreateExplosion(2427.9363, -1288.8926, 30.2144,1,100);
    // X, Y, Z == X = X Coordinates, Y = Y Coordinates, Z = Z Coordinates
    return 1;
    }
Reply
#2

So you mean that it explodes, and keeps exploding non-stop?
Reply
#3

No, it explodes at 5 minutes , but when explodes happend it explodes at all coordinates i set. But i want to explode one, before 5 minutes another explode in anothet location if you understand...
Reply
#4

By your code it says it'll only explode here

Код:
CreateExplosion(2438.04688, -1271.21838, 23.22764,2,100);
If it's exploding elsewhere, then maybe you have another set of code doing it.


Search for CreateExplosion in your script to see if you have anything else that will be doing this.
Reply
#5

After reading that, I thought that would be the case for you so I have created a code you can use which was based off the codes I saw in your main thread, it will randomly select one explosion, then use that, then after around five minutes (if you set the timer on it) will change to a differnt explosion and will carry on doing this until it reaches the 100 mark then will cut it's timer off, I have also added in some codes which will help you more with your development, they're simple to understand and easier to do than making a mess of your systems:

pawn Код:
new ExplosionCount; // This will keep count of how many explosions have occured
new ExplosionTimer; // This will be used to kill the timer after the count has reached its limit

ExplosionTimer = SetTimer("BurgerShotExplosion", 1000, true); // This starts the timer, place this whereever you want


forward BurgerShotExplosion();
public BurgerShotExplosion()
{
    if(ExplosionCount == 0) // If the Timer is set on 0, this is where it will start! I also suggest adding a smoking object on the building!
    {
        if(IsPlayerConnected(playerid)) // This will check if the player is connected
        {
            new string[300];
            format(string, sizeof(string), "HQ: All Units APB, Reporter: {FFFFFF} Un Incediu a fost depistat! Mergeti pentru a-l stinge.");
            SendMedicMessage(COLOR_DBLUE, string); // This will only send to the medics and not to the player who started the fire!
            SetMedicCheckPoint(2438.04688, -1271.21838, 23.22764,1.0); // This will only set a checkpoint on the medics radar and not the civilians
        }
    }
    else if(ExplosionCount < 100) // This checks to see if the explosions are under 100, if it is, it will carry on!
    {
        switch(random(3)) // This will randomly select one explosion, then change to another explosion.
        {
            case 0:
            {
                CreateExplosion(2438.04688, -1271.21838, 23.22764,2,100);
            }
            case 1:
            {
                CreateExplosion(432.4224, -1297.9946, 25.0137,1,100);
            }
            case 2:
            {
                CreateExplosion(2427.9363, -1288.8926, 30.2144,1,100);
            }
        }
        ExplosionCount++; // Adds 1 explosion count to the variable
    }
    else if(ExplosionCount == 100) // Once the explosion count hits 100, it will stop the timer
    {
        ExplosionCount = 0; // Resets the count for the next time it happens
        KillTimer(ExplosionTimer); // This will kill the timer and end the explosions
        // You can also add a dispatch message saying the fire is out and units can return to base! :D
    }
    return 1;
}

stock SendMedicMessage(colour, string[]) // This will send a mass message to the Medic Faction only!
{
    for(new i = 0; i < MAX_PLAYERS; i++) // This will go through each player ID
    {
        if(PlayerInfo[i][pMember] == 14 || PlayerInfo[i][pLeader] == 14) // This will check if that player ID is in the medic faction
        {
            SendClientMessage(i, colour, string); // This will send the message to the medics in that faction
        }
    }
    return 1;
}

stock SetMedicCheckPoint(Float: x, Float: y, Float: z, Float: size) // This will send a mass checkpoint to the Medic Faction only!
{
    for(new i = 0; i < MAX_PLAYERS; i++) // This will go through each player ID
    {
        if(PlayerInfo[i][pMember] == 14 || PlayerInfo[i][pLeader] == 14) // This will check if that player ID is in the medic faction
        {
            SetPlayerCheckpoint(i, x, y, z, size); // This will set a checkpoint for the medics in that faction
        }
    }
    return 1;
}
Reply
#6

You could make both MedicMessage and MedicCheckpoint into one, and simply use one function to do that.

It's not clarifying the issue though.
Reply
#7

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
You could make both MedicMessage and MedicCheckpoint into one, and simply use one function to do that.

It's not clarifying the issue though.
I added those two things in to make it easier on my eyes and to help me track where everything is, this is an example of how he can lay out the system, where it will send a mass message to the medics only, then create the things needed, as for the explosions, I have mentioned the things into it below the code itself where he can see how to do it in one way.
Reply
#8

Than you so much for the code , but when i replace in my gamemode i have this error message, i didn't know [U]why...
Quote:

error 017: undefined symbol "playerid"

Is line
Код:
if(IsPlayerConnected(playerid))
Reply
#9

PHP код:
forward OnBurgerExplosion(); 
to
PHP код:
forward OnBurgerExplosion(playerid); 
Reply
#10

Quote:
Originally Posted by McGuiness
Посмотреть сообщение
I added those two things in to make it easier on my eyes and to help me track where everything is, this is an example of how he can lay out the system, where it will send a mass message to the medics only, then create the things needed, as for the explosions, I have mentioned the things into it below the code itself where he can see how to do it in one way.
If you amalgamated both of them, then they wouldn't be doing 2 loops, and would easily do the same function, without being 2 functions.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)