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

Requesting 3 Different Scripts and a Question

ELEM3NT

LUA Status: Beginner
Joined
Mar 12, 2009
Messages
191
Reaction score
0
Location
In your room without you knowing.
Okay, can anybody be helpful enough to make me 3 somewhat-easy scripts? Seems pretty simple for other people but for me, I tried to get them to work and it got so frustrating!

Script 1) I right click an item (5951 is itemid) and it removes 4 different walls in 4 different positions, then after 30 seconds, it adds the 3 different walls in 4 different positions back to normal. So its kinda like 4 Walls Removed, 30 Second Interval, then 4 Walls added again, then when I right click the item again it repeats. I got a script that does that but it only removes, doesn't add it again:
LUA:
-- Removing walls with time (By Conde Sapo)

function onUse(cid, item, fromPosition, itemEx, toPosition)

pausa = 0 -- 2 sec.

-- wall positions - don't change stackpos.
wall0pos = {x=1741, y=2051, z=7, stackpos=1}
wall1pos = {x=1743, y=2051, z=7, stackpos=1}
wall2pos = {x=1741, y=2052, z=7, stackpos=1}
wall3pos = {x=1743, y=2052, z=7, stackpos=1}


if item.itemid == 5951 then
wall0 = getThingfromPos(wall0pos)
if wall0.itemid ~= 0 then
doBroadcastMessage("The maze event has started! Find the ham my little rats!", 22)
doRemoveItem(wall0.uid,1)
addEvent(wait1,pausa,wall1pos)
end
else
end
return 1
end

function wait1(wall1pos)
thing = getThingfromPos(wall1pos)
doRemoveItem(thing.uid,1)
addEvent(wait2,pausa,wall2pos)
end

function wait2(wall2pos)
thing = getThingfromPos(wall2pos)
doRemoveItem(thing.uid,1)
addEvent(wait3,pausa,wall3pos)
end

function wait3(wall3pos)
thing = getThingfromPos(wall3pos)
doRemoveItem(thing.uid,1)
end

Script 2) Set someone's basespeed once right clicked lever? Like right click lever, there basespeed stays at 100.. This is what I have, I just need it to change the basespeed to a certain number so everyone can be same speed(only need the function to put it in my script)
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local outfit = { lookType = 21, lookHead = 0, lookAddons = 0, lookLegs = 0, lookBody = 0, lookFeet = 0 }	
	 if item.actionid == 6273 then 
	 
		doSetCreatureOutfit(cid, outfit, 10000*60*1000)
		doSendAnimatedText(getPlayerPosition(cid), "HAM!", 78)
                >doSetBaseSpeed or however you do it here or something<
		doPlayerSendTextMessage(cid,22,"Please here while the event gets started.")
		doTeleportThing(cid, {x=1742, y=2052, z=7})
end
  end

Script 3) Once someone goes through portal, they get kicked and once they log back on, there at the temple. (from the portal's coordinates)

Questions:
1) How do I make it so people can walk through eachother(the tibia function)? Because my event is a maze and I don't people trapping eachother.. There are alot of 1 way paths.

2) How do I make it so people can't use spells in certain areas, like utani hur to speed them up n stuff. Like they've already been exhausted? =O



I know this must sound like alot of work, but please if you can, make these scripts! :) Thank you! :thumbup:
 
Last edited:
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)

	local pausa,storage,wall_itemid,t = 30000,40000,1234,0;
	local walls = {{x=1741, y=2051, z=7}, {x=1743, y=2051, z=7}, {x=1741, y=2052, z=7}, {x=1743, y=2052, z=7}}

	if(getStorage(storage)<1) then
		for i=1,#walls do
			t=getTileItemById(walls[i], wall_itemid)
			if t then
				doRemoveItem(t.uid)
				addEvent(doCreateItem,pausa,wall_itemid,1,walls[i])
			end
		end
		setStorage(storage,1);
		addEvent(setStorage,pausa,storage,0);
	end
	return true;
end
 
@quas, I got an error
Code:
[31/05/2010 18:17:28] data/actions/scripts/custom/Maze WallRemover.lua:onUse
[31/05/2010 18:17:28] Description: 
[31/05/2010 18:17:28] data/actions/scripts/custom/Maze WallRemover.lua:14: attempt to call global 'setStorage' (a nil value)
[31/05/2010 18:17:28] stack traceback:
[31/05/2010 18:17:28] 	data/actions/scripts/custom/Maze WallRemover.lua:14: in function <data/actions/scripts/custom/Maze WallRemover.lua:1>

And can you kinda explain the script to me? I don't really get it, like wheres the time and stuff.. Sorry for rushin ya.

Pce:peace:
 
@up Depends on TFS Version in 0.4 is SetStorage/GetStorage

in Older ones is setGlobalStorageValue/getGlobalStorageValue
LUA:
        local pausa,storage,wall_itemid,t =  30000,40000,1234,0;
                                          --interval, storage, UR WALL ITEMID,TEMP VAR.
 
cuz players could click item 1500x per second, so 1500 wals will be created.

i have old 0.3.5 functions and there doCreateItem has 3 parameters.

LUA:
doCreateItem(itemid, type/count, pos)

It is not better cuz it is harder to configure script if u write values instead of variables what keeps this value. I mean bigger script, longer than 20 lines, but this is nice habit, so i keep doing it even in small scripts.
 
cuz players could click item 1500x per second, so 1500 wals will be created.

i have old 0.3.5 functions and there doCreateItem has 3 parameters.

LUA:
doCreateItem(itemid, type/count, pos)

It is not better cuz it is harder to configure script if u write values instead of variables what keeps this value. I mean bigger script, longer than 20 lines, but this is nice habit, so i keep doing it even in small scripts.
Lol, when you add 'if item.itemid ~= 1234 then return true' and fuck the spam :D
 
cuz players could click item 1500x per second, so 1500 wals will be created.

i have old 0.3.5 functions and there doCreateItem has 3 parameters.

It is not better cuz it is harder to configure script if u write values instead of variables what keeps this value. I mean bigger script, longer than 20 lines, but this is nice habit, so i keep doing it even in small scripts.

instead storages

LUA:
local last, delay = 0, 5 -- 0, delay in secs.

local wall_itemid = 1234

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local walls =
        {
            {x = 1741, y = 2051, z = 7},
            {x = 1743, y = 2051, z = 7},
            {x = 1741, y = 2052, z = 7},
            {x = 1743, y = 2052, z = 7}
        }

    if (math.abs(os.time() - last) >= delay) then
        for _, wall in ipairs(walls) do
            local tmp = getTileItemById(wall, wall_itemid).uid
            if (tmp > 0) then
                doRemoveItem(tmp)
                addEvent(doCreateItem, delay * 1000, wall_itemid, 1, wall)
            end
        end
        last = os.time()
    end
    return true
end

also, this is not php;
 
Back
Top