City Is Not Changing! -
TuFF12 - 20.02.2016
Hello all i have a problemm today

I have a City System that every week the city change!
But this is not working properly the city dont change!
This is my Clock system where the city should change!
Pleaase i need help
PHP код:
forward GameModeClock();
public GameModeClock()
{
new string[256],string2[128];
GameMinute ++;
if (GameMinute == 60)
{
GameMinute = 0;
GameHour ++;
SetWorldTime(GameHour);
GameWeather ++;
if (GameWeather == 3)
{
new weatherid = random(MAX_WEATHER);
SetWeather(RandomWeather[weatherid][0]);
GameWeather = 0;
}
}
if (GameHour == 24)
{
GameMinute = 0;
GameHour = 0;
GameDay ++;
}
format(string, sizeof(string), "%s",WeekDays[GameDay]);
TextDrawSetString(DaysOfWeek, string);
if (GameHour < 10)
format(string, sizeof(string), "0%d",GameHour);
else
format(string, sizeof(string), "%d",GameHour);
if (GameMinute < 10)
format(string, sizeof(string), "%s:0%d",string,GameMinute);
else
format(string, sizeof(string), "%s:%d",string,GameMinute);
TextDrawSetString(Clock, string);
if (GameHour < 10)
format(string, sizeof(string), "%s, 0%d",WeekDays[GameDay],GameHour);
else
format(string, sizeof(string), "%s, %d",WeekDays[GameDay],GameHour);
if (GameMinute < 10)
format(string, sizeof(string), "%s:0%d",string,GameMinute);
else
format(string, sizeof(string), "%s:%d",string,GameMinute);
if (GameMinute == 0)
{
format(string, sizeof(string), "%s",string);
//printf(string);
format(string2, sizeof(string2), "worldtime %s",string);
SendRconCommand(string2);
format(string, sizeof(string), "{FFFFFF}Game Time: {BDBDBD}%s",string);
SendClientMessageToAll(COLOR_SERVER_MAIN_MSG, string);
}
if(GameDay == 6 && GameHour == 23 && GameMinute == 0)
{
switch(CurentCity)
{
case LasVenturas:
{
GameTextForAll("~w~GameWeek Is Almost ~r~Over~n~Be Ready For The Next City",5000,3);
CurentCity = LosSantos;
return 1;
}
case LosSantos:
{
GameTextForAll("~w~GameWeek Is Almost ~r~Over~n~Be Ready For The Next City",5000,3);
CurentCity = SanFierro;
return 1;
}
case SanFierro:
{
GameTextForAll("~w~GameWeek Is Almost ~r~Over~n~Be Ready For The Next City",5000,3);
CurentCity = LasVenturas;
return 1;
}
}
}
if(GameDay == 6 && GameHour == 23 && GameMinute == 59)
{
switch(CurentCity)
{
case LasVenturas:
{
SendRconCommand("gmx");
GameTextForAll("~w~Server Is Changing ~b~City~n~~w~Please Wait ...",5000,3);
return 1;
}
case LosSantos:
{
SendRconCommand("gmx");
GameTextForAll("~w~Server Is Changing ~b~City~n~~w~Please Wait ...",5000,3);
return 1;
}
case SanFierro:
{
SendRconCommand("gmx");
GameTextForAll("~w~Server Is Changing ~b~City~n~~w~Please Wait ...",5000,3);
return 1;
}
}
}
return 1;
}
Re: City Is Not Changing! -
TuFF12 - 22.02.2016
BUMP Please if anyone know how to fix it please HELP!
Re: City Is Not Changing! -
Nero_3D - 22.02.2016
Well all I see is that you set the variable CurrentCity to a new location but than you restart your gamemode which resets all variables, so CurrentCity is back to the default value
Guess you have to avoid restarting the gamemode or save the CurrentCity variable into a file and load it again after restart
Re: City Is Not Changing! -
[eLg]elite - 22.02.2016
Is it sending the game text before the week ends?
Re: City Is Not Changing! -
TuFF12 - 22.02.2016
@JacobTr Yes.
@Nero_3D
i'v tried this still not work !
But how to save the VARIATE?
PHP код:
if(GameDay == 6 && GameHour == 23 && GameMinute == 59)
{
switch(CurentCity)
{
case LasVenturas:
{
SendRconCommand("gmx");
GameTextForAll("~w~Server Is Changing ~b~City~n~~w~Please Wait ...",5000,3);
CurentCity = LosSantos;
return 1;
}
case LosSantos:
{
SendRconCommand("gmx");
GameTextForAll("~w~Server Is Changing ~b~City~n~~w~Please Wait ...",5000,3);
CurentCity = SanFierro;
return 1;
}
case SanFierro:
{
SendRconCommand("gmx");
GameTextForAll("~w~Server Is Changing ~b~City~n~~w~Please Wait ...",5000,3);
CurentCity = LasVenturas;
return 1;
}
}
}
Re: City Is Not Changing! -
[eLg]elite - 22.02.2016
Try switching it to else if instead of if.
Re: City Is Not Changing! -
TuFF12 - 22.02.2016
still the same
Re: City Is Not Changing! -
[eLg]elite - 22.02.2016
Check out this include, learn what it does and learn how to use it. I would suggest YSI, however the compile times are annoying.
Re: City Is Not Changing! -
Sascha - 22.02.2016
Quote:
Originally Posted by TuFF12
still the same 
|
nonononononoooooo.....
As said before, you restart your gamemode.
It does not matter if you first restart the gamemode and then change the variable, or if you use else if or if or else or nothing at all....
A restart of your gamemode will set all variables back to default! It is a "complete reset" for what is written in your gamemode, so changing a variable and then restarting the gamemode is basicly like not changing the variable...
If you are not familar with databases, you should start getting familar...
A simple way to do what you want is to use the default file functions
fopen
https://sampwiki.blast.hk/wiki/Fopen
fclose
https://sampwiki.blast.hk/wiki/Fclose
fwrite
https://sampwiki.blast.hk/wiki/Fwrite
fread
https://sampwiki.blast.hk/wiki/Fread
So instead updating the variable you'll save the new city in a file...
Код:
new File:store = fopen("nextcity.txt", io_write);
fwrite(store, "LasVenturas"); //For example... if changing it to another city, change the city name
fclose(store);
And then at "OnGameModeInit"
you use this to check what is written:
Код:
new File:store = fopen("nextcity.txt", io_read);
new string[100];
fread(store, string);
fclose(store);
if(!strcmp(string, "LasVenturas", true))
{
//set to LV
}
else if(!strcmp(string, "SanFierro", true))
{
//set to SF
}
else if(!strcmp(string, "LosSantos", true))
{
//set to LS
}
else if.....
Re: City Is Not Changing! -
TuFF12 - 24.02.2016
Hello @sascha thank you for replying!
But i used you way and i got this :
On Game Mode Init
PHP код:
new File:store = fopen("nextcity.txt", io_read);
new string2[100];
fread(store, string2);
fclose(store);
if(!strcmp(string2, "LasVenturas", true))
{
CurentCity = LasVenturas;
}
else if(!strcmp(string2, "SanFierro", true))
{
CurentCity = SanFierro;
}
else if(!strcmp(string2, "LosSantos", true))
{
CurentCity = LosSantos;
}
and on city change :
PHP код:
if(GameDay == 6 && GameHour == 23 && GameMinute == 59)
{
if(CurentCity == LasVenturas)
{
SendRconCommand("gmx");
GameTextForAll("~w~Server Is Changing ~b~City~n~~w~Please Wait ...",5000,3);
new File:store = fopen("nextcity.txt", io_write);
fwrite(store, "LosSantos");
fclose(store);
return 1;
}
if(CurentCity == LosSantos)
{
SendRconCommand("gmx");
GameTextForAll("~w~Server Is Changing ~b~City~n~~w~Please Wait ...",5000,3);
new File:store = fopen("nextcity.txt", io_write);
fwrite(store, "SanFierro");
fclose(store);
return 1;
}
if(CurentCity == SanFierro)
{
SendRconCommand("gmx");
GameTextForAll("~w~Server Is Changing ~b~City~n~~w~Please Wait ...",5000,3);
new File:store = fopen("nextcity.txt", io_write);
fwrite(store, "LasVenturas"); //For example... if changing it to another city, change the city name
fclose(store);
return 1;
}
}
it complites i dont get errors but when i start the gamemode server shutdown when i delete my code it does not shutdown why is this haping??