SA-MP Forums Archive
[Tutorial] Set weather command with GTA clock [without bug] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Set weather command with GTA clock [without bug] (/showthread.php?tid=191061)



Set weather command with GTA clock [without bug] - blackwave - 17.11.2010

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
__________________________________________________ _______________________________________________


Re: Set weather command with GTA clock [without bug] - Lorenc_ - 18.11.2010

Nice tutorial, great job.


Re: Set weather command with GTA clock [without bug] - blackwave - 18.11.2010

Quote:
Originally Posted by Lorenc_
View Post
Nice tutorial, great job.
Thank y


Re: Set weather command with GTA clock [without bug] - randomkid88 - 18.11.2010

To make it faster and more effecient, you could look into zcmd and foreach. Other than that, nice tutorial!


Re: Set weather command with GTA clock [without bug] - Ozz - 18.11.2010

Quote:
Originally Posted by blackwave
View Post
Thank y
I ever helpt only people when i knew.


Re: Set weather command with GTA clock [without bug] - gabitzu4ever - 18.11.2010

nice


Re: Set weather command with GTA clock [without bug] - wups - 01.12.2010

pawn 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);
  for(new i = 0; i < MAX_PLAYERS; i++) TogglePlayerClock(i, false);
  SetAllWeather(time);
  for(new i = 0; i < MAX_PLAYERS; i++) TogglePlayerClock(i, true);
  return 1;
}
Then no need for clockon/clockoff.


Re: Set weather command with GTA clock [without bug] - Gh0sT_ - 01.12.2010

for(new i = 0; i < MAX_PLAYERS; i++) TogglePlayerClock(i, false);
SetAllWeather(time);
for(new i = 0; i < MAX_PLAYERS; i++) TogglePlayerClock(i, true);
>
SetWeather(time);


Re: Set weather command with GTA clock [without bug] - Macluawn - 30.12.2010

Not really a good tutorial. it's no good for advanced scripters, 'cuz they know that. And its no good for beginners, 'cuz they don't know what each line of the code does, so they will be just copy&pasting and wont learn anything.


Re: Set weather command with GTA clock [without bug] - justsomeguy - 02.01.2011

pls help i get these errors
Code:
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\sf90s.pwn(103) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\sf90s.pwn(642) : warning 202: number of arguments does not match definition
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\sf90s.pwn(813) : warning 235: public function lacks forward declaration (symbol "MoneyTimer")
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\sf90s.pwn(835) : warning 219: local variable "true" shadows a variable at a preceding level
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\sf90s.pwn(835) : warning 203: symbol is never used: "true"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\sf90s.pwn(835 -- 839) : warning 219: local variable "false" shadows a variable at a preceding level
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\sf90s.pwn(839) : warning 203: symbol is never used: "false"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\sf90s.pwn(849) : error 017: undefined symbol "tempo"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.



Re: Set weather command with GTA clock [without bug] - Antonio [G-RP] - 15.01.2011

Quote:
Originally Posted by justsomeguy
View Post
pls help i get these errors
Code:
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\sf90s.pwn(103) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\sf90s.pwn(642) : warning 202: number of arguments does not match definition
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\sf90s.pwn(813) : warning 235: public function lacks forward declaration (symbol "MoneyTimer")
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\sf90s.pwn(835) : warning 219: local variable "true" shadows a variable at a preceding level
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\sf90s.pwn(835) : warning 203: symbol is never used: "true"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\sf90s.pwn(835 -- 839) : warning 219: local variable "false" shadows a variable at a preceding level
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\sf90s.pwn(839) : warning 203: symbol is never used: "false"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\sf90s.pwn(849) : error 017: undefined symbol "tempo"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
This basicly proves Maclauwn's point...