Posts: 211
Threads: 51
Joined: Dec 2008
Reputation:
0
Hi,
i have got a problem. I will explain and I hope you can help me. Ok, i want to make my own Weather Change. How can I define mind. Random and max random?
like this?:
new weatherChange = random(<12 && >4);
or how? pls explain me.
Posts: 1,293
Threads: 6
Joined: Jul 2008
Reputation:
0
#define MAX 50
#define MIN 10
random(MAX-MIN) + MIN
For greater efficiency you might want to add:
#define RANDOMNUMBERTHING MAX-MIN so your computer doesn't constantly have to do MAX - MIN, but this is trivial..
Posts: 211
Threads: 51
Joined: Dec 2008
Reputation:
0
I hvae it like this.
if(hour == 9 || hour == 10 || hour == 11)
{
new wea2 = random(MAX_WEA2-MIN_WEA2) + MIN_WEA2;
SetWeather(wea2);
}
Posts: 211
Threads: 51
Joined: Dec 2008
Reputation:
0
Sorry for Doublepost. How can i do like this.
I want the change of 3 ids they are 12 & 17 & 3. How can i do this?
Posts: 1,293
Threads: 6
Joined: Jul 2008
Reputation:
0
Put them in an array:
new WeatherIDs[3] = { 3, 12, 17 };
Then use something like:
WeatherIDs[random(sizeof(WeatherIDs))];
Posts: 211
Threads: 51
Joined: Dec 2008
Reputation:
0
Erros:
K:\The Godfather - Neu\gamemode\gf.pwn(31445) : error 012: invalid function call, not a valid address
K:\The Godfather - Neu\gamemode\gf.pwn(31445) : error 001: expected token: ",", but found "sizeof"
K:\The Godfather - Neu\gamemode\gf.pwn(31445) : warning 215: expression has no effect
K:\The Godfather - Neu\gamemode\gf.pwn(31445) : error 001: expected token: ";", but found ")"
K:\The Godfather - Neu\gamemode\gf.pwn(31445) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
if(hour == 6)
{
new WeatherIDs[3] = { 3, 12, 17 };
new irandom = random(sizeof(WeatherIDs));
SetWeather(irandom(sizeof(WeatherIDs)));//31445
}
Posts: 1,293
Threads: 6
Joined: Jul 2008
Reputation:
0
Unless you hadn't already guessed the line I gave you was quite a few functions rolled into one!
Explanation:
SetWeather(WeatherIDs[random(sizeof(WeatherIDs))]);
WeatherIDs is an array, so sizeof(WeatherIDs) returns how many spaces it has (3)
random(3) gives you a random number, either 0, 1, or 2.
WeatherIDs[1] is the second cell in the array, which in this case is 12.
The only downside is that you may get the same WeatherID twice in a row.