How to make Random weather. -
Tee - 05.02.2011
Hello SA-MP members. I had this in my GM for a long time, so i thought i should not be the only one to know how to do it.
So i decided to share it with you all. I think it would be great for RP servers like mine.
Here goes, we need to make a new variable.
Then we need to make a function and forward it.
pawn Код:
forward RandomWeather();
public RandomWeather()
{
}
That by itself will do nothing so here is where the advance part comes in.
We need a Timer to set when to change the weather. Put the timer under, "OnGamModeInit();"
pawn Код:
SetTimer("RandomWeather",60000,true);//This sets the timer that will be repeated for 1 minute (1000 ms = 1 second) hence 1000 x 60 = 60000 (1 minute)
Now we will soon be finished but we need to add the rest of what the function will do.
pawn Код:
public RandomWeather()
{
Weather = random(20);//The variable that we created will hold the random weather.
SetWeather(Weather);//This will set the weather to a random number which is held in the variable "Weather"
}
I suggest you look here:
Click Me, for the ids of the weather so you can know what you want.
We are finished. Thanks for reading and Learning.
Re: How to make Random weather. -
Ockad - 05.02.2011
Hey thanks!
Really helpful and useful.
Just one minor question: Where do I put the 'public GlobalWeather()' ?
Re: How to make Random weather. - [03]Garsino - 05.02.2011
Did you even try to compile your script?
pawn Код:
forward RandomWeather();
public GlobalWeather()
You forward a public named "RandomWeather" but the public itself is named "GlobalWeather".
Also, there is no need for a global variable.
pawn Код:
public GlobalWeather()
{
return SetWeather(random(20)); //This will set the weather to a random number which is held in the variable "Weather"
}
Re: How to make Random weather. -
Antonio [G-RP] - 05.02.2011
Quote:
forward RandomWeather();
public GlobalWeather()
{
}
|
Why the fuck are you messing up the headers?
EDIT: Too late
Re: How to make Random weather. -
Ockad - 05.02.2011
So if I am right, I only need to use
Quote:
public GlobalWeather()
{
return SetWeather(random(20)); //This will set the weather to a random number which is held in the variable "Weather"
}
|
and i'm done?
Re: How to make Random weather. - [03]Garsino - 05.02.2011
pawn Код:
SetTimer("RandomWeather",60000,true); // In OnGameModeInit
forward RandomWeather(); // Outside any other callback
public RandomWeather() // Outside any other callback
{
return SetWeather(random(20));
}
Yes
Re: How to make Random weather. -
Ockad - 05.02.2011
That is brilliant man. Thank you!
Re: How to make Random weather. -
Tee - 05.02.2011
Garison sorry it is fixed. And Thanks to you all.
This is even easier.
Quote:
Originally Posted by [03]Garsino
pawn Код:
SetTimer("RandomWeather",60000,true); // In OnGameModeInit forward RandomWeather(); // Outside any other callback public RandomWeather() // Outside any other callback { return SetWeather(random(20)); }
Yes
|
Re: How to make Random weather. -
HeLiOn_PrImE - 19.06.2012
How can I make the weather be set between a number of values given by me? for example I want only 3 weather ID's. 20 15 and 7.
Re: How to make Random weather. -
Jonny5 - 21.06.2012
Quote:
Originally Posted by HeLiOn_PrImE
How can I make the weather be set between a number of values given by me? for example I want only 3 weather ID's. 20 15 and 7.
|
im not sure who made this simple stock but i know it was not me
pawn Код:
stock RandomNumber(...)
return getarg(random(numarg()));
//use it like
SetTimer("RandomWeather",60000,true); // In OnGameModeInit
forward RandomWeather(); // Outside any other callback
public RandomWeather() // Outside any other callback
{
return SetWeather(RandomNumber(20,15,7));
}