Problem regarding loading a function with SetTimer
#1

Hello all.

I have a strange problem here. So I have a function, say, to load a map. And I use timer to load that function:

Код:
function:LoadMap(mapname[])
{
	new file[100];
	format(file, sizeof(file), MAP_LOCATION, mapname);
	if(!fexist(file)) return printf("FATAL ERROR: Failed to load map files %s (File doesnt exist in scriptfiles directory)!", file);

	LoadMapSettings(mapname);
	print("\n============================================");
	print("Currently loading....");
	printf("Mapname: %s", MapConfig[MAP_NAME]);
	printf("Author: %s", MapConfig[MAP_AUTHOR]);
	printf("Version: %s", MapConfig[MAP_VERSION]);
	print("============================================");

	printf("[MAP: %s] Map settings loaded!", MapConfig[MAP_NAME]);

	LoadMapDynamicObjects(MapConfig[MAP_CONFIGURATION_NAME]);

	new randomload = random(sizeof(Maplist));
	SetTimerEx("LoadMap", MapConfig[MAP_TIME], false, "s", Maplist[randomload]);

	return 1;
}
I already have this code in OnGamemodeInIt to run the function the first time:

Код:
public OnGameModeInit()
{
	LoadMap("shipment"); 
        return 1;
}
Take a look at this code in that function above

Код:
	new file[100];
	format(file, sizeof(file), MAP_LOCATION, mapname);
	if(!fexist(file)) return printf("FATAL ERROR: Failed to load map files %s (File doesnt exist in scriptfiles directory)!", file)
....and look at this:



I don't understand how could this happen. And sometimes it even tries to load the first message I give to the server, say when I entered a password in the dialog box the first time I connect to the server. And sometimes it load the message I typed to the chat.

And note that:
1. I am aware of SetTimer bug regarding passing strings or array, and I fixed (or at least I hope it is really fixed) from an include <fixes2.inc>


serverlog.txt
Код:
[16:54:03] Currently loading....
[16:54:03] Mapname: Cargoship
[16:54:03] Author: playbox12
[16:54:03] Version: v0.1
[16:54:03] ============================================
[16:54:03] [MAP: Cargoship] Map settings loaded!
[16:54:03] [MAP: cargoship]  229 objects loaded!
[16:54:06] 
============================================
[16:54:06] Currently loading....
[16:54:06] Mapname: Shipment
[16:54:06] Author: playbox12
[16:54:06] Version: v0.1
[16:54:06] ============================================
[16:54:06] [MAP: Shipment] Map settings loaded!
[16:54:06] [MAP: shipment]  381 objects loaded!
[16:54:09] 
============================================
[16:54:09] Currently loading....
[16:54:09] Mapname: Shipment
[16:54:09] Author: playbox12
[16:54:09] Version: v0.1
[16:54:09] ============================================
[16:54:09] [MAP: Shipment] Map settings loaded!
[16:54:09] [MAP: shipment]  381 objects loaded!
[16:54:10] [connection] 127.0.0.1:54656 requests connection cookie.
[16:54:11] [connection] incoming connection: 127.0.0.1:54656 id: 0
[16:54:11] [join] RedBaron has joined the server (0:127.0.0.1)
[16:54:12] FATAL ERROR: Failed to load map files codsamp/Maps/127.0.0.1 (File doesnt exist in scriptfiles directory)!
[16:55:28] [part] RedBaron has left the server (0:1)
So the function works just fine until I join the server and seems like I just messed it up.

What is causing this problem...?
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)