• 01-04.05.2026 - DOUBLE EXP / SKILL EVENT!

Skrypty & Kody Balance, guild skrypt.

Mr ImaGu?

Advanced User
Zarejestrowany
Dołączył
Grudzień 13, 2014
Posty
289
Liczba reakcji
10
Siema, ot?rz ten oto skrypt:

local function isValidMoney(value)
if(value == nil) then
return false
end

return (value > 0 and value <= 99999999999999)
end

function onSay(cid, words, param, channel)
local guild = getPlayerGuildId(cid)
if(guild == 0) then
return false
end

local t = string.explode(param, ' ', 1)
if(getPlayerGuildLevel(cid) == GUILDLEVEL_LEADER and isInArray({ 'pick' }, t[1])) then
if(t[1] == 'pick') then
local money = { tonumber(t[2]) }
if(not isValidMoney(money[1])) then
doPlayerSendChannelMessage(cid, '', 'Invalid amount of money specified.', TALKTYPE_CHANNEL_HIGHLIGHT, CHANNEL_GUILD)
return true
end

local result = db.getResult('SELECT `balance` FROM `guilds` WHERE `id` = ' .. guild)
if(result:getID() == -1) then
return false
end

money[2] = result:getDataLong('balance')
result:free()

if(money[1] > money[2]) then
doPlayerSendChannelMessage(cid, '', 'The balance is too low for such amount.', TALKTYPE_CHANNEL_HIGHLIGHT, CHANNEL_GUILD)
return true
end

if(not db.executeQuery('UPDATE `guilds` SET `balance` = `balance` - ' .. money[1] .. ' WHERE `id` = ' .. guild .. ' LIMIT 1;')) then
return false
end

doPlayerAddMoney(cid, money[1])
doPlayerSendChannelMessage(cid, '', 'You have just picked ' .. money[1] .. ' money from your guild balance.', TALKTYPE_CHANNEL_HIGHLIGHT, CHANNEL_GUILD)
else
doPlayerSendChannelMessage(cid, '', 'Invalid sub-command.', TALKTYPE_CHANNEL_HIGHLIGHT, CHANNEL_GUILD)
end
elseif(t[1] == 'donate') then
local money = tonumber(t[2])
if(not isValidMoney(money)) then
doPlayerSendChannelMessage(cid, '', 'Invalid amount of money specified.', TALKTYPE_CHANNEL_HIGHLIGHT, CHANNEL_GUILD)
return true
end

if(getPlayerMoney(cid) < money) then
doPlayerSendChannelMessage(cid, '', 'You don\'t have enough money.', TALKTYPE_CHANNEL_HIGHLIGHT, CHANNEL_GUILD)
return true
end

if(not doPlayerRemoveMoney(cid, money)) then
return false
end

db.executeQuery('UPDATE `guilds` SET `balance` = `balance` + ' .. money .. ' WHERE `id` = ' .. guild .. ' LIMIT 1;')
doPlayerSendChannelMessage(cid, '', 'You have transfered ' .. money .. ' money to your guild balance.', TALKTYPE_CHANNEL_HIGHLIGHT, CHANNEL_GUILD)
else
local result = db.getResult('SELECT `name`, `balance` FROM `guilds` WHERE `id` = ' .. guild)
if(result:getID() == -1) then
return false
end

doPlayerSendChannelMessage(cid, '', 'Current balance of guild ' .. result:getDataString('name') .. ' is: ' .. result:getDataLong('balance') .. ' bronze coins.', TALKTYPE_CHANNEL_HIGHLIGHT, CHANNEL_GUILD)
result:free()
end

return true
end


nie dzia?a poprawnie.

W grze po wp?aceniu hajsu poprzez komend? /balance deposit pisze, ?e przela?em hajs na konto gildi jednak po sprawdzeniu stanu konta /balance mamy 0 i nie mog? op?aci? waru.
Server robi? dla siebie i znajomych, jednak zaciekawi? mnie ten skrypt dlaczego nie dzia?a.

Logi z gry:
01:24 You have transfered 100 money to your guild balance.
01:24 Current balance of guild Support Team is: 0 bronze coins.
01:25 The balance is too low for such amount.

---------- Tre?? dodana o 08:03 ----------

/balance donate nie deposit*
 
Odp: Balance, guild skrypt.

Czy wyskakuje Ci jaki? b??d w konsoli?
Ot?RZ ta informacja mo?e by? rozwi?zaniem.
 
Back
Do góry