Random weather
#1

Well.. I got this idea about weather changing every hour and I tried to realize it... The code compiles correctly, but it doesn't give me wanted results. Here is what I get ._. :

Код:
#include <a_samp> // I use more includes, but only this one is need now ._.
public OnGameModeInit()
{
	SetTimer("weather", 10000, 1);	// I did say hour, but I put 10s for testing
	return 1;
}
public weather(playerid, weatherid)
{
	new wstr[40];
	if(weatherid < 0 || weatherid > 45) return weather(playerid, weatherid);
	format(wstr, sizeof(wstr), "The weather has been changed to %i!", weatherid);
	SendClientMessageToAll(0xAA0000AA, wstr);
	SetPlayerWeather(playerid, weatherid);
	return 1;
}
Reply
#2

You are totally wrong

SetTimer("name on timer",time in miliseconds,repeat);

1h dont have 10 000 miliseconds

on publick you just check if weather is more the 0 or then 45
Reply
#3

instead you can use:

pawn Код:
//top of script/GM
forward RandomWeatherSystem();
new RandomWeather[][1]= {0,1,2,3,4,5,6,7,8,10,18,20,15}; //just add all the weather Id's you want in here, they all will be randomly chosen

//onfilterscript/gammode init:
public OnGameModeInit()
{
    RandomWeatherSystem();
    SetTimer("RandomWeatherSystem",60*60*1000,1); // set to one hour
}

//then add this at the very end of script:
public RandomWeatherSystem()
{
    new rnd = random(sizeof(RandomWeather));
    SetWeather(RandomWeather[rnd][0]);
    return 1;
}
then it should work. Good luck! +rep if i helped you :P
Reply
#4

The easiest way for you:
pawn Код:
#include <a_samp>

public OnGameModeInit()
{

    SetTimer("weather",360000,true);
    return 1;
}

forward weather(playerid);
public weather(playerid)
{
    switch( random( 2 ) )
    {
        case 0: SetPlayerWeather(playerid,08);
        case 1: SetPlayerWeather(playerid,09);
    }
}
Add more weather's if you want.This is a sample.
Reply
#5

Or...

pawn Код:
public OnGameModeInit() //Or OnFilterScriptInit for filterscripts
{
    SetTimer("WeatherChange", 3600000, true);
    return 1;
}

forward WeatherChange();
public WeatherChange()
{
    new rand = random(45);
    SetWeather(rand);
    return 1;
}
Simple.
Reply
#6

Quote:
Originally Posted by doreto
Посмотреть сообщение
You are totally wrong

SetTimer("name on timer",time in miliseconds,repeat);

1h dont have 10 000 miliseconds
y u no read! " // I did say hour, but I put 10s for testing "

Thanks guys, I'll use your solutions. I knew I forgot something...
Reply
#7

I don't know if it is allowed, but sorry for double post ._.
Anyway, decided to expand my "rand weather code" with a possibility for a player to disable it..
I got these:
Код:
C:\Users\Zeid\Desktop\SAMPSERVER\gamemodes\ZGM.pwn(337) : warning 213: tag mismatch
C:\Users\Zeid\Desktop\SAMPSERVER\gamemodes\ZGM.pwn(353) : warning 213: tag mismatch
C:\Users\Zeid\Desktop\SAMPSERVER\gamemodes\ZGM.pwn(353) : warning 213: tag mismatch
C:\Users\Zeid\Desktop\SAMPSERVER\gamemodes\ZGM.pwn(354) : warning 213: tag mismatch
C:\Users\Zeid\Desktop\SAMPSERVER\gamemodes\ZGM.pwn(354) : warning 213: tag mismatch
And here is the code itself
Код:
#include <zs> //this contains includes I use, like a_samp, zcmd or sscanf2...

forward weather(playerid);

new bool:wthr[MAX_PLAYERS]; //new Boolean value

public OnGameModeInit()
{
	SetTimer("weather", 60*60*1000, 1); //one hour timer
	return 1;
}
public weather(playerid)
{
	if(wthr[playerid] == 0) return 0;
	new wstr[40];
	new rand = random(45);
	format(wstr, sizeof(wstr), "The weather has been changed to %i!", rand);
	SendClientMessageToAll(0xAA0000AA, wstr);
	SetPlayerWeather(playerid, rand);
	return 1;
}
CMD:srw(playerid)
{
	if(wthr[playerid] == 1) return wthr[playerid] == 0;
	if(wthr[playerid] == 0) return wthr[playerid] == 1;
	return 1;
}
Any ideas?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)