X time for use lever - tfs 0.4

adriez

Well-Known Member
Joined
Aug 14, 2011
Messages
73
Best answers
0
Reaction score
0
i want script for use lever, need wait x time, from the first use...
 
OP
A

adriez

Well-Known Member
Joined
Aug 14, 2011
Messages
73
Best answers
0
Reaction score
0
I test and speak you, very ty

Lua:
local wait = 30 -- seconds
local storage = 20000
function onUse(cid, item, fromPos, toPos)
    if getCreatureStorage(cid, storage) > os.time() then
        doPlayerSendCancel(cid, "you must wait another "..getCreatureStorage(cid, storage)-os.time().." seconds before you can use the lever again.")
    else
        -- do other shit
        doCreatureAddStorage(cid, storage, os.time() + seconds)
    end
    return true
end
 
OP
A

adriez

Well-Known Member
Joined
Aug 14, 2011
Messages
73
Best answers
0
Reaction score
0
not function bro, i need first use not use, and speak msg you need wait for 6 minutes and later use..

Lua:
local wait = 30 -- seconds
local storage = 20000
function onUse(cid, item, fromPos, toPos)
    if getCreatureStorage(cid, storage) > os.time() then
        doPlayerSendCancel(cid, "you must wait another "..getCreatureStorage(cid, storage)-os.time().." seconds before you can use the lever again.")
    else
        -- do other shit
        doCreatureAddStorage(cid, storage, os.time() + seconds)
    end
    return true
end
 

Webo

Otland 4ever
Joined
Oct 20, 2013
Messages
604
Best answers
10
Reaction score
206
Location
Warsaw
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1945 then
        local s = getStorage(1)
        if os.time() < s then
            return doPlayerSendCancel(cid, 'You must wait ' .. s - os.time() .. ' more seconds.')
        end
        local k = getTileItemById({x=1167, y=1155, z=7}, 2151).uid
        if k ~= 0 then
            doRemoveItem(k)
            doCreateMonster('Bloody Mary', {x=1168, y=1156, z=7})
            doCreateItem(2776, 1, {x=1168, y=1158, z=7})
            doCreateItem(2776, 1, {x=1169, y=1158, z=7})
            doCreateItem(2774, 1, {x=1170, y=1158, z=7})
            doCreateItem(2776, 1, {x=1171, y=1157, z=7})
            doCreateItem(2774, 1, {x=1171, y=1154, z=7})
            doCreateItem(2776, 1, {x=1165, y=1153, z=7})
            doCreateItem(2774, 1, {x=1169, y=1152, z=7})
            doCreateItem(2776, 1, {x=1165, y=1157, z=7})
            doSendMagicEffect({x=1168, y=1156, z=7}, CONST_ME_TELEPORT)
            doCreatureSay(cid, 'Hahaha, now you are trapped!', TALKTYPE_ORANGE_1)
            doSetStorage(1, os.time() + 3 * 3600)
        else
            return doPlayerSendCancel(cid, 'Sorry, not possible.')
        end
    end
    return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
OP
A

adriez

Well-Known Member
Joined
Aug 14, 2011
Messages
73
Best answers
0
Reaction score
0
create monster ?? you error topic bro...

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1945 then
        local s = getStorage(1)
        if os.time() < s then
            return doPlayerSendCancel(cid, 'You must wait ' .. s - os.time() .. ' more seconds.')
        end
        local k = getTileItemById({x=1167, y=1155, z=7}, 2151).uid
        if k ~= 0 then
            doRemoveItem(k)
            doCreateMonster('Bloody Mary', {x=1168, y=1156, z=7})
            doCreateItem(2776, 1, {x=1168, y=1158, z=7})
            doCreateItem(2776, 1, {x=1169, y=1158, z=7})
            doCreateItem(2774, 1, {x=1170, y=1158, z=7})
            doCreateItem(2776, 1, {x=1171, y=1157, z=7})
            doCreateItem(2774, 1, {x=1171, y=1154, z=7})
            doCreateItem(2776, 1, {x=1165, y=1153, z=7})
            doCreateItem(2774, 1, {x=1169, y=1152, z=7})
            doCreateItem(2776, 1, {x=1165, y=1157, z=7})
            doSendMagicEffect({x=1168, y=1156, z=7}, CONST_ME_TELEPORT)
            doCreatureSay(cid, 'Hahaha, now you are trapped!', TALKTYPE_ORANGE_1)
            doSetStorage(1, os.time() + 3 * 3600)
        else
            return doPlayerSendCancel(cid, 'Sorry, not possible.')
        end
    end
    return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 

Xikini

I whore myself out for likes
Premium User
Joined
Nov 17, 2010
Messages
4,124
Best answers
164
Reaction score
2,194
Provide all of the pertinent information in your first post so we don't need to guess what you want.
 
OP
A

adriez

Well-Known Member
Joined
Aug 14, 2011
Messages
73
Best answers
0
Reaction score
0
[Error - Action Interface]
data/actions/scripts/bomb.lua:eek:nUse
Description:
data/actions/scripts/bomb.lua:8: attempt to perform arithmetic on global 'seconds' (a nil value)
stack traceback:
data/actions/scripts/bomb.lua:8: in function <data/actions/scripts/bomb.lua:3>
Lua:
local wait = 30 -- seconds
local storage = 20000
function onUse(cid, item, fromPos, toPos)
    if getCreatureStorage(cid, storage) > os.time() then
        doPlayerSendCancel(cid, "you must wait another "..getCreatureStorage(cid, storage)-os.time().." seconds before you can use the lever again.")
    else
        -- do other shit
        doCreatureAddStorage(cid, storage, os.time() + seconds)
    end
    return true
end
 
OP
A

adriez

Well-Known Member
Joined
Aug 14, 2011
Messages
73
Best answers
0
Reaction score
0
o script full this, i want, when player use for first time, not function and he wait 6 minutes for use, and other player or same, 5 regressing times, ty

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

local t, n, storage = {
    {x=951, y=1442, z=14},
    {x=951, y=1443, z=14},
    {x=951, y=1444, z=14},
    {x=951, y=1445, z=14},
    
    {x=949, y=1445, z=14},
    {x=950, y=1445, z=14},
    {x=952, y=1445, z=14},
    {x=953, y=1445, z=14}
}, {
    {x=896, y=1434, z=14},
    {x=930, y=1434, z=14},
    {x=930, y=1464, z=14},
    {x=896, y=1464, z=14},
    {x=921, y=1454, z=14},
    
    {x=905, y=1444, z=14},
    {x=921, y=1444, z=14},
    {x=905, y=1454, z=14},
    {x=921, y=1454, z=14}
}, {
    placed = 101,
    max = 102,
    radius = 103
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1946 then
        return doTransformItem(item.uid, item.itemid - 1)
    end

    local v = getPlayersInRange({x=913,y=1449,z=14}, 34, 30)
    if #v > 1 then
        return doPlayerSendCancel(cid, "Please wait for the current match to end.")
    end

    local players = {}
    for i = 1, #t do
        local v = getTopCreature(t[i]).uid
        players[i] = isPlayer(v) and v or nil
    end

    if #players < 2 then
        return doPlayerSendCancel(cid, "You need at least 2 players to enter.")
    end
    
    local first = players[1] and 1 or players[2] and 2 or players[3] and 3 or players[4] and 4 or players[5] and 5 and 6 or players[6] and 7 or players[7] and 7 and 8 or players[8] and 8
    for i = 1, 8 do
        if players[i] then
            setPlayerStorageValue(players[i], storage.placed, 0)
            setPlayerStorageValue(players[i], storage.max, 1)
            setPlayerStorageValue(players[i], storage.radius, 1)
            doSendMagicEffect(t[i], CONST_ME_TELEPORT)
            doTeleportThing(players[i], n[i])
            doSendMagicEffect(n[i], CONST_ME_TELEPORT)
        end
    end

    doTransformItem(item.uid, item.itemid + 1)
    return true
end
updated previous post try again
 
OP
A

adriez

Well-Known Member
Joined
Aug 14, 2011
Messages
73
Best answers
0
Reaction score
0
I want a player can not do it, using a lever since its first use and he can get it after 6 minutes and go back time

sorry my english very bad

I'm a donkey. I can't understand anything you just said
 
OP
A

adriez

Well-Known Member
Joined
Aug 14, 2011
Messages
73
Best answers
0
Reaction score
0
boa tarde, eu quero que qualquer jogador, que for usar a alavanca pela primeira vez não consiga, ai começa a contar um tempo de 6 minutos, caso um segundo tentar usar tbm não consiga e o tempo vai regredindo exemplo 5 minutos, e por ai vai, depois que o tempo acabar qualquer um consiga usar...

@Xikini
 

Xikini

I whore myself out for likes
Premium User
Joined
Nov 17, 2010
Messages
4,124
Best answers
164
Reaction score
2,194
boa tarde, eu quero que qualquer jogador, que for usar a alavanca pela primeira vez não consiga, ai começa a contar um tempo de 6 minutos, caso um segundo tentar usar tbm não consiga e o tempo vai regredindo exemplo 5 minutos, e por ai vai, depois que o tempo acabar qualquer um consiga usar...

@Xikini
Use lever -> wait 6 minutes
use lever -> wait 5 minutes
4 min
3 min
2 min
1 min
use lever -> 0 minutes
use lever -> 0 minutes
use lever -> 0 minutes
use lever -> 0 minutes

yes?
 

Xikini

I whore myself out for likes
Premium User
Joined
Nov 17, 2010
Messages
4,124
Best answers
164
Reaction score
2,194
I think this will work. ¯\(ツ)
Lua:
global_lever_storage = {}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if not global_lever_storage[1] then
        global_lever_storage[1] = 7
        global_lever_storage[2] = 0
    end
   
    if global_lever_storage[1] >= 0 then
        local time = os.time()
        if time < global_lever_storage[2] then       
            doCreatureSay(cid, "Lever can be used again in " .. (global_lever_storage[2] - time) .. " seconds.", TALKTYPE_ORANGE_1)
            return true
        else
            global_lever_storage[1] = global_lever_storage[1] - 1
            global_lever_storage[2] = time + (global_lever_storage[1] * 60)
        end
    end
    doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
    return true
end
 
OP
A

adriez

Well-Known Member
Joined
Aug 14, 2011
Messages
73
Best answers
0
Reaction score
0
@Xikini this script full, for lever my bomberman, i want this not use first time and wait 6 minutes

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

local t, n, storage = {
{x=951, y=1442, z=14},
{x=951, y=1443, z=14},
{x=951, y=1444, z=14},
{x=951, y=1445, z=14},

{x=949, y=1445, z=14},
{x=950, y=1445, z=14},
{x=952, y=1445, z=14},
{x=953, y=1445, z=14}
}, {
{x=896, y=1434, z=14},
{x=930, y=1434, z=14},
{x=930, y=1464, z=14},
{x=896, y=1464, z=14},
{x=921, y=1454, z=14},

{x=905, y=1444, z=14},
{x=921, y=1444, z=14},
{x=905, y=1454, z=14},
{x=921, y=1454, z=14}
}, {
placed = 101,
max = 102,
radius = 103
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 1946 then
return doTransformItem(item.uid, item.itemid - 1)
end

local v = getPlayersInRange({x=913,y=1449,z=14}, 34, 30)
if #v > 1 then
return doPlayerSendCancel(cid, "Please wait for the current match to end.")
end

local players = {}
for i = 1, #t do
local v = getTopCreature(t).uid
players = isPlayer(v) and v or nil
end

if #players < 2 then
return doPlayerSendCancel(cid, "You need at least 2 players to enter.")
end

local first = players[1] and 1 or players[2] and 2 or players[3] and 3 or players[4] and 4 or players[5] and 5 and 6 or players[6] and 7 or players[7] and 7 and 8 or players[8] and 8
for i = 1, 8 do
if players then
setPlayerStorageValue(players, storage.placed, 0)
setPlayerStorageValue(players, storage.max, 1)
setPlayerStorageValue(players, storage.radius, 1)
doSendMagicEffect(t, CONST_ME_TELEPORT)
doTeleportThing(players, n)
doSendMagicEffect(n, CONST_ME_TELEPORT)
end
end

doTransformItem(item.uid, item.itemid + 1)
return true
end
 
Top