• 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!

function that executes when server start

You could do it through the onLogin function, although this would happen as soon as someone login and not immediately after the server starts.
 
You could also try doing it like this (Will work only in 0.3+)

add this at the bottom of functions.lua
Code:
function startupEvent()
	if(getGameState() == GAMESTATE_NORMAL) then
		if(getGlobalStorageValue(10001) == -1) then
			setGlobalStorageValue(10001, 1)
			onServerStart()
			addEvent(setGlobalStorageValue, 3000, 10001, -1)
		end
	else
		addEvent(startupEvent, 1000)
	end
end

startupEvent()

function onServerStart()
	--here you can place whatever you want
	--will be executed at server start
	print('Server loaded..')
end

#Edit

Ha! Tested and it works ;)

#Edit2

Fixes..
 
Last edited:
use npc! make a xml npc, which loads a script. do whatever you want in a BLANK script file, no functions. this will only load when you start the server, and when you reload npcs. so if you dont reload npcs, you have a prefect startup script
 
thanks for the help everyone, I'll try it

the problem was like this:
I got this quest thing where you have to kill some monsters in a special combo and if you do it the proper way a stone removes and when you step behind the stone the sotne and the monsters reapear. But as the monsters reapear with the doCreateMonster function then it'll spawn extra monsters with the spawn thing. And for that I needed to create the monsters with a script at the beginning of the server so I didnt need to make them as a spawn.

So I guess there is other ways around it but this was the easiest I could think of

edit: the code you wrote slawkens: the global storage dosent reset at server close
 
Last edited:
Sure, but it works only at first start :D

Yaa, sorry men, nie pomyślałem o tym, a przetestowałem tylko jednorazowo jak to mam w zwyczaju :D

#Topic
This storage is just for protection, as without it, onServerStart() will be executed probably 6-7 times (for actions, movements etc)

Code:
@function onTopic()
	print('Updated!')
	return POST_NEW_REPLY
end

#fixed this bug in previous post
 

Similar threads

Back
Top