15.11.2012, 22:20
(
Last edited by KiNG3; 23/11/2012 at 05:57 PM.
)
Random Explosions
If you think you can improve this tutorial, then please improve it a little better, especially my coding.
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
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.
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
Now, this last piece of code is interesting, but I will break it down for you
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
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.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.
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);
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;
}
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
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;
}
If you think you can improve this tutorial, then please improve it a little better, especially my coding.