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

Script works but not as i want!

Ninja Bodil

New Member
Joined
Mar 7, 2009
Messages
116
Reaction score
0
Oki you may have seen my thread "Need help with reward".
So I didn't got the problem solved (Nice try Icy).
So i decided to try it on my own. The script give you a reward when you are alone in an area. So this is my script:

Globalevents.xml:
Code:
<globalevent name="LMS" interval="1" script="lms.lua"/>
LMS.lua
Code:
function getPlayersInRange(position, radiusx, radiusy)
	local creaturesList = {}
	for x = -radiusx, radiusx do
		for y = -radiusy, radiusy do
			if not (x == 0 and y == 0) then
				local creature = getTopCreature({x = position.x+x, y = position.y+y, z = position.z})
				if creature.type == 1 then
					table.insert(creaturesList, creature.uid)
				end
			end
		end
	end
	local creature = getTopCreature(position)
	if creature.type == 1 then
		if not(table.find(creaturesList, creature.uid)) then
			table.insert(creaturesList, creature.uid)
		end
	end
    return creaturesList
end
function lms()
local t = {
temple = {x=1000, y=1000, z=7},
lol = {x=1045, y=1173, z=7},
}

local area = getPlayersInRange({x=1045, y=1173, z=7}, 15, 11)

if #area <2 and #area >0 then


doBroadcastMessage(getPlayerName(area[1]) .. " has won Last man standing!", MESSAGE_STATUS_WARNING)
doPlayerAddLevel(area[1], 1)
doTeleportThing(area[1], t.temple)
else doSendMagicEffect(t.lol, CONST_ME_BLOCKHIT)
end
return true
end

function onThink(cid, interval)
        addEvent(lms, 0)
return true
end
The script works but when like three players are in the area one of the players get an reward and get tped to temple and the other to fight untill one die and the "winner" get an reward.
So can anyone fix so the first player don't get tped out.
(hope you know what i mean).
 
Last edited:
Back
Top