StevenTrembly
New Member
- Joined
- Mar 17, 2016
- Messages
- 40
- Reaction score
- 4
Hello am looking for stable bank system against cash clone and cheaters and ofc stable
function onSay(player, words, param)
if words == "!deposit" then
t = string.split(param, ",")
amount = t[1]
if amount ~= "all" then
amount = tonumber(t[1])
if amount > 0 then
if player:removeMoney(amount) then
local old_balance = getPlayerBalance(player)
doPlayerSetBalance(player, getPlayerBalance(player) + amount)
doPlayerPopupFYI(player, "[old balance]: "..old_balance.."\n[new balance]: "..getPlayerBalance(player))
else
player:sendCancelMessage("You do not have this much gold.")
return false
end
end
else
player_gold = player:getMoney()
if player_gold > 0 then
local old_balance = getPlayerBalance(player)
player:removeMoney(player_gold)
doPlayerSetBalance(player, player_gold)
doPlayerPopupFYI(player, "[old balance]: "..old_balance.."\n[new balance]: "..getPlayerBalance(player))
else
player:sendCancelMessage("You do not have any gold to deposit.")
return false
end
end
elseif words == "!withdraw" then
t = string.split(param, ",")
amount = tonumber(t[1])
if amount <= 0 then
player:sendCancelMessage("You must type a number value to withdraw.")
return false
end
if amount > 100000000 then
player:sendCancelMessage("You cannot withdraw more then 100 million gold.")
return false
end
if getPlayerBalance(player) < amount then
player:sendCancelMessage("You do not have this much gold!")
return false
end
if doPlayerSetBalance(player, getPlayerBalance(player) - amount) then
player:addMoney(amount)
doPlayerPopupFYI(player, "[balance]: "..getPlayerBalance(player))
end
elseif words == "!balance" then
doPlayerPopupFYI(player, "[balance]: "..getPlayerBalance(player))
elseif words == "!transfer" then
t = string.split(param, ",")
target = Player(t[1])
amount = tonumber(t[2])
if not t[1] or not t[2] then
player:sendCancelMessage("Type: !transfer player, amount")
return false
end
if not target then
player:sendCancelMessage("Player must be online.")
return false
end
if target:getName() == player:getName() then
player:sendCancelMessage("You cannot tranfer gold to yourself.")
return false
end
if amount <= 0 then
player:sendCancelMessage("You must transfer 1 or more gold.")
return false
end
if getPlayerBalance(player) < amount then
player:sendCancelMessage("You do not have this much gold.")
return false
end
doPlayerSetBalance(player, getPlayerBalance(player) - amount)
doPlayerSetBalance(target, getPlayerBalance(target) + amount)
doPlayerPopupFYI(player, "You have added gold to his balance.")
end
return false
end
<talkaction words="!deposit" separator=" " script="banking.lua" />
<talkaction words="!withdraw" separator=" " script="banking.lua" />
<talkaction words="!balance" separator=" " script="banking.lua" />
<talkaction words="!transfer" separator=" " script="banking.lua" />
I am using it and it is all okay! Thank you! I'm using TFS 1.2.in talkactions/scripts
Code:function onSay(player, words, param) if words == "!deposit" then t = string.split(param, ",") amount = t[1] if amount ~= "all" then amount = tonumber(t[1]) if amount > 0 then if player:removeMoney(amount) then local old_balance = getPlayerBalance(player) doPlayerSetBalance(player, getPlayerBalance(player) + amount) doPlayerPopupFYI(player, "[old balance]: "..old_balance.."\n[new balance]: "..getPlayerBalance(player)) else player:sendCancelMessage("You do not have this much gold.") return false end end else player_gold = player:getMoney() if player_gold > 0 then local old_balance = getPlayerBalance(player) player:removeMoney(player_gold) doPlayerSetBalance(player, player_gold) doPlayerPopupFYI(player, "[old balance]: "..old_balance.."\n[new balance]: "..getPlayerBalance(player)) else player:sendCancelMessage("You do not have any gold to deposit.") return false end end elseif words == "!withdraw" then t = string.split(param, ",") amount = tonumber(t[1]) if amount <= 0 then player:sendCancelMessage("You must type a number value to withdraw.") return false end if amount > 100000000 then player:sendCancelMessage("You cannot withdraw more then 100 million gold.") return false end if getPlayerBalance(player) < amount then player:sendCancelMessage("You do not have this much gold!") return false end if doPlayerSetBalance(player, getPlayerBalance(player) - amount) then player:addMoney(amount) doPlayerPopupFYI(player, "[balance]: "..getPlayerBalance(player)) end elseif words == "!balance" then doPlayerPopupFYI(player, "[balance]: "..getPlayerBalance(player)) elseif words == "!transfer" then t = string.split(param, ",") target = Player(t[1]) amount = tonumber(t[2]) if not t[1] or not t[2] then player:sendCancelMessage("Type: !transfer player, amount") return false end if not target then player:sendCancelMessage("Player must be online.") return false end if target:getName() == player:getName() then player:sendCancelMessage("You cannot tranfer gold to yourself.") return false end if amount <= 0 then player:sendCancelMessage("You must transfer 1 or more gold.") return false end if getPlayerBalance(player) < amount then player:sendCancelMessage("You do not have this much gold.") return false end doPlayerSetBalance(player, getPlayerBalance(player) - amount) doPlayerSetBalance(target, getPlayerBalance(target) + amount) doPlayerPopupFYI(player, "You have added gold to his balance.") end return false end
in talkactions.xml
Code:<talkaction words="!deposit" separator=" " script="banking.lua" /> <talkaction words="!withdraw" separator=" " script="banking.lua" /> <talkaction words="!balance" separator=" " script="banking.lua" /> <talkaction words="!transfer" separator=" " script="banking.lua" />
I have tested this system and it has this error:in talkactions/scripts
Code:function onSay(player, words, param) if words == "!deposit" then t = string.split(param, ",") amount = t[1] if amount ~= "all" then amount = tonumber(t[1]) if amount > 0 then if player:removeMoney(amount) then local old_balance = getPlayerBalance(player) doPlayerSetBalance(player, getPlayerBalance(player) + amount) doPlayerPopupFYI(player, "[old balance]: "..old_balance.."\n[new balance]: "..getPlayerBalance(player)) else player:sendCancelMessage("You do not have this much gold.") return false end end else player_gold = player:getMoney() if player_gold > 0 then local old_balance = getPlayerBalance(player) player:removeMoney(player_gold) doPlayerSetBalance(player, player_gold) doPlayerPopupFYI(player, "[old balance]: "..old_balance.."\n[new balance]: "..getPlayerBalance(player)) else player:sendCancelMessage("You do not have any gold to deposit.") return false end end elseif words == "!withdraw" then t = string.split(param, ",") amount = tonumber(t[1]) if amount <= 0 then player:sendCancelMessage("You must type a number value to withdraw.") return false end if amount > 100000000 then player:sendCancelMessage("You cannot withdraw more then 100 million gold.") return false end if getPlayerBalance(player) < amount then player:sendCancelMessage("You do not have this much gold!") return false end if doPlayerSetBalance(player, getPlayerBalance(player) - amount) then player:addMoney(amount) doPlayerPopupFYI(player, "[balance]: "..getPlayerBalance(player)) end elseif words == "!balance" then doPlayerPopupFYI(player, "[balance]: "..getPlayerBalance(player)) elseif words == "!transfer" then t = string.split(param, ",") target = Player(t[1]) amount = tonumber(t[2]) if not t[1] or not t[2] then player:sendCancelMessage("Type: !transfer player, amount") return false end if not target then player:sendCancelMessage("Player must be online.") return false end if target:getName() == player:getName() then player:sendCancelMessage("You cannot tranfer gold to yourself.") return false end if amount <= 0 then player:sendCancelMessage("You must transfer 1 or more gold.") return false end if getPlayerBalance(player) < amount then player:sendCancelMessage("You do not have this much gold.") return false end doPlayerSetBalance(player, getPlayerBalance(player) - amount) doPlayerSetBalance(target, getPlayerBalance(target) + amount) doPlayerPopupFYI(player, "You have added gold to his balance.") end return false end
in talkactions.xml
Code:<talkaction words="!deposit" separator=" " script="banking.lua" /> <talkaction words="!withdraw" separator=" " script="banking.lua" /> <talkaction words="!balance" separator=" " script="banking.lua" /> <talkaction words="!transfer" separator=" " script="banking.lua" />
function onSay(player, words, param)
if words == "!deposit" then
t = string.split(param, ",")
amount = t[1]
if amount ~= "all" then
amount = tonumber(t[1])
if amount > 0 then
if player:removeMoney(amount) then
local old_balance = getPlayerBalance(player)
doPlayerSetBalance(player, old_balance + amount)
doPlayerPopupFYI(player, "[Previous balance]: "..old_balance.."\n[Actual balance]: "..getPlayerBalance(player))
else
player:sendCancelMessage("You do not have this much gold.")
return false
end
end
else
player_gold = player:getMoney()
if player_gold > 0 then
local old_balance = getPlayerBalance(player)
player:removeMoney(player_gold)
doPlayerSetBalance(player, old_balance + player_gold)
doPlayerPopupFYI(player, "[Previous balance]: "..old_balance.."\n[Actual balance]: "..getPlayerBalance(player))
else
player:sendCancelMessage("You do not have any gold to deposit.")
return false
end
end
elseif words == "!withdraw" then
t = string.split(param, ",")
amount = t[1]
if amount ~= "all" then
amount = tonumber(t[1])
if amount <= 0 then
player:sendCancelMessage("You must type a valid value to withdraw.")
return false
end
if amount > 100000000 then
player:sendCancelMessage("You cannot withdraw more then 100 million gold.")
return false
end
if getPlayerBalance(player) < amount then
player:sendCancelMessage("You do not have this much gold!")
return false
end
if doPlayerSetBalance(player, getPlayerBalance(player) - amount) then
player:addMoney(amount)
doPlayerPopupFYI(player, "[Balance]: "..getPlayerBalance(player))
end
else
local balance = getPlayerBalance(player)
if balance > 0 then
local old_balance = getPlayerBalance(player)
if doPlayerSetBalance(player, getPlayerBalance(player) - balance) then
player:addMoney(balance)
doPlayerPopupFYI(player, "[Previous balance]: "..old_balance.."\n[Actual balance]: "..getPlayerBalance(player))
end
else
player:sendCancelMessage("You do not have gold to withraw!")
end
end
elseif words == "!balance" then
doPlayerPopupFYI(player, "[Balance]: "..getPlayerBalance(player))
elseif words == "!transfer" then
t = string.split(param, ",")
target = Player(t[1])
amount = tonumber(t[2])
if not t[1] or not t[2] then
player:sendCancelMessage("You must type like: !transfer player, amount")
return false
end
if not target then
player:sendCancelMessage("Player must be online.")
return false
end
if target:getName() == player:getName() then
player:sendCancelMessage("You cannot transfer gold to yourself.")
return false
end
if amount <= 0 then
player:sendCancelMessage("You must transfer 1 or more gold.")
return false
end
if getPlayerBalance(player) < amount then
player:sendCancelMessage("You do not have this much gold.")
return false
end
doPlayerSetBalance(player, getPlayerBalance(player) - amount)
doPlayerSetBalance(target, getPlayerBalance(target) + amount)
doPlayerPopupFYI(player, "You transfered: "..amount.." gold to this player!")
end
return false
end