waqmaz
Member
- Joined
- Jun 17, 2015
- Messages
- 203
- Reaction score
- 11
I try to write a bank script on my own, but the only thing I do not know how to do is how to get a value from a variable that player has writed?
Here is the code:
The script doesn't see the money variable. It's nil even if i write "deposit 10".
Here is the code:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
local talkState = {}
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 creatureSayCallback(cid, type, msg) local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if not npcHandler:isFocused(cid) then
if msg == 'hi' then
npcHandler:addFocus(cid)
else
return false
end
else
money = tonumber(money) -- integer
money = math.abs(money)
if (msg == 'deposit '..money) then
if getPlayerMoney(cid) >= money then
selfSay('You have successfully deposited '..money..' gold points. Your account balance is '..getPlayerBalance(cid), cid)
end
end
if msgcontains(msg, 'bye') then
npcHandler:releaseFocus(cid)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
-- npcHandler:addModule(FocusModule:new())
The script doesn't see the money variable. It's nil even if i write "deposit 10".
Last edited: