Hello, here is other of my script.. a bank system. (tested in TFS v0.3.1 and v0.3.3)
Features
- Balance -
Create a file called balance.lua and put there:
- Deposit -
Create a file called deposit.lua and put there:
- Deposit All -
Create a file called deposit_all.lua and put there:
- Withdraw -
Create a file called withdraw.lua and put there:
- Withdraw All -
Create a file called withdraw_all.lua and put there:
- Transfer -
Create a file called transfer.lua and put there:
- Transfer All -
Create a file called transfer_all.lua and put there:
Now, put this in your talkaction.xml:
Features
- You can see your account balance.
- Deposit money on your account balance.
- Deposit all money that you have in your backpack.
- Withdraw money from your account balance.
- Withdraw all your money from your account balance.
- Possibility to transfer money.
- Possibility to transfer all your money.
- !balance
- !deposit [money]
- !depositall
- !withdraw [money]
- !withdrawall
- !transfer [player], [money]
- !transferall [player]
- [04/04/09] - Fixed bug with negative values (Thanks Slawkens)
- [05/04/09] - Fixed text showed in screen (Ex: Darkhaos[100]: !balance)
- [07/04/09] - Bank System only can be used if this one confirmed in config.lua (bankSystem = "yes")
- [07/04/09] - If is player have battle, can't use the bank (CONDITION_INFIGHT)
- Balance -
Create a file called balance.lua and put there:
Lua:
function onSay(cid, words, param)
local config = {
bankSystemEnabled = getBooleanFromString(getConfigInfo('bankSystem')),
playerIsFighting = hasCondition(cid, CONDITION_INFIGHT)
}
if config.bankSystemEnabled == TRUE then
if config.playerIsFighting == FALSE then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your account balance is " .. getPlayerBalance(cid) .. ".")
return TRUE
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Bank can not be used in fight.")
return TRUE
end
else
return FALSE
end
end
- Deposit -
Create a file called deposit.lua and put there:
Lua:
function onSay(cid, words, param)
local config = {
bankSystemEnabled = getBooleanFromString(getConfigInfo('bankSystem')),
playerIsFighting = hasCondition(cid, CONDITION_INFIGHT)
}
if config.bankSystemEnabled == TRUE then
if config.playerIsFighting == FALSE then
if(param == "") then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Command requires param.")
return TRUE
end
local m = tonumber(param)
if(not m) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Command requires numeric param.")
return TRUE
end
m = math.abs(m)
if m <= getPlayerMoney(cid) then
doPlayerDepositMoney(cid, m)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Alright, you have added the amount of " .. m .. " gold to your balance. You can withdraw your money anytime you want to. Your account balance is " .. getPlayerBalance(cid) .. ".")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You do not have enough money.")
end
return TRUE
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Bank can not be used in fight.")
return TRUE
end
else
return FALSE
end
end
- Deposit All -
Create a file called deposit_all.lua and put there:
Lua:
function onSay(cid, words, param)
local config = {
bankSystemEnabled = getBooleanFromString(getConfigInfo('bankSystem')),
playerIsFighting = hasCondition(cid, CONDITION_INFIGHT)
}
if config.bankSystemEnabled == TRUE then
if config.playerIsFighting == FALSE then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Alright, you have added the amount of " .. getPlayerMoney(cid) .. " gold to your balance. You can withdraw your money anytime you want to.")
doPlayerDepositAllMoney(cid)
return TRUE
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Bank can not be used in fight.")
return TRUE
end
else
return FALSE
end
end
- Withdraw -
Create a file called withdraw.lua and put there:
Lua:
function onSay(cid, words, param)
local config = {
bankSystemEnabled = getBooleanFromString(getConfigInfo('bankSystem')),
playerIsFighting = hasCondition(cid, CONDITION_INFIGHT)
}
if config.bankSystemEnabled == TRUE then
if config.playerIsFighting == FALSE then
local m = tonumber(param)
if(param == "") then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Command requires param.")
return TRUE
end
if(not m) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Command requires numeric param.")
return TRUE
end
m = math.abs(m)
if m <= getPlayerBalance(cid) then
doPlayerWithdrawMoney(cid, m)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Here you are, " .. m .. " gold. Your account balance is " .. getPlayerBalance(cid) .. ".")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "There is not enough gold on your account.")
end
return TRUE
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Bank can not be used in fight.")
return TRUE
end
else
return FALSE
end
end
- Withdraw All -
Create a file called withdraw_all.lua and put there:
Lua:
function onSay(cid, words, param)
local config = {
bankSystemEnabled = getBooleanFromString(getConfigInfo('bankSystem')),
playerIsFighting = hasCondition(cid, CONDITION_INFIGHT)
}
if config.bankSystemEnabled == TRUE then
if config.playerIsFighting == FALSE then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Here you are, " .. getPlayerBalance(cid) .. " gold.")
doPlayerWithdrawAllMoney(cid)
return TRUE
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Bank can not be used in fight.")
return TRUE
end
else
return FALSE
end
end
- Transfer -
Create a file called transfer.lua and put there:
Lua:
function onSay(cid, words, param)
local config = {
bankSystemEnabled = getBooleanFromString(getConfigInfo('bankSystem')),
playerIsFighting = hasCondition(cid, CONDITION_INFIGHT)
}
if config.bankSystemEnabled == TRUE then
if config.playerIsFighting == FALSE then
if(param == "") then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Command requires param.")
return TRUE
end
local t = string.explode(param, ",")
local m = tonumber(t[2])
local tmp = string.explode(t[2], ",")
if(not m) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "No money specified.")
return TRUE
end
m = math.abs(m)
if m <= getPlayerBalance(cid) then
if playerExists(t[1]) then
doPlayerTransferMoneyTo(cid, t[1], m)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have transferred " .. m .. " gold to " .. t[1] .. ". Your account balance is " .. getPlayerBalance(cid) .. " gold.")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Player " .. t[1] .. " does not exist.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "There is not enough gold on your account. Your account balance is " .. getPlayerBalance(cid) .. ". Please tell the amount of gold coins you would like to transfer.")
end
return TRUE
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Bank can not be used in fight.")
return TRUE
end
else
return FALSE
end
end
- Transfer All -
Create a file called transfer_all.lua and put there:
Lua:
function onSay(cid, words, param)
local config = {
bankSystemEnabled = getBooleanFromString(getConfigInfo('bankSystem')),
playerIsFighting = hasCondition(cid, CONDITION_INFIGHT)
}
if config.bankSystemEnabled == TRUE then
if config.playerIsFighting == TRUE then
if(param == "") then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Command requires param.")
return TRUE
end
local t = string.explode(param, ",")
if playerExists(param) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have transferred " .. getPlayerBalance(cid) .. " gold to " .. param .. ".")
doPlayerTransferAllMoneyTo(cid, param)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Player " .. param .. " does not exist.")
end
return TRUE
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Bank can not be used in fight.")
return TRUE
end
else
return FALSE
end
end
Now, put this in your talkaction.xml:
XML:
<talkaction log="yes" words="!balance" script="balance.lua" />
<talkaction log="yes" words="!deposit" script="deposit.lua" />
<talkaction log="yes" words="!withdraw" script="withdraw.lua" />
<talkaction log="yes" words="!transfer" script="transfer.lua" />
<talkaction log="yes" words="!depositall" script="deposit_all.lua" />
<talkaction log="yes" words="!withdrawall" script="withdraw_all.lua" />
<talkaction log="yes" words="!transferall" script="transfer_all.lua" />
Last edited by a moderator: