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

6 players needed to pull a lever..

Joined
Jun 19, 2009
Messages
1,852
Reaction score
5
Hello!

I need a script;

you must be at least 6 players in order to pull a lever, and those 6 players needs to stand on those tiles (like anni):

20100523231929.png


and all of those players must be at least xxx lvl, also, when pulling the lever; 50 crystal coins will be removed :p

thanks!

edit: lol, forgot the most important thing

When the lever is pulled, a stone gets removed from a specific position. thanks!

edit2:

I got this script from Cykotitan but it doesn't work for some reason... no errors in console or anything.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="idk" enabled="yes">
    <action uniqueid="64317" event="script"><![CDATA[
        local playerPosition = {
          {x = 1144, y = 850, z = 5},
          {x = 1144, y = 851, z = 5},
          {x = 1144, y = 852, z = 5},
          {x = 1144, y = 853, z = 5},
          {x = 1144, y = 854, z = 5},
          {x = 1144, y = 855, z = 5}
        }
        local players = {}
        if item.itemid == 1945 then
            for _, pos in ipairs(playerPosition) do
                local c = getTopCreature(pos).uid
                if c > 0 and isPlayer(c) then table.insert(players, c) end
            end
            if #players == 6 then
                local stone, stonePos = 1304, {x = 1141, y = 856, z = 5}
                local it = getTileItemById(stonePos, stone).uid
                if it < 1 then
                    return doPlayerSendCancel(cid, "No stone to remove.")
                end
                for _, v in ipairs(players) do
                    if getPlayerItemCount(v, 155) < 100 or getPlayerLevel(v) < 150 then
                        for _, pid in ipairs(players) do
                            doPlayerSendCancel(pid, getPlayerName(v) .. (getPlayerLevel(v) >= 150 and " doesn't have enough money." or " isn't level 150."))
                        end
                        return true
                    end    
                end
                for _, v in ipairs(players) do
                    doPlayerRemoveItem(v, 155, 100)
                    doPlayerSendTextMessage(v, MESSAGE_STATUS_CONSOLE_ORANGE, "You have removed the wall, but it costed you a lot of money!")
                end
                doRemoveItem(it)
            else
                return doPlayerSendCancel(#players > 0 and players[1] or cid, "You need to be at least 6 persons to pass the wall.")
            end
        end
        return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
    ]]></action>
</mod>

thanks!
 
Last edited:
i meant with the function "getTileItemById" you must make a check if the item is their in the place you specified or it will raise an error (item not found) etc etc
 
yep, and

(-Inf,-1) U (1,INF) numbers are true, and
0 = false xD

I mean all numbers excluding 0 are true so if getTileItemById returns 0 when there is no Item with ID on Tile, then
Lua:
 if it>0 then

it same as

if it then
xP
 
you can try this;
Code:
local playerPosition = {
	{x = 100, y = 200, z = 7},
	{x = 100, y = 200, z = 7},
	{x = 100, y = 200, z = 7},
	{x = 100, y = 200, z = 7},
	{x = 100, y = 200, z = 7},
	{x = 100, y = 200, z = 7}
}
local players = {}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 or item.itemid == 1946 then
		for _, pos in ipairs(playerPosition) do
			local c = getTopCreature(pos).uid
			if c > 0 and isPlayer(c) then table.insert(players, c) end
		end
		local stone, stonePos = 1000, {x = 100, y = 200, z = 7}
		local it = getTileItemById(stonePos, stone).uid
		if #players == 6 then
			for _, v in ipairs(players) do
				if getPlayerItemCount(v, 2160) >= 50 then
					doPlayerRemoveItem(v, 2160, 50)
				end
				if it then
					doRemoveItem(it)
					break
				end
			end
		else
			return doPlayerSendCancel(#players > 0 and players[1] or cid, "You need atleast 6 players to enter.")
		end
	end
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Lua:
			for _, v in ipairs(players) do
				if getPlayerItemCount(v, 2160) >= 50 then
					doPlayerRemoveItem(v, 2160, 50)
				end
				if it then
					doRemoveItem(it)
					break
				end
			end

same as Wesoly xD

should be:
Lua:
			local hascash = true;
			if it then
				for _, v in ipairs(players) do
					if getPlayerItemCount(v, 2160) < 50 then
						hascash=false;
						break;
					end
				end
				if hascash then
					--Bool with remove money
					doRemoveItem(it)
				else
					--Error Message
				end
			end
 
Last edited:
I can't understand what comes up with these pairs and for _, ipairs, etc. LOL, I have to learn it somewhere :/

PS
What's wrong with my script denero?

quas
In my script can't be "if (doPlayerRemovemoney(player1.uid) and) == TRUE then"? It is long but it should work I think
 
PHP:
local playersPos = {
		{x = 100, y = 200, z = 7},
		{x = 100, y = 200, z = 7},
		{x = 100, y = 200, z = 7},
		{x = 100, y = 200, z = 7},
		{x = 100, y = 200, z = 7},
		{x = 100, y = 200, z = 7}
	},
	
local stonePos = {x = 200, y = 100, z=7}

}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local pc=0
	for _,p in ipairs(playersPos) do
		p.stackpos = 253
		if isPlayer(getThingfromPos(p).uid) then
			pc = pc+1
		end
	end
	if pc == #playersPos then
		stonePos.stackpos = 1
		doRemoveItem(stonePos.uid, 1, true)
	else
		doPlayerSendCancel("You need 6-player team to remove stone.")
	end
end
take it easy.
 
Code:
local playersPos = [B][COLOR="Blue"]{
		{x = 100, y = 200, z = 7},
		{x = 100, y = 200, z = 7},
		{x = 100, y = 200, z = 7},
		{x = 100, y = 200, z = 7},
		{x = 100, y = 200, z = 7},
		{x = 100, y = 200, z = 7}
	},
	
local stonePos = {x = 200, y = 100, z=7}

}[/COLOR][/B]
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local pc=0
	for _,p in ipairs(playersPos) do
		p.stackpos = 253
		if isPlayer(getThingfromPos(p).uid) then
			pc = pc+1
		end
	end
	if pc == #playersPos then
		stonePos.stackpos = 1
		doRemoveItem([B][COLOR="Red"]stonePos.uid[/COLOR][/B], 1, true)
	else
		[B][COLOR="Red"]doPlayerSendCancel("You need 6-player team to remove stone.")[/COLOR][/B]
	end
end
take it easy.
so many bugas bugas bugas bugas bugas bugas bugas bugas bugas bugas
--
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="idk" enabled="yes">
	<action uniqueid="10000" event="script"><![CDATA[
		local playerPosition = {
			{x = 100, y = 200, z = 7},
			{x = 100, y = 200, z = 7},
			{x = 100, y = 200, z = 7},
			{x = 100, y = 200, z = 7},
			{x = 100, y = 200, z = 7},
			{x = 100, y = 200, z = 7}
		}
		local players = {}
		if item.itemid == 1945 or item.itemid == 1946 then
			for _, pos in ipairs(playerPosition) do
				local c = getTopCreature(pos).uid
				if c > 0 and isPlayer(c) then table.insert(players, c) end
			end
			if #players == 6 then
				local stone, stonePos = 1234, {x = 100, y = 200, z = 7}
				local it = getTileItemById(stonePos, stone).uid
				for _, v in ipairs(players) do
					if getPlayerItemCount(v, 2060) >= 50 then
						doPlayerRemoveItem(v, 2060, 50)
						if it > 0 then
							doRemoveItem(it)
						else
							doPlayerSendCancel(v, "No stone to remove.")
							break
						end
					else
						doPlayerSendCancel(v, "You dont have enough money.")
						break
					end
				end
			else
				return doPlayerSendCancel(#players > 0 and players[1] or cid, "You need atleast 6 players to do this.")
			end
		end
		return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
	]]></action>
</mod>
 
Last edited:
sorry xD but should I put the uid on the stone or on the stone?

Also,

Code:
local [COLOR="Red"]stone[/COLOR], stonePos = 1234, {x = 100, y = 200, z = 7}

what's "stone (1234)"? The ID of the stone?
 
Script doesn't work, no errors in game or in console :S

script I'm using:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="idk" enabled="yes">
    <action uniqueid="64317" event="script"><![CDATA[
local playerPosition = {
  {x = 1144, y = 850, z = 5},
  {x = 1144, y = 851, z = 5},
  {x = 1144, y = 852, z = 5},
  {x = 1144, y = 853, z = 5},
  {x = 1144, y = 854, z = 5},
  {x = 1144, y = 855, z = 5}
}
        local players = {}
        if item.itemid == 1945 or item.itemid == 1946 then
            for _, pos in ipairs(playerPosition) do
                local c = getTopCreature(pos).uid
                if c > 0 and isPlayer(c) then table.insert(players, c) end
            end
            if #players == 6 then
                local stone, stonePos = 1304, {x = 1141, y = 856, z = 5}
                local it = getTileItemById(stonePos, stone).uid
                for _, v in ipairs(players) do
                    if getPlayerItemCount(v, 155) >= 100 then
                        doPlayerRemoveItem(v, 155, 100)
                        if it > 0 then
                            doRemoveItem(it)
                        else
                            doPlayerSendCancel(v, "No stone to remove.")
                            break
                        end
                    else
                        doPlayerSendCancel(v, "You dont have enough money.")
                        break
                    end
                end
            else
                return doPlayerSendCancel(#players > 0 and players[1] or cid, "You need at least 6 players to do this.")
            end
        end
        return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
    ]]></action>
</mod>

What I've done:

i put the correct uid in the stone
changed money
changed positions
changed stone id

that's all :S

edit: works :p

editt2: not realy what i wanted after all
 
Last edited:
Lua:
local function getCreaturesFromArea(fromPosition, toPosition)
	local creatures = {};
	local currentPosition, creature;
	for ax = fromPosition.x, toPosition.x do
		for ay = fromPosition.y, toPosition.y do
			for az = fromPosition.z, toPosition.z do
				currentPosition = {x=ax,y=ay,z=az, stackpos=STACKPOS_TOP_CREATURE};
				creature = getTopCreature(currentPosition).uid
				if isCreature(creature) then
					table.insert(creatures,creature);
				end
			end
		end
	end
	return creatures;
end

local function getMonstersFromArea(fromPosition, toPosition)
	local creatures = getCreaturesFromArea(fromPosition, toPosition);
	local monsters = {};
	for i =1,#creatures do
		if isMonster(creatures[i]) then
			table.insert(monsters,creatures[i]);
		end
	end
	return monsters;
end

local function getPlayersFromArea(fromPosition, toPosition)
	local creatures = getCreaturesFromArea(fromPosition, toPosition);
	local players = {};
	for i =1,#creatures do
		if isPlayer(creatures[i]) then
			table.insert(players,creatures[i]);
		end
	end
	return players;
end

local players = getPlayersFromArea(Pos_Most_up, Pos_Most_Down)
if #players == 6 then 

etc...
 
Back
Top