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

[Error - TalkAction Interface]

Cracudoo

New Member
Joined
Jan 22, 2017
Messages
32
Reaction score
0
[Error - TalkAction Interface] data/talkactions/scripts/withdraw.lua:eek:nSay Description: data/talkactions/scripts/withdraw.lua:9: attempt to compare string with number stack traceback: data/talkactions/scripts/withdraw.lua:9: in function

script.lua
Code:
function onSay(cid, words, param)
   if getPlayerTown(cid) == 24 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You cannot withdraw money being in Rookgaard.")
        return
    end
    
    if isPlayer(cid) == TRUE and param ~= "" then
        if getTilePzInfo(getPlayerPosition(cid)) == TRUE then
                if getPlayerBalance(cid) >= param then       
                    doPlayerSetBalance(cid, getPlayerBalance(cid) - param)
                    doPlayerAddMoney(cid, param)
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Here you are, ".. param .." gold.")
                else
                    doPlayerSendCancel(cid, "You do not have enough money.")
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                end
        else
            doPlayerSendCancel(cid, "You can only use this command in PZ.")
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
        end
    end
end
 
Try this.
Code:
function onSay(cid, words, param)
   if getPlayerTown(cid) == 24 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You cannot withdraw money being in Rookgaard.")
        return
    end

    if isPlayer(cid) == TRUE and param ~= nil then
        if getTilePzInfo(getPlayerPosition(cid)) == TRUE then
           param = tonumber(param)
            if getPlayerBalance(cid) >= param then       
                doPlayerSetBalance(cid, getPlayerBalance(cid) - param)
                doPlayerAddMoney(cid, param)
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Here you are, ".. param .." gold.")
            else
                doPlayerSendCancel(cid, "You do not have enough money.")
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
            end
        else
            doPlayerSendCancel(cid, "You can only use this command in PZ.")
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
        end
    end
end
 
Last edited:
You'll probably want to confirm that param is actually a number, or you'll get another error.
Like if a player wrote
/withdraw asdsad
instead of
/withdraw 500
You'd get an error.

Just a minor thing.

Code:
function onSay(cid, words, param)

   if getPlayerTown(cid) == 24 then
       doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You cannot withdraw money while being in Rookgaard.")
       return true
   end
 
   if isPlayer(cid) == TRUE and param ~= nil then
       if getTilePzInfo(getPlayerPosition(cid)) == TRUE then
           if tonumber(param) ~= nil then
               param = tonumber(param)         
               if getPlayerBalance(cid) >= param then 
                   doPlayerSetBalance(cid, getPlayerBalance(cid) - param)
                   doPlayerAddMoney(cid, param)
                   doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Here you are, ".. param .." gold.")
               else
                   doPlayerSendCancel(cid, "You do not have enough money.")
                   doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
               end
           else
               doPlayerSendCancel(cid, "" .. param .. " is not a known currency value. Use numbers only. -> ex: 5000")
               doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
           end
       else
           doPlayerSendCancel(cid, "You may only use this command while in a protection zone.")
           doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
       end
   end

   return true
end
 
Back
Top