23.04.2012, 22:26
hmmm... crazy... I can't reproduce the problem in a simple test script.
Maybe the plugins I use work in threads and cause the server to crash if I call a function at the wrong time?
I'm using the following plugins:
SA-MP Server version: 0.3e RC7 (I also had this problem in RC6)
//EDIT: I found the problem.
I have an filterscript to process RCON commands in the gamemode. In my filterscript (rcon proxy) I just call rcmd_<command> with CallRemoteFunction().
RCON Proxy Filterscript:
Test gamemode:
Just type "testcmd" in the server console or send it via RCON.
The result will look like that:
But I want that:
//EDIT2: I moved the SlowFunction() code directly to OnRconCommand() in the filterscript. Same problem...
Filterscripts don't run in the main loop? But I thought SA-MP is using a single thread?
Maybe the plugins I use work in threads and cause the server to crash if I call a function at the wrong time?
I'm using the following plugins:
- crashdetect plugin v4.6
- GeoIP Plugin v0.1.4
- IRC Plugin v1.4.2
- SA:MP MySQL Plugin 2.1.1
- Regular expression 0.2
- Streamer Plugin v2.6
- XML plugin
SA-MP Server version: 0.3e RC7 (I also had this problem in RC6)
//EDIT: I found the problem.
I have an filterscript to process RCON commands in the gamemode. In my filterscript (rcon proxy) I just call rcmd_<command> with CallRemoteFunction().
RCON Proxy Filterscript:
Код:
#include <a_samp> public OnFilterScriptInit() { print("RCON Proxy Filterscript loaded"); return true; } public OnFilterScriptExit() { print("RCON Proxy Filterscript unloaded"); return true; } public OnRconCommand(cmd[]) { new pos; new functionName[32]; while (cmd[pos] > ' ') { functionName[pos] = tolower(cmd[pos]); pos++; } format(functionName, sizeof(functionName), "rcmd_%s", functionName); while (cmd[pos] == ' ') { pos++; } if (!cmd[pos]) { return CallRemoteFunction(functionName, "s", "\1"); } return CallRemoteFunction(functionName, "s", cmd[pos]); }
Код:
#include <a_samp> public OnGameModeInit() { SetTimer("Timer", 250, true); } SlowFunction() { print("SlowFunction:Start"); // Simulate slow function new oldTime = gettime(); new difference; while (difference < 5) { difference = gettime() - oldTime; } print("SlowFunction:End"); } forward rcmd_testcmd(command[]); public rcmd_testcmd(command[]) { SlowFunction(); return true; } forward Timer(); public Timer() { print("Timer"); } main(){}
The result will look like that:
Код:
[00:44:22] Timer [00:44:23] Timer [00:44:23] Timer [00:44:23] Timer Console input: testcmd [00:44:23] SlowFunction:Start [00:44:23] Timer [00:44:24] Timer [00:44:24] Timer [00:44:24] Timer [00:44:25] Timer [00:44:25] Timer [00:44:25] Timer [00:44:25] Timer [00:44:26] Timer [00:44:26] Timer [00:44:26] Timer [00:44:27] Timer [00:44:27] Timer [00:44:27] Timer [00:44:27] Timer [00:44:28] SlowFunction:End [00:44:28] Timer [00:44:28] Timer [00:44:28] Timer [00:44:28] Timer [00:44:29] Timer [00:44:29] Timer
Код:
[00:44:22] Timer [00:44:23] Timer [00:44:23] Timer [00:44:23] Timer Console input: testcmd [00:44:23] SlowFunction:Start [00:44:28] SlowFunction:End [00:44:28] Timer [00:44:28] Timer [00:44:28] Timer [00:44:28] Timer [00:44:29] Timer [00:44:29] Timer
Filterscripts don't run in the main loop? But I thought SA-MP is using a single thread?