[Tutorial] Set weather command with GTA clock [without bug]
#1

Setting the weather withTogglePlayerClock ON

Well, it's not really usefull, but I wanted just to show you how to set gta's game weather with the "TogglePlayerClock", because when you tries to set weather with this clock, nothing happens.
First: put on your gamemode or filterscript's top:
Code:
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
On "OnPlayerConnect", put:

Code:
TogglePlayerClock(playerid, true);
On "OnPlayerCommandText":
Code:
dcmd(setallweather,13,cmdtext);
Now, I recommend to do a stock, which's faster for Set everyone else's weather, and avoid bugs ( I tested).
Put it on gamemode or filterscript's end:
Code:
stock SetAllWeather(weather)
{
   for(new i = 0; i < MAX_PLAYERS; i++) SetPlayerWeather(i, weather);
}
Also put these stocks underneath, below this one above:
Code:
stock clockon(true)
{
  for(new i = 0; i < MAX_PLAYERS; i++) TogglePlayerClock(i, true);
}
stock clockoff(false)
{
   for(new i = 0; i < MAX_PLAYERS; i++) TogglePlayerClock(i, false);
}
Now, after the last callback, or even after this stock above, put the code:
Code:
dcmd_setallweather(playerid, params[])
{
  
  new time,string[128],name[30]; GetPlayerName(playerid, name, 30);
  time = strval(params);
  if(!strlen(params)) return SendClientMessage(playerid, 0x33CCFFAA, "USAGE: /setallweather <ID>");
  if(tempo > 2009) return SendClientMessage(playerid, 0x33CCFFAA, "Choose an weather lower than 2010");
  format(string,sizeof(string),"ADMIN: %s set everyone weather's for %d", name, time);
  SendClientMessageToAll(0x33CCFFAA, string);
  clockoff(false);
  SetAllWeather(time);
  clockon(true);
  return 1;
}
NOTE: that's just something I thought, and not really usefull, but Im posting, always
__________________________________________________ _______________________________________________
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 4 Guest(s)