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

TFS 1.X+ Is it possible to add storage to player on greeting npc?

gudan garam

Advanced OT User
Joined
Feb 13, 2011
Messages
353
Solutions
17
Reaction score
173
Location
São Paulo.
Is it possible to, when the player greets the npc, if x storage < 0, set x storage = 1?

I tought about doing it inside the "creatureSayCallback" on the npc script, but that would trigger it everytime the player says hi, not necessarily when the player is greeting the npc. (Even if he is already talking to the npc.)
 
Yes,
Lua:
keywordHandler:addGreetKeyword({'hi'}, {npcHandler = npcHandler, text = 'Greetings, |PLAYERNAME|! Seems you dont have valid storage'},
    local player = Player(cid)
  
    if player:getStorageValue(storage) <= 0 then
    player:setStorageValue(storage, 1)
    end
end
 
Yes,
Lua:
keywordHandler:addGreetKeyword({'hi'}, {npcHandler = npcHandler, text = 'Greetings, |PLAYERNAME|! Seems you dont have valid storage'},
    local player = Player(cid)
 
    if player:getStorageValue(storage) <= 0 then
    player:setStorageValue(storage, 1)
    end
end

Thank you for the answer.

But, that way, It would only happen if the player said hi, but the player can actually greet the npc by saying hello, and others words that i don't know. Thats the main point, I would like to set the storage on the greeting callback, because I don't know all the words a player can say to greet a npc.

Is that right?


-- EDIT:
I found a way to add an alias, like this:
Lua:
keywordHandler:addGreetKeyword({'hi'}, {npcHandler = npcHandler, text = 'Greetings, |PLAYERNAME|! Seems you dont have valid storage'},
    local player = Player(cid)

    if player:getStorageValue(storage) <= 0 then
    player:setStorageValue(storage, 1)
    end
end
keywordHandler:addAliasKeyword({'hello'})


-- EDIT2:
Actually, reading it with more than 5% of my brain, will this work?
Lua:
keywordHandler:addGreetKeyword({'hi', 'hello'}, {npcHandler = npcHandler, text = 'Greetings, |PLAYERNAME|! Seems you dont have valid storage'},
    local player = Player(cid)

    if player:getStorageValue(storage) <= 0 then
    player:setStorageValue(storage, 1)
    end
end
 
Lua:
function greetCallback(cid)
    local player = Player(cid)
    if player:getStorageValue(storage) == -1 then
        player:setStorageValue(storage, 1)
    end
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
 
Back
Top