Random gamemode change help
#1

Hello, im developing a missions server and i made a small code to change randomly the missions, this is the code:

Код:
new ModeNames[][] =
{
    "GM1",
    "GM2",
    "GM3",
    "GM4"
};

public GMChange()
{
    new modestring[50];
	new randmode = random(sizeof(ModeNames));
	format(modestring,sizeof(modestring),"The Next mode will be %s!",ModeNames[randmode]);
	SendClientMessageToAll(0x32CD32FF,modestring);
	format(modestring,sizeof(modestring),"changemode %s",ModeNames[randmode]);
	SendRconCommand(modestring);
    return 1;
}
And this is how i called it in the mission gamefile:

Код:
CallRemoteFunction("GMChange","");
The message "the next mode will be" shows, but server gets stuck at restart after executing that code...whats wrong?
Reply
#2

After some research I found out that the cause of it is in the OnGameModeExit, this is somehow caused when the code execution doesn't reaches the return 1; of the OnGameModeExit. Just put print("Game Mode EXit return one executing"); something like that just before return 1; of OnGameModeExit and see if that is printed or not.
If not then check for loops in OnGameGodeExit that is what causes it most of times.
Reply
#3

Quote:

----------------------------------
[22:29:48] Hot Room Loaded (TDM).
[22:29:48] ----------------------------------

[22:29:48] Number of vehicle models: 0
[22:31:28] [connection] **** requests connection cookie.
[22:31:29] [connection] incoming connection: ***id: 0
[22:31:30] [join] Face9000 has joined the server (0:1**)
[22:31:30] IsPlayerBanned called.
[22:35:26] Game Mode EXit return one executing

Did what you said, is calling but still server stuck at restart. This is the OnGameModeExit (name of the callback has been edited to fit the map settings):

Код:
public GameModeExitFunc(playerid)
{
    CallRemoteFunction("GMChange","");
   GameTextForAll("~y~Loading next mission ~n~ ~w~Please Wait....",5000,5);
    if(TeamBlueScore > TeamRedScore)
	{
	GameTextForAll("~w~Team ~b~Blue ~w~Won!", 4500, 4);
	}
	else if(TeamRedScore > TeamBlueScore)
	{
	GameTextForAll("~w~Team ~r~Red ~w~Won!", 4500, 4);
	}
	else if(TeamRedScore == TeamBlueScore)
	{
	GameTextForAll("~w~Mission Draw!", 4500, 4);
	}
    KillTimer(CheckScoreTimer);
    KillTimer(GameTimer);
    KillTimer(ScoreTimer);
    TextDrawHideForPlayer(playerid,Timer);
    
   	TextDrawHideForAll(TimeLeftTxd);
	TextDrawDestroy(TimeLeftTxd);
	TextDrawHideForAll(BTSTxd);
	TextDrawDestroy(BTSTxd);
	TextDrawHideForAll(RTSTxd);
	TextDrawDestroy(RTSTxd);
	print("Game Mode EXit return one executing");
	return 1;
}
GameModeExit function is called on OnGameModeInit (in the same script):

Код:
SetTimer("GameModeExitFunc", RoundTime, 0);
Reply
#4

Have you placed OnGameModeExit() in the script anywhere or not? If not then place it and add 'return 1;' to it. Make sure there is return one inside OnGameModeExit() not GameModeExitFunc, inside the GM. And also make sure that 'return 1' in OnGameModeInit in the next GM that has to be loaded is being executed.
Reply
#5

BroZeus i tried everything you said...nothing..
Reply
#6

pawn Код:
new ModeNames[][] =
{
    "GM1",
    "GM2",
    "GM3",
    "GM4"
};

public MapChange(mapid)
{
    new str[50];
    format(str,sizeof(str),"changemode %s",ModeNames[mapid]);
    SendRconCommand(str);
    return 1;
}

public GMChange()
{
    new modestring[50],randmode;
    randmode = random(sizeof(ModeNames));
    format(modestring,sizeof(modestring),"The Next mode will be %s!",ModeNames[randmode]);
    SendClientMessageToAll(0x32CD3200,modestring);
    return SetTimerEx("MapChange",750,false,"d",randmode);
}

public GameModeExitFunc()
{
    GameTextForAll("~y~Loading next mission ~n~ ~w~Please Wait....",5000,5);
    if(TeamBlueScore > TeamRedScore) GameTextForAll("~w~Team ~b~Blue ~w~Won!", 4500, 4);
    else if(TeamRedScore > TeamBlueScore) GameTextForAll("~w~Team ~r~Red ~w~Won!", 4500, 4);
    else GameTextForAll("~w~Mission Draw!", 4500, 4);

    KillTimer(CheckScoreTimer);
    KillTimer(GameTimer);
    KillTimer(ScoreTimer);
    //TextDrawHideForPlayer(playerid,Timer);

    TextDrawHideForAll(TimeLeftTxd);
    TextDrawDestroy(TimeLeftTxd);
    TextDrawHideForAll(BTSTxd);
    TextDrawDestroy(BTSTxd);
    TextDrawHideForAll(RTSTxd);
    TextDrawDestroy(RTSTxd);
    print("Game Mode EXit return one executing");
    return CallRemoteFunction("GMChange","");
}
Reply
#7

Same LOL..
Reply
#8

My GM does the same thing, so my GMX command doesn't work.

Suggestions:

1. If you're using MySQL make sure you close the connection under OnGameModeExit and then reconnect in the next GM under OnGameModeInit.

2. Make sure all your timers are killed in the OnGameModeExit.

3. Try running the compiler with debugging flags.

4. Add crashdetect and check your log afterwards, it might give you a clue.
Reply
#9

1) Done, nothing.

2) Checked and i'm killing all the timers.

3) Done.

4) Doesn't show anything in the server log.
Reply
#10

Ok, after some tests, the 99% of problems im getting with server stuck while restarting is for the system filterscript.

So i made a test, i removed the system filterscript (the one which handles everything, register, login, ac etc..) and replaced with a default samp filterscript which comes in the samp server package. (a51_base)

No server stuck at restart, randomly change was working well.

Then i re-added the system filterscript and server gets stuck, so 99% is the sys fs the problem. This is the server log when using sys fs:

Quote:

[07:32:14] Filterscripts
[07:32:14] ---------------
[07:32:14] Loading filterscript 'sys.amx'...
[07:32:14]
[07:32:14]
[07:32:14]
[07:32:14] =======================================
[07:32:14] | |
[07:32:14] | YSI version 3.09.0684 |
[07:32:14] | By Alex "******" Cole |
[07:32:14] | |
[07:32:14] =======================================
[07:32:14]
[07:32:14] Attempting to connect to MySQL...
[07:32:14] Successfully connected on DB ****
[07:32:14] Connected to database (host: ****, db: ****) as ****
[07:32:14] -> Loaded Successfully!

[07:32:14] Date: 29/9/2015 - Time: 7:32:14
[07:32:14] __________________________________________________ _

[07:32:14] Loaded 1 filterscripts.

[07:32:14]
----------------------------------
[07:32:14] Hot Room Loaded (TDM).
[07:32:14] ----------------------------------

[07:32:14] Number of vehicle models: 0
[07:32:39] [connection] **** requests connection cookie.
[07:32:40] [connection] incoming connection: *** id: 0
[07:32:40] [join] Face9000 has joined the server (0:***)

As you can see, nothing is printed in the server console after gamemode restart.
MySql log is okay, i dont get any problem.

This is OnFilterScriptInit of the sys fs:

Код:
public OnFilterScriptInit()
{
    print("Attempting to connect to MySQL...");

    mysql_log(LOG_ERROR | LOG_WARNING | LOG_DEBUG);
	mConnectionHandle = mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
	if(mysql_errno(mConnectionHandle) != 0)
	{
		 print("Could not connect to database!");
	}
	else
	{
		printf("Successfully connected on DB %s",SQL_DB);
	}

	if(mysql_errno(mConnectionHandle) != 0) print("Could not connect to database!");
	else printf("Connected to database (host: %s, db: %s) as %s", SQL_HOST, SQL_DB, SQL_USER);

     SetTimer("SaveAllStats", 300000, 1);
     SetTimer("AntiCheat", 1000, 1);
     SetTimer("RandomMessages", 60000*RANDMSGMINUTES, 1);

     new year,month,day;
	 getdate(year, month, day);
	 new hour,minute,second;
	 gettime(hour,minute,second);

     print(" -> Loaded Successfully!\n");
	 printf(" Date: %d/%d/%d - Time: %d:%d:%d",day,month,year,hour, minute, second);
	 print(" ___________________________________________________\n");

	botIDs[0] = IRC_Connect(IRC_SERVER, IRC_PORT, BOT_1_MAIN_NICKNAME, BOT_1_REALNAME, BOT_1_USERNAME);
	IRC_SetIntData(botIDs[0], E_IRC_CONNECT_DELAY, 10);
	botIDs[1] = IRC_Connect(IRC_SERVER, IRC_PORT, BOT_2_MAIN_NICKNAME, BOT_2_REALNAME, BOT_2_USERNAME);
	IRC_SetIntData(botIDs[1], E_IRC_CONNECT_DELAY, 15);
	botIDs[1] = IRC_Connect(IRC_SERVER, IRC_PORT, BOT_3_MAIN_NICKNAME, BOT_3_REALNAME, BOT_3_USERNAME);
	IRC_SetIntData(botIDs[2], E_IRC_CONNECT_DELAY, 15);
	groupID = IRC_CreateGroup();

	EnableVehicleFriendlyFire();//Anti team vehicle damaging

	foreach (new i : Player)
    {
	JailTxd[i] = TextDrawCreate(482.000000, 366.000000, "Jail Time:");
	TextDrawBackgroundColor(JailTxd[i], 255);
	TextDrawFont(JailTxd[i], 2);
	TextDrawLetterSize(JailTxd[i], 0.280000, 1.500000);
	TextDrawColor(JailTxd[i], -1);
	TextDrawSetOutline(JailTxd[i], 1);
	TextDrawSetProportional(JailTxd[i], 1);
	TextDrawUseBox(JailTxd[i], 1);
	TextDrawBoxColor(JailTxd[i], -219);
	TextDrawTextSize(JailTxd[i], 635.000000, 0.000000);
    }

    for(new i=0; i<gMax; i++)
    {
        InfoBox[i] = TextDrawCreate(37.000000,127.000000," ");
        TextDrawUseBox(InfoBox[i],1);
        TextDrawBoxColor(InfoBox[i],0x00000033);
        TextDrawTextSize(InfoBox[i],217.000000,59.000000);
        TextDrawAlignment(InfoBox[i],0);
        TextDrawBackgroundColor(InfoBox[i],0x000000ff);
        TextDrawFont(InfoBox[i],2);
        TextDrawLetterSize(InfoBox[i],0.199999,1.200005);
        TextDrawColor(InfoBox[i],0xffffffff);
        TextDrawSetOutline(InfoBox[i],1);
        TextDrawSetProportional(InfoBox[i],1);
        TextDrawSetShadow(InfoBox[i],1);
    }

     //Textdraws
  	LogoTxd0 = TextDrawCreate(517.000000, 419.000000, "Epic Missions v0.1");
	TextDrawBackgroundColor(LogoTxd0, 255);
	TextDrawFont(LogoTxd0, 3);
	TextDrawLetterSize(LogoTxd0, 0.370000, 1.000000);
	TextDrawColor(LogoTxd0, -1);
	TextDrawSetOutline(LogoTxd0, 1);
	TextDrawSetProportional(LogoTxd0, 1);

	LogoTxd1 = TextDrawCreate(531.000000, 434.000000, "Created by Face9000");
	TextDrawBackgroundColor(LogoTxd1, 255);
	TextDrawFont(LogoTxd1, 3);
	TextDrawLetterSize(LogoTxd1, 0.250000, 1.000000);
	TextDrawColor(LogoTxd1, -16776961);
	TextDrawSetOutline(LogoTxd1, 1);
	TextDrawSetProportional(LogoTxd1, 1);

	MissionTxd = TextDrawCreate(3.000000, 428.000000, "Mission:");
	TextDrawBackgroundColor(MissionTxd, 255);
	TextDrawFont(MissionTxd, 3);
	TextDrawLetterSize(MissionTxd, 0.370000, 1.000000);
	TextDrawColor(MissionTxd, -1);
	TextDrawSetOutline(MissionTxd, 1);
	TextDrawSetProportional(MissionTxd, 1);
	TextDrawUseBox(MissionTxd, 1);
	TextDrawBoxColor(MissionTxd, 69);
	TextDrawTextSize(MissionTxd, 637.000000, 20.000000);

	GameTypeTxd = TextDrawCreate(263.000000, 428.000000, "Game Type:");
	TextDrawBackgroundColor(GameTypeTxd, 255);
	TextDrawFont(GameTypeTxd, 3);
	TextDrawLetterSize(GameTypeTxd, 0.370000, 1.000000);
	TextDrawColor(GameTypeTxd, -1);
	TextDrawSetOutline(GameTypeTxd, 1);
	TextDrawSetProportional(GameTypeTxd, 1);

	RandMsgTxd = TextDrawCreate(121.000000, 416.000000, "_");
	TextDrawBackgroundColor(RandMsgTxd, 255);
	TextDrawFont(RandMsgTxd, 2);
	TextDrawLetterSize(RandMsgTxd, 0.170000, 1.000000);
	TextDrawColor(RandMsgTxd, -1);
	TextDrawSetOutline(RandMsgTxd, 1);
	TextDrawSetProportional(RandMsgTxd, 1);
	TextDrawUseBox(RandMsgTxd, 1);
	TextDrawBoxColor(RandMsgTxd, 69);
	TextDrawTextSize(RandMsgTxd, 483.000000, 20.000000);
	//
	return 1;
}
And OnPlayerConnect:

Код:
public OnPlayerConnect(playerid)
{
    ResetPlayerCash(playerid);

    pDrunkLevelLast[playerid] = 0;
    cowit[playerid] = 0;
    pFPS[playerid] = 0;
    killstreak[playerid] = 0;

    //================================================================//
    //                              MySQL part                        //
    //================================================================//

    JustLogged[playerid] = 0;
    IsPlayerBanned(playerid);

	new query[300], pname[24];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "SELECT 'IP' FROM `players` WHERE Username = '%s' LIMIT 1", pname);
	mysql_tquery(mConnectionHandle, query, "OnAccountLoad", "i", playerid);
	printf("%s", query);*/
	
	/*___________________________________________________________________________________________________________________________*/
    
    SetPVarInt(playerid, "spawned", 0);
    for( new i = 0; i <= 50; i ++ ) SCM(playerid,-1, "" );
	SCM(playerid, COLOR_JOINHELPERCHAT, "** Welcome to Epic Missions - Please read /rules and /cmds for server info.");
	SCM(playerid,0xFF8080FF, "** Do /gametypes to know the available game types and their reward in this server.");
    SCM(playerid,0xFF8080FF, "** NOTICE: If you see anyone hacking please report it using /report [id] [reason]");
    SendDeathMessage(INVALID_PLAYER_ID,playerid, 200);
    
    new str[ 100 ];
	gpci( playerid , str , sizeof( str ) );
	if( !strcmp( str , DISALLOWED_ADDRESS ,true ) )
	{
		ShowPlayerDialog(playerid, 64, DIALOG_STYLE_MSGBOX, "Map Stealer", "570P US1NG M4P 5T34L3R M07H3RFUCK3R, FUCK 0FF.", "1M 7H3 R34L FUCK3R5", "");
		BanEx( playerid, "Map Stealer / RakSampClient" );
    }
    
    
    new stats[128];
	format(stats, sizeof(stats), "UPDATE ServerStats SET TotalJoins = TotalJoins + 1");
	mysql_function_query(mysql, stats, false, "", "");
	
	new joinm[128];
	new ipp[16];
	GetPlayerIp(playerid, ipp, sizeof(ipp));
	format(joinm,sizeof(joinm),"* %s (%d) has joined the server. (IP: %s)", Name[playerid],playerid,ipp);
	SendStaffMessage(0xFF0000FF,joinm);
	
	new ip[16];
	GetPlayerIp(playerid, ip, sizeof(ip));
	
    new ModeName[45], GameTypeName[45], mess[128];
	GetSVarString("GM_Name", ModeName, sizeof(ModeName));
	GetSVarString("GameType", GameTypeName, sizeof(GameTypeName));
	format(mess,sizeof(mess),"> You are currently playing: {F2C80C}%s (%s)", ModeName, GameTypeName);
	SCM(playerid, -1, mess);
	
	new ipschan[150];
	new name[24];
	GetPlayerName(playerid, Name[playerid], 24);
	new ipo[16];
	GetPlayerIp(playerid, ipo, sizeof(ipo));
	format(ipschan, sizeof(ipschan), "** %s (%d) IP: %s - %s", name,playerid,ipo,InsertTimeStamp());
	JoinsLog(ipschan);
	IRC_GroupSay(groupID, IRC_IPCHANNEL, ipschan);
    
    FpsPingLabel[playerid] = Create3DTextLabel("_", 0x008080FF, 30.0, 40.0, 50.0, 40.0, 0);
    Attach3DTextLabelToPlayer(FpsPingLabel[playerid], playerid, 0.0, 0.0, 0.75);
    
    /*TextDrawShowForPlayer(playerid, LogoTxd0);
	TextDrawShowForPlayer(playerid, LogoTxd1);*/
	return 1;
}
I tried commenting mysql login/register part but still same result.

I wanna advise that thing server stuck happens even with normal rcon changemode GMNAME.

Any help is really appreciated, thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)