[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
#2

Nice tutorial, great job.
Reply
#3

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

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

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

nice
Reply
#7

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.
Reply
#8

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);
Reply
#9

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.
Reply
#10

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.
Reply
#11

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...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)