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

help with globalevent

Joined
Apr 17, 2008
Messages
1,922
Solutions
1
Reaction score
188
Location
Venezuela
Look this script:

Lua:
function onThink(interval, lastExecution)

local ENCHANTEDMONSTER_POSITION = {x=95, y=126, z=7, stackpos=253}

local enchantedMonster = getThingFromPos(ENCHANTEDMONSTER_POSITION)

	for _, name in ipairs(getOnlinePlayers()) do
	local player = getPlayerByName(name)
	if enchantedMonster.itemid > 0 then
		doSendMagicEffect(ENCHANTEDMONSTER_POSITION, CONST_ME_MAGIC_GREEN)
	else
		if getPlayerStorageValue(player, 15230) == 0 then
			doCreateMonster("Enchanted Monster", ENCHANTEDMONSTER_POSITION)
			doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Enchanted Monster is alive again.")
		end
	end
	end
		return TRUE
end

My script is based in a creaturescript and a globalevent. Each 1 hour, only a player in the server can kill a creature and gain a storage. The globalevent check if the monster is alive, if the monster is dead, check for the player that have the storage. If the globalevent do not found the player (If player die, or log out [i have a creature script that when you log out it remove the storage from the player]), it will summon the creature again.

Problem: The global event works if in the server is only a player online (player that kill the monster) nut.. if are more than 1 player online, it does not work. I think it happens because the globalevent check storage for ALL players, and not for one player.

SORRY IF I WRITE IN BAD ENGLISH.
 
Last edited:
You could use global storage instead

And also if this monster will have unique name, then you can do getCreatureByName() instead setting position, which isn't constant [?]

for example
Code:
  function onThink(interval, lastExecution)

local ENCHANTEDMONSTER_POSITION = {x=95, y=126, z=7, stackpos=253}

local enchantedMonster = getThingFromPos(ENCHANTEDMONSTER_POSITION)

        if enchantedMonster.itemid > 0 then
                doSendMagicEffect(ENCHANTEDMONSTER_POSITION, CONST_ME_MAGIC_GREEN)
        else
                if getGlobalStorageValue(15230) == 0 then
                        doCreateMonster("Enchanted Monster", ENCHANTEDMONSTER_POSITION)
                        doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Enchanted Monster is alive again.")
                end
        end
                return TRUE
end
 
Back
Top