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

Request / Is this possible?

Ecstacy

Mothafuckaaa
Joined
Dec 26, 2008
Messages
3,836
Reaction score
108
Location
The Netherlands
Hello,

I'm having this idea of an event, which should be all automatic, so it works while I'm away from the server.

Now I need to know if the following things are possible to script, and if so I would like to make it a request:

- Only 10 people may enter a portal which spawns every hour.
- After killing a boss is it able to get every player of which have attacked the monster and give them a reward.

Thanks in advance,
unknown666
 
Code:
function onTime()
	doCreateTeleport(1387, {x = 1024, y = 1024, z = 7}, {x = 2048, y = 2048, z = 7})
	setStorage(1336, 0)
	return true
end

Code:
function onDeath(cid, corpse, deathList)
	for _, creature in ipairs(deathList) do
		if(isPlayer(creature)) then
			doCreatureSetStorage(creature, 1337, 1)
		end
	end
	return true
end

Code:
local rews = {
	[1001] = {2160, 100},
	[1002] = {2400, 1}
}

function onUse(cid, item, fromPositio, itemEx, toPosition)
	local rew = rews[item.uid]
	if(rew) then
		if(tonumber(getCreatureStorage(cid, 1337)) == 1) then
			if(tonumber(getCreatureStorage(cid, 1338)) == EMPTY_STORAGE) then
				doPlayerAddItem(cid, rew[1], rew[2])
			else
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
			end
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can't touch this chest!")
		end
	end
	return true
end

Code:
local in = {x = 4096, y = 4096, z = 7}
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
	if(tonumber(getStorage(1336)) < 10) then
		doTeleportThing(cid, in)
		setStorage(1336, tonumber(getStorage(1336)) + 1)
	else
		doTeleportThing(cid, fromPosition, true)
	end
	return true
end
 
Code:
function onKill(cid, target, flags)
	if(getCreatureName(target):lower() == "hp monster" and isPlayer(cid)) then
		local myPos = getCreaturePosition(cid)
		local targetPos = getCreaturePosition(target)
		if(myPos.x == targetPos.x and myPos.y == targetPos.y and myPos.z == targetPos.z) then
			voila()
		end
	end
	return true
end
 
Hmm, I'm having some trouble with some scripts.

With
LUA:
local tp = {x= 995, y= 1024, z= 7}
local tpto = {x= 1356, y= 921, z= 13}

function onThink(interval, lastExecution, thinkInterval)
  doCreateTeleport(1387, tpto, tp)
  doSetGlobalStorage(3330, 0)
  doBroadcastMessage("The boss kill event teleport is created, it will be removed in 2 minutes.")
  addEvent(onRemove, 60 * 2 * 1000)
return true
end

function onRemove()
     doRemoveItem(getTileItemById(tp, 1387).uid)
         doSendMagicEffect(tp, CONST_ME_POFF)
         doBroadcastMessage("The teleport was removed.")  
return true
end

I'm getting this error:
Code:
[30/04/2010 13:52:06] [Error - GlobalEvent Interface] 
[30/04/2010 13:52:06] data/globalevents/scripts/tpevent.lua:onThink
[30/04/2010 13:52:06] Description: 
[30/04/2010 13:52:06] data/globalevents/scripts/tpevent.lua:6: attempt to call global 'doSetGlobalStorage' (a nil value)
[30/04/2010 13:52:06] stack traceback:
[30/04/2010 13:52:06] 	data/globalevents/scripts/tpevent.lua:6: in function <data/globalevents/scripts/tpevent.lua:4>
[30/04/2010 13:52:06] [Error - GlobalEvents::think] Couldn't execute event: bossevent

Which also means that this doesn't work.
LUA:
local tp = {x= 1356, y= 921, z= 13}

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
	if(tonumber(doGetStorage(3330)) < 10) then
		doTeleportThing(cid, tp)
		doSetGlobalStorage(3330, tonumber(doGetGlobalStorage(1336)) + 1)
	else
		doTeleportThing(cid, fromPosition, true)
	end
	return true
end

Also, nothing happens when killing the "HP monster" since I get no broadcast
LUA:
function onKill(cid, target, flags)
	if(getCreatureName(target):lower() == "hp monster" and isPlayer(cid)) then
		local myPos = getCreaturePosition(cid)
		local targetPos = getCreaturePosition(target)
		if(myPos.x == targetPos.x and myPos.y == targetPos.y and myPos.z == targetPos.z) then
			doBroadcastMessage("works")
		end
	end
	return true
end
 
doSetGlobalStorage to setGlobalStorageValue
doGetStorage to getGlobalStorageValue
;/

And according to the onKill script, you would have to be at the same position as the target for the broadcast to happen
 
Code:
local positions = {
	{x=100, y=100, z=7},
	{x=101, y=100, z=7},
}
local destination = {x=200, y=200, z=7}

function isPositionInArray(haystack, needle)
	for i = 1, #haystack do
		if haystack[i].x == needle.x and haystack[i].y == needle.y and haystack[i].z == needle.z then
			return true
		end
	end
end

function onKill(cid, target, flags)
	if getCreatureName(target):lower() == "hp monster" then
		local myPos = getThingPos(cid)
		if isPositionInArray(positions, myPos) then
			doTeleportThing(cid, destination)
			doSendMagicEffect(myPos, CONST_ME_TELEPORT)
			doSendMagicEffect(destination, CONST_ME_TELEPORT)
		end
	end
	return true
end
 
Back
Top