• 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 Npc need 1 more option

Lbtg

Intermediate OT User
Joined
Nov 22, 2008
Messages
2,324
Reaction score
136
Hello so i got this npc with gives Storage for xxxx items.
i use 0.4

i want that npc can aswell Sell ticket with Same storage for lets say 30 min and after 30 min remove storage from player . and player again can buy Ticket for 30 min for xxxx items.
So player can bring items to npc to have 4eever storage or buy tickets to have storage for 30 min.

npc.lua
PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid)        end
function onCreatureDisappear(cid)        npcHandler:onCreatureDisappear(cid)        end
function onCreatureSay(cid, type, msg)        npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                npcHandler:onThink()                end

function AssassinFirst(cid, message, keywords, parameters, node)

    if(not npcHandler:isFocused(cid)) then
        return false
    end

  
        if getPlayerItemCount(cid,8309) >= 250 then
        if doPlayerRemoveItem(cid,8309,250) then
            npcHandler:say('You can now pass next floor!', cid)
            setPlayerStorageValue(cid,6211,1)
        end
        else
            npcHandler:say('You don\'t have 250 nails , you can get them at War Golems!', cid)
        end
    end

keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Bring me 250 nails from War golems, and bring them to me."})

local node = keywordHandler:addKeyword({'m'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you already collected 250 nails to pass next floor?'})
    node:addChildKeyword({'yes'}, AssassinFirst, {npcHandler = npcHandler, onlyFocus = true, reset = true})
    node:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got the neccessary items.', reset = true})
npcHandler:addModule(FocusModule:new())

npc.xml
PHP:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Alex" script="1floor.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100"/>
    <look type="326" head="110" body="133" legs="54" feet="45" addons="2"/>
    <parameters>
        <parameter key="message_greet" value="Hello |PLAYERNAME|, wanna make {mission} to pass next floor? Or do you need {help} ?"/>
    </parameters>
</npc>

Thanks in advance :)
 
Last edited:
I don't know how or why your using it. I can't justify an actual answer if the operation may be unnecessary.
But the way it's scripted, should cause little to no server strain, so it shouldn't be an issue.
well i got similart npc for 7 scripts so i use all 7 scripts same
as this

PHP:
local storage = 6211

local function tempStorage(cid)
    if not isPlayer(cid) then
        return true
    end

    if getPlayerStorageValue(cid, storage) > 1 then
        if getPlayerStorageValue(cid, storage) == 2 then
            setPlayerStorageValue(cid, storage, 0)
            return true
        else
            setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage) - 1)
        end
    end

    addEvent(tempStorage, 1000, cid)
end

function onLogin(cid)
    if getPlayerStorageValue(cid, storage) > 1 then
        addEvent(tempStorage, 1000, cid)
    end
    return true
end
but just change Storage id and all should be fine?
or i do need to change some things in script like
addEvent(tempStorage, 1000, cid) or antyhing else ?all other npc is similar just different ids of storage
 
Why is there an additional function to set a storage value in onlogin? that makes 0 sense.
All those checks, including the function are a waste of execution time... it is like you ran around the block just so you could move 2 feet from yourself.

I guess that is a troll script, coz it looks like an infinite loop.
 
Last edited:
Why is there an additional function to set a storage value in onlogin? that makes 0 sense.
All those checks, including the function are a waste of execution time... it is like you ran around the block just so you could move 2 feet from yourself.

I guess that is a troll script, coz it looks like an infinite loop.
you mean login script ? i guess Xikini knows what he is doing.
 
Why is there an additional function to set a storage value in onlogin? that makes 0 sense.
All those checks, including the function are a waste of execution time... it is like you ran around the block just so you could move 2 feet from yourself.

I guess that is a troll script, coz it looks like an infinite loop.
Really? Really?!
And you tell everyone else to learn to read the script before posting garbage. :rolleyes:
 
Your code for some odd reason loops a function to set a storage value to 0 which is retarded.. maybe someone needs to learn to code before telling other people who actually do know how to script, they need to learn how to script..
Code:
local storage = 6211

function onLogin(cid)

    if getPlayerStorageValue(cid, storage) > 1 then
        setPlayerStorageValue(cid, storage, 0)
    end
    return true
end

This is just plain dumb
Code:
local function tempStorage(cid)
    if not isPlayer(cid) then
        return true
    end
Well who is else logs into a game besides a player?
 
Your code for some odd reason loops a function to set a storage value to 0 which is retarded.. maybe someone needs to learn to code before telling other people who actually do know how to script, they need to learn how to script..
Code:
local storage = 6211

function onLogin(cid)

    if getPlayerStorageValue(cid, storage) > 1 then
        setPlayerStorageValue(cid, storage, 0)
    end
    return true
end

This is just plain dumb
Code:
local function tempStorage(cid)
    if not isPlayer(cid) then
        return true
    end
Well who is else logs into a game besides a player?
he sets the storage to 1801 to count down 1800 seconds..
 
Really fucking useless script.
Code:
local storage = 6211

local function tempStorage(cid)
    -- creatures and npc's don't login
    if not isPlayer(cid) then
        return true
    end

    -- you already checked this
    if getPlayerStorageValue(cid, storage) > 1 then
        -- what is the signifigance of checking for 2?
        if getPlayerStorageValue(cid, storage) == 2 then
            setPlayerStorageValue(cid, storage, 0)
            return true
        else
            setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage) - 1)
        end
    end
    -- call the function again for what purpose? so eventually the value of the storage becomes 0?
    addEvent(tempStorage, 1000, cid)
end

function onLogin(cid)
    if getPlayerStorageValue(cid, storage) > 1 then
        addEvent(tempStorage, 1000, cid)
    end
    return true
end
 
Really fucking useless script.
Code:
local storage = 6211

local function tempStorage(cid)
    -- creatures and npc's don't login
    if not isPlayer(cid) then
        return true
    end

    -- you already checked this
    if getPlayerStorageValue(cid, storage) > 1 then
        -- what is the signifigance of checking for 2?
        if getPlayerStorageValue(cid, storage) == 2 then
            setPlayerStorageValue(cid, storage, 0)
            return true
        else
            setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage) - 1)
        end
    end
    -- call the function again for what purpose? so eventually the value of the storage becomes 0?
    addEvent(tempStorage, 1000, cid)
end

function onLogin(cid)
    if getPlayerStorageValue(cid, storage) > 1 then
        addEvent(tempStorage, 1000, cid)
    end
    return true
end
loooool
I can't. I just can't. lmfao
I've been laughing at this post for over 20 minutes.
God damn Codex.
You've literally explained the script back to me, and still don't understand what's going on.
Either your trolling hard, or your not even trying to understand the script, or the reasons for each part of it.

NPC
Gives Storage '1' OR Storage '1801'
If storage of 1801 is given, also starts "function tempStorage(cid)"

Login script
If storage is higher then 1, start "function tempStorage(cid)"

Storage '1' = permanent storage value
Storage '1801' = temporary storage / aka: timed storage

Code:
local storage = 6211

local function tempStorage(cid)
    -- creatures and npc's don't login
    -- (Correct! However, if the player logs out, when the storage is checked against 'cid',)
    -- (cid will not be found and will throw an error. This checks if the player is still online.)
    if not isPlayer(cid) then
        return true
    end

    -- you already checked this (Yes, you are correct, this was an accidental addition. This can be removed.)
    if getPlayerStorageValue(cid, storage) > 1 then
        -- what is the signifigance of checking for 2? (So the 'permanent storage' is not affected.)
        if getPlayerStorageValue(cid, storage) == 2 then
            setPlayerStorageValue(cid, storage, 0)
            return true
        else
            setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage) - 1)
        end
    end

    -- call the function again for what purpose? so eventually the value of the storage becomes 0? (YES, exactly correct.)
    addEvent(tempStorage, 1000, cid)
end

function onLogin(cid)
    if getPlayerStorageValue(cid, storage) > 1 then
        addEvent(tempStorage, 1000, cid)
    end
    return true
end
 
Back
Top