[Tutorial] How to make Random Explosions
#1

Random Explosions
Welcome to my tutorial for Random Explosions, this tutorial is mainly recommended for Roleplay servers, because it gives the Fire Department something to do, instead of waiting for a dispatch call.

ANYWAYS

Step 1
We have to add some stuff before we make the actual explosions itself.

So, under your #define's you might or might not run across some lines with the label "forward" under that you want to add this under it
pawn Code:
forward OnBurgerExplosion(playerid); // You can name this whatever you feel.
One you have this, then we can go start the timers

Step 2
We have to add a timer, a timer is pretty self explanatory. It's when a timer goes off, so let's say our fire started in 1 hour this is how long it is, in Millseconds (You can use your own time) 1 hour = 3,600,000 I believe. In miliseconds

You want to add this under OnGameModeInit, NOT OnPlayerConnect! Else everytime a player connects, the timer will start and this could just cause a cluster of Explosions.
pawn Code:
SetTimer("OnBurgerExplosion", 3600000, true);
Step 3
Now that we have settled our Timer in the script, on the bottom of the script, we have to make our "forward" come into action like this

pawn Code:
public OnBurgerExplosion(playerid)
{
       // define stuff here
       return 1;
}
Now, this last piece of code is interesting, but I will break it down for you

pawn Code:
static explode2; // Defining the explode
    if(explode2 == 0) { // If explode2 is just going to start, get prepared and alert!
        // Add your Dispatch message here!
    }
    explode2++; // Every explosion, this will go up
    if(explode2 < 100) // 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(x,y,z, 2, 50.0); // explosions
    CreateExplosion(x,y,z, 2, 50.0); // explosions
Step 4
With your new piece of code, that I attempted to define well, but probably failed.. Anyways with your code, fill the information out like your Dispatch message, and put coordinates in there. Once you do that, put it into place

pawn Code:
public OnBurgerExplosion(playerid)
{
    static explode2; // Defining the explode
    if(explode2 == 0) { // If explode2 is just going to start, get prepared and alert!
        // Add your Dispatch message here!
    }
    explode2++; // Every explosion, this will go up
    if(explode2 < 100) // 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(x,y,z, 2, 50.0); // explosions
    CreateExplosion(x,y,z, 2, 50.0); // explosions
    // X, Y, Z == X = X Coordinates, Y = Y Coordinates, Z = Z Coordinates
    return 1;
}
Then your done!
NOTE: This is a crappy tutorial, I know. I am bad at defining what certain variables/functions are. I wasn't learned by telling the names of these things, I was self taught. And I don't even know what there called still, I have my own ways of naming stuff. Sorry if it doesn't make sense to you.

If you think you can improve this tutorial, then please improve it a little better, especially my coding.
Reply
#2

bump
Reply
#3

That looks good
I will test later
Reply
#4

Aight!
Reply
#5

Okay i will rate it by 3/10

Reason Dude look at the Code it's messed up and you didn't even define the x y z it will give any one an error undefined with x y z so you either copied it out of your gamemode without the defines or you took it from an old tutorial ?!.
Reply
#6

Quote:
Originally Posted by VBullet
View Post
Okay i will rate it by 3/10

Reason Dude look at the Code it's messed up and you didn't even define the x y z it will give any one an error undefined with x y z so you either copied it out of your gamemode without the defines or you took it from an old tutorial ?!.
Did I really have to explain X,Y,Z?
Reply
#7

Quote:
Originally Posted by KiNG3
View Post
Did I really have to explain X,Y,Z?
Probably should have defined it though..

pawn Code:
new Float: x, Float: y, Float: z;
Reply
#8

You didn't have to define it, i just added on that X is your X Coordinates, and etc.
Reply
#9

then you should tell that..newb's can easily get confused
Reply
#10

Good Tutorial
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)