• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

/closeserver ?!

GarQet

Own3d!
Joined
Feb 10, 2009
Messages
1,381
Solutions
14
Reaction score
81
Eloszka, na wstępie chce życzyć wszystkim Wesołych Świąt ^_^ !
Teraz przechodzę do sedna sprawy, mianowicie mam problem z komendą /closeserver. Wpisuje ją w grze, po czym serwer się zamyka (tak jak być powinno), lecz po jakimś czasie sam się otwiera :eek: (?!). Jak ten skrypt jest skonstruowany, że pierw zamyka a potem sam otwiera?
Może mi ktoś go opisać czemu tak się dzieje?
Może global save powoduje otwarcie serwera?
Proszę o pomoc.

Skrypt:
Code:
function onSay(cid, words, param, channel)
	local state = GAMESTATE_CLOSED
	if(words:sub(2, 2) == "o") then
		state = GAMESTATE_NORMAL
	end

	local str = "Failed to " .. (state == GAMESTATE_CLOSED and "close" or "open") .. " server."
	if(doSetGameState(state)) then
		str = "Server has been " .. (state == GAMESTATE_CLOSED and "closed" or "opened") .. " successfully."
	end

	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str)
	return true
end
 
Last edited:
Save/Clean?
Oryginalnych 0.3.5 używasz?

Sam kiedyś tak miałem.

Raczej odwrotnie, global save otwarcie =)...

Używam oryginalnych.
Co do mojego błędu, do sorka, już się poprawiłem, ale wiadomo było o co chodzi :p.

Ostatnio mnie to wkurwiło, zamknąłem serwer (chciałem otworzyć po upłynięciu 10h) po około 4h patrze na stronkę a tam 49player online... :/
Proszę o pomoc.
 
Save:
Code:
local savingEvent = 0

function onSay(cid, words, param, channel)
	if(isNumber(param)) then
		stopEvent(savingEvent)
		save(tonumber(param) * 60 * 1000)
	else
		doSaveServer()
	end
	return true
end

function save(delay)
	doSaveServer()
	if(delay > 0) then
		savingEvent = addEvent(save, delay, delay)
	end
end
 
Też tam miałem. Jak dałem closeserver to przy save serwer sam się otwierał;]
 
Code:
	std::clog << "> Saving server..." << std::endl;
	uint64_t start = OTSYS_TIME();
	if(gameState == GAMESTATE_NORMAL)
		setGameState(GAMESTATE_MAINTAIN);

	IOLoginData* io = IOLoginData::getInstance();
	for(AutoList<Player>::iterator it = Player::autoList.begin(); it != Player::autoList.end(); ++it)
	{
		it->second->loginPosition = it->second->getPosition();
		io->savePlayer(it->second, false, shallow);
	}

	std::string storage = "relational";
	if(g_config.getBool(ConfigManager::HOUSE_STORAGE))
		storage = "binary";

	map->saveMap();
	ScriptEnviroment::saveGameState();
	if(gameState == GAMESTATE_MAINTAIN)
		setGameState(GAMESTATE_NORMAL);

	std::clog << "> SAVE: Complete in " << (OTSYS_TIME() - start) / (1000.) << " seconds using "
		<< storage << " house storage." << std::endl;

Problem tkwi tutaj, bo podczas save przestawia sie stan serwera na Maintain~, zeby nikt nie mogl wbic chwilowo, bo bedzie crash :(, a po wykonanym save przestawia na Normal, zamiast na Closed.
 
@up
czyli najprościej:

globalevents/scripts/save.lua
Code:
local config = {
	broadcast = "no"
}

config.broadcast = getBooleanFromString(config.broadcast)
local function executeSave(seconds)
[B]	if(seconds == 0) then
		doSaveServer()
		return true
	end[/B]

	if(seconds == 120 or seconds == 30) then
		doBroadcastMessage("Full server save within " .. seconds .. " seconds, please stay in safe place!")
	end

	seconds = seconds - 30
	if(seconds >= 0) then
		addEvent(executeSave, 30 * 1000, seconds)
	end
end

function onThink(interval, lastExecution, thinkInterval)
	if(not config.broadcast) then
		doSaveServer()
		return true
	end

	executeSave(120)
	return true
end

zamienieniamy na:

Code:
		if (seconds == 0) then
			if getGameState() == GAME_STATE_CLOSED then
				doSaveServer()
				doSetGameState(GAME_STATE_CLOSED)
			else
				doSaveServer()
			end
			return true
		end

Mh?
Nie wiem czy będzie działać, nie sprawdzałem...

Jest jeszcze opcja, że w źródłach ten state przerobisz, żeby przed zamknieciem sprawdzić, czy state=closed, jeśli tak to jakas tam zmienna beforeClosed=true, a na końcu if(beforeClosed) { state=open }...

Tylko, że przy /save serwer dalej będzie się otwierał (co zrobic? talkactions/scripts/save.lua [...]).
 
@up
I tak będzie źle, poprawiłem już :D...

Code:
		if (seconds == 0) then
			if getGameState() == GAME_STATE_CLOSED then
				doSaveServer()
				doSetGameState(GAME_STATE_CLOSED)
			else
				doSaveServer()
			end
			return true
		end

Tak powinno wyglądać.

To co napisaleś wyżej jest troche nielogiczne ^^, przy każdym SAVE serwer się zamykać będzie ^^.
 
No, przynajmniej tyle dobrego :p.
Dziękówka, repucik lecą.
 
Back
Top