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

Lua Convert old script to 1.0

Gaddhuve

Member
Joined
May 6, 2011
Messages
76
Solutions
1
Reaction score
19
Hey guys, got favor to ask.

The script below used to be one of my favourites but since I switched to 1.0 it does not work so Id be really thankful if someone could convert it for me!

Code:
local t = {
    npc = 'Npc',
    text = 'Text 1',
    storage = 13518,
    pos = {x=1523, y=1326, z=7}
}

function onStepIn(cid, item, position, fromPosition)
    if isPlayer(cid) and getPlayerStorageValue(cid, t.storage) == -1 then
        setPlayerStorageValue(cid, t.storage, 1)
       
        local v = doCreateNpc(t.npc, t.pos)
        doCreatureSay(v, t.text, TALKTYPE_YELL)       
        addEvent(doCreatureSay, 2000, v, t.text, TALKTYPE_YELL)
        addEvent(doRemoveCreature, 5000, v)
       
        addEvent(doMoveCreature, 1000, v, WEST)
       
    end
end

It does not give me any errors in console. Thanks in advance!
 
Code:
local config = {
    storageKey = 1000,
    npcName = "Name",
    spawnPosition = Position(100, 100, 7),
    sayText = "Hello"
}

local function delayMovement(cid)
    if Npc(cid) then
        doMoveCreature(cid, DIRECTION_WEST)
    end
end

local function delaySay(cid)
    local npc = Npc(cid)
    if npc then
        npc:say(config.sayText, TALKTYPE_YELL)
    end
end

local function delayRemove(cid)
    local npc = Npc(cid)
    if npc then
        npc:remove()
    end
end

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if player == nil then
        return false
    end

    if player:getStorageValue(config.storageKey) == 1 then
        return false
    end

    local npc = Game.createNpc(config.npcName, config.spawnPosition)
    if npc then
        npc:say(config.sayText, TALKTYPE_YELL)
        local npcId = npc:getId()
        addEvent(delayMovement, 1000, npcId)
        addEvent(delaySay, 2000, npcId)
        addEvent(delayRemove, 5000, npcId)
    end

    player:setStorageValue(config.storageKey, 1)
    return true
end
 
Hey, thanks for taking your time, really! (-:

Got this:
B0rJ9dd.png

Difficult to fix?
 
Back
Top