City Is Not Changing!
#1

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(stringsizeof(string), "%s",WeekDays[GameDay]);
    
TextDrawSetString(DaysOfWeekstring);
    if (
GameHour 10)
    
format(stringsizeof(string), "0%d",GameHour);
    else
    
format(stringsizeof(string), "%d",GameHour);
    if (
GameMinute 10)
    
format(stringsizeof(string), "%s:0%d",string,GameMinute);
    else
    
format(stringsizeof(string), "%s:%d",string,GameMinute);
    
TextDrawSetString(Clockstring);
    if (
GameHour 10)
    
format(stringsizeof(string), "%s, 0%d",WeekDays[GameDay],GameHour);
    else
    
format(stringsizeof(string), "%s, %d",WeekDays[GameDay],GameHour);
    if (
GameMinute 10)
    
format(stringsizeof(string), "%s:0%d",string,GameMinute);
    else
    
format(stringsizeof(string), "%s:%d",string,GameMinute);
    if (
GameMinute == 0)
    {
    
format(stringsizeof(string), "%s",string);
    
//printf(string);
    
format(string2sizeof(string2), "worldtime %s",string);
    
SendRconCommand(string2);
    
format(stringsizeof(string), "{FFFFFF}Game Time: {BDBDBD}%s",string);
    
SendClientMessageToAll(COLOR_SERVER_MAIN_MSGstring);
    }
    
    if(
GameDay == && 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 == && 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;

Reply
#2

BUMP Please if anyone know how to fix it please HELP!
Reply
#3

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
Reply
#4

Is it sending the game text before the week ends?
Reply
#5

@JacobTr Yes.

@Nero_3D

i'v tried this still not work !

But how to save the VARIATE?

PHP код:
    if(GameDay == && 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;
        }
    }
    } 
Reply
#6

Try switching it to else if instead of if.
Reply
#7

still the same
Reply
#8

Check out this include, learn what it does and learn how to use it. I would suggest YSI, however the compile times are annoying.
Reply
#9

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

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(storestring2);
    
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 == && 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??
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)