• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved Simple addition script

Vrotz

Member
Joined
Apr 7, 2011
Messages
1,071
Reaction score
7
Location
Brazil
Hi,

How I do to add the message in this script? When the player use the lever, he receives a message in the default.

PHP:
local config ={
    pos = {x=808, y=1151, z=8},
    itemid = 1304,
    time = 1800
}

local function Remove(fromPosition)
    doCreateItem(config.itemid, 1, config.pos)
    doTransformItem(getTileItemById(fromPosition, 1946).uid, 1945)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1945 then
        doRemoveItem(getTileItemById(config.pos, config.itemid).uid)
        addEvent(Remove, config.time * 1000, fromPosition)
        doTransformItem(item.uid, 1946)
    elseif item.itemid == 1946 then
        if getTileItemById(config.pos, config.itemid).uid > 0 then
            doTransformItem(item.uid, 1945)
        else
            doPlayerSendCancel(cid, "It seems the lever has been already used.")
        end      
    end
    return true
end

Thanks.
 
Code:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your message.")
If it should give this message when the player uses the lever to remove the stone, add it between if and elseif.
 
Like that?

PHP:
local config ={
    pos = {x=808, y=1151, z=8},
    itemid = 1304,
    time = 1800
}

local function Remove(fromPosition)
    doCreateItem(config.itemid, 1, config.pos)
    doTransformItem(getTileItemById(fromPosition, 1946).uid, 1945)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1945 then
        doRemoveItem(getTileItemById(config.pos, config.itemid).uid)
        addEvent(Remove, config.time * 1000, fromPosition)
        doTransformItem(item.uid, 1946)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "My msg.")
    elseif item.itemid == 1946 then
        if getTileItemById(config.pos, config.itemid).uid > 0 then
            doTransformItem(item.uid, 1945)
        else
            doPlayerSendCancel(cid, "It seems the lever has been already used.")
        end      
    end
    return true
end
 
Back
Top