[*]Author: Mock the bear
[*]Tested on: TFS 0.3.6
With this bank system you can do:
:thumbup:!bank [command] [amount]
- Withdraw
!bank withdraw 1000---
!bank w 1000
!withdraw 1000
!bank balance
- Balance
!bank b
!balance
!bank deposit 100
- Deposit
!bank d 100
!deposit 100
Or else:
!bank [cmd] all
!bank deposit all
!bank withdraw all
Add these tag on talkactions.xml
Code:
<talkaction words="!bank" event="script" value="bank.lua" />
<talkaction words="!withdraw" event="script" value="bank.lua" />
<talkaction words="!deposit" event="script" value="bank.lua" />
<talkaction words="!balance" event="script" value="bank.lua" />
Lua:
---Script by mock the bear
local storeige = 18316
local function msg(cid,m)
doCreatureSay(cid,m,TALKTYPE_ORANGE_1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, m)
end
function onSay(cid, words, param, channel) ---Script by mock the bear
local c = getPlayerStorageValue(cid,storeige)
c = c == -1 and 0 or c
if param:find('balance') or param == 'b' or (words == '!balance') then
msg(cid,'Account balance '..c..'')
elseif param:find('amount') or param == 'a' then
local c = getPlayerMoney(cid)
doCreatureSay(cid,'Account balance '..c..' gps.',TALKTYPE_ORANGE_1)
msg(cid,'Your account balance contains only '..c..' gps.')
elseif param:match('deposit (.+)') or param:match('d (.+)') or (words == '!deposit') then
local v = param:match('deposit (.+)') or param:match('d (.+)') or tonumber(param) or param == 'all' and param
local dep = tonumber(v == 'all' and getPlayerMoney(cid) or v)
if not dep then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Insert a value')
else
if getPlayerMoney(cid) >= dep then
setPlayerStorageValue(cid,storeige,c+dep)
doPlayerRemoveMoney(cid,dep)
msg(cid,'Deposit '..dep..'.')
else
msg(cid,'Your account balance contains only '..getPlayerMoney(cid)..'.')
end
end
elseif param:match('withdraw (.+)') or param:match('w (.+)') or (words == '!withdraw') then
local v = param:match('withdraw (.+)') or param:match('w (.+)') or tonumber(param) or param == 'all' and param
local dep = tonumber(v == 'all' and c or v)
if not dep then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Insert a value')
else
if c >= dep then
setPlayerStorageValue(cid,storeige,c-dep)
doPlayerAddMoney(cid,dep)
msg(cid,'Withdraw '..dep..'.')
else
msg(cid,'Your account balance contains only '..c..'.')
end
end
else
doPlayerSendTextMessage(cid, 25, "Use like this:\n!bank deposit x\n!bank balance\n!bank withdraw\n!bank amount(ou assim)\n!bank d x\n!bank w x\n!bank deposit all\n!bank a")
end
return TRUE
end