Ir para conteúdo

guild system erro talckactions


sk8sk8ter

Posts Recomendados

to com um erro aki q ja fiz de tuod mais não deu pra arrumar bom o erro é esse da imagem e meu war.lua vo posta tbm

post-381868-0-00285700-1440370143_thumb.png

 

 

function onSay(cid, words, param, channel)
local guild = getPlayerGuildId(cid)
if(not guild or getPlayerGuildLevel(cid) < GUILDLEVEL_LEADER) then
doPlayerSendChannelMessage(cid, "", "You cannot execute this talkaction.", TALKTYPE_CHANNEL_W, 0)
return true
end

local t = string.explode(param, ",")
if(not t[2]) then
doPlayerSendChannelMessage(cid, "", "Not enough param(s).", TALKTYPE_CHANNEL_W, 0)
return true
end

local enemy = getGuildId(t[2])
if(not enemy) then
doPlayerSendChannelMessage(cid, "", "Guild \"" .. t[2] .. "\" does not exists.", TALKTYPE_CHANNEL_W, 0)
return true
end

if(enemy == guild) then
doPlayerSendChannelMessage(cid, "", "You cannot perform war action on your own guild.", TALKTYPE_CHANNEL_W, 0)
return true
end

local enemyName, tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
if(tmp:getID() ~= -1) then
enemyName = tmp:getDataString("name")
tmp:free()
end

if(isInArray({"accept", "reject", "cancel"}, t[1])) then
local query = "`guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild
if(t[1] == "cancel") then
query = "`guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy
end

tmp = db.getResult("SELECT `id`, `begin`, `end`, `payment` FROM `guild_wars` WHERE " .. query .. " AND `status` = 0")
if(tmp:getID() == -1) then
doPlayerSendChannelMessage(cid, "", "Currently there's no pending invitation for a war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end

if(t[1] == "accept") then
local _tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)
local state = _tmp:getID() < 0 or _tmp:getDataInt("balance") < tmp:getDataInt("payment")

_tmp:free()
if(state) then
doPlayerSendChannelMessage(cid, "", "Your guild balance is too low to accept this invitation.", TALKTYPE_CHANNEL_W, 0)
return true
end

db.query("UPDATE `guilds` SET `balance` = `balance` - " .. tmp:getDataInt("payment") .. " WHERE `id` = " .. guild)
end

query = "UPDATE `guild_wars` SET "
local msg = "accepted " .. enemyName .. " invitation to war."
if(t[1] == "reject") then
query = query .. "`end` = " .. os.time() .. ", `status` = 2"
msg = "rejected " .. enemyName .. " invitation to war."
elseif(t[1] == "cancel") then
query = query .. "`end` = " .. os.time() .. ", `status` = 3"
msg = "canceled invitation to a war with " .. enemyName .. "."
else
query = query .. "`begin` = " .. os.time() .. ", `end` = " .. (tmp:getDataInt("end") > 0 and (os.time() + ((tmp:getDataInt("begin") - tmp:getDataInt("end")) / 86400)) or 0) .. ", `status` = 1"
end

query = query .. " WHERE `id` = " .. tmp:getDataInt("id")
if(t[1] == "accept") then
doGuildAddEnemy(guild, enemy, tmp:getDataInt("id"), WAR_GUILD)
doGuildAddEnemy(enemy, guild, tmp:getDataInt("id"), WAR_ENEMY)
end

tmp:free()
db.query(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. msg, MESSAGE_EVENT_ADVANCE)
return true
end

if(t[1] == "invite") then
local str = ""
tmp = db.getResult("SELECT `guild_id`, `status` FROM `guild_wars` WHERE `guild_id` IN (" .. guild .. "," .. enemy .. ") AND `enemy_id` IN (" .. enemy .. "," .. guild .. ") AND `status` IN (0, 1)")
if(tmp:getID() ~= -1) then
if(tmp:getDataInt("status") == 0) then
if(tmp:getDataInt("guild_id") == guild) then
str = "You have already invited " .. enemyName .. " to war."
else
str = enemyName .. " have already invited you to war."
end
else
str = "You are already on a war with " .. enemyName .. "."
end

tmp:free()
end

if(str ~= "") then
doPlayerSendChannelMessage(cid, "", str, TALKTYPE_CHANNEL_W, 0)
return true
end

local frags = tonumber(t[3])
if(frags ~= nil) then
frags = math.max(10, math.min(1000, frags))
else
frags = 100
end

local payment = tonumber(t[4])
if(payment ~= nil) then
payment = math.max(100000, math.min(1000000000, payment))
tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)

local state = tmp:getID() < 0 or tmp:getDataInt("balance") < payment
tmp:free()
if(state) then
doPlayerSendChannelMessage(cid, "", "Your guild balance is too low for such payment.", TALKTYPE_CHANNEL_W, 0)
return true
end

db.query("UPDATE `guilds` SET `balance` = `balance` - " .. payment .. " WHERE `id` = " .. guild)
else
payment = 0
end

local begining, ending = os.time(), tonumber(t[5])
if(ending ~= nil and ending ~= 0) then
ending = begining + (ending * 86400)
else
ending = 0
end

db.query("INSERT INTO `guild_wars` (`guild_id`, `enemy_id`, `begin`, `end`, `frags`, `payment`) VALUES (" .. guild .. ", " .. enemy .. ", " .. begining .. ", " .. ending .. ", " .. frags .. ", " .. payment .. ");")
doBroadcastMessage(getPlayerGuildName(cid) .. " has invited " .. enemyName .. " to war till " .. frags .. " frags.", MESSAGE_EVENT_ADVANCE)
return true
end

if(not isInArray({"end", "finish"}, t[1])) then
return false
end

local status = (t[1] == "end" and 1 or 4)
tmp = db.getResult("SELECT `id` FROM `guild_wars` WHERE `guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy .. " AND `status` = " .. status)
if(tmp:getID() ~= -1) then
local query = "UPDATE `guild_wars` SET `end` = " .. os.time() .. ", `status` = 5 WHERE `id` = " .. tmp:getDataInt("id")
tmp:free()
doGuildRemoveEnemy(guild, enemy)
doGuildRemoveEnemy(enemy, guild)

db.query(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. (status == 4 and "mend fences" or "ended up a war") .. " with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
return true
end

if(status == 4) then
doPlayerSendChannelMessage(cid, "", "Currently there's no pending war truce from " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end

tmp = db.getResult("SELECT `id`, `end` FROM `guild_wars` WHERE `guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild .. " AND `status` = 1")
if(tmp:getID() ~= -1) then
if(tmp:getDataInt("end") > 0) then
tmp:free()
doPlayerSendChannelMessage(cid, "", "You cannot request ending for war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end

local query = "UPDATE `guild_wars` SET `status` = 4, `end` = " .. os.time() .. " WHERE `id` = " .. tmp:getDataInt("id")
tmp:free()

db.query(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has signed an armstice declaration on a war with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
return true
end

doPlayerSendChannelMessage(cid, "", "Currently there's no active war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end


balance.lua

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_W, 0)
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_W, 0)
return true
end

if(not db.query('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_W, 0)
else
doPlayerSendChannelMessage(cid, '', 'Invalid sub-command.', TALKTYPE_CHANNEL_W, 0)
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_W, 0)
return true
end

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

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

db.query('UPDATE `guilds` SET `balance` = `balance` + ' .. money .. ' WHERE `id` = ' .. guild .. ' LIMIT 1;')
doPlayerSendChannelMessage(cid, '', 'You have transfered ' .. money .. ' money to your guild balance.', TALKTYPE_CHANNEL_W, 0)
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_W, 0)
result:free()
end

return true
end

 

Link para o comentário
Compartilhar em outros sites

tente assim

 

 

 

function onSay(cid, words, param, channel)
local guild = getPlayerGuildId(cid)
if(not guild or getPlayerGuildLevel(cid) < GUILDLEVEL_LEADER) then
doPlayerSendChannelMessage(cid, "", "You cannot execute this talkaction.", TALKTYPE_CHANNEL_W, 0)
return true
end

local t = string.explode(param, ",")
if(not t[2]) then
doPlayerSendChannelMessage(cid, "", "Not enough param(s).", TALKTYPE_CHANNEL_W, 0)
return true
end

local enemy = getGuildId(t[2])
if(not enemy) then
doPlayerSendChannelMessage(cid, "", "Guild \"" .. t[2] .. "\" does not exists.", TALKTYPE_CHANNEL_W, 0)
return true
end

if(enemy == guild) then
doPlayerSendChannelMessage(cid, "", "You cannot perform war action on your own guild.", TALKTYPE_CHANNEL_W, 0)
return true
end

local enemyName, tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
if(tmp:getID() ~= -1) then
enemyName = tmp:getDataString("name")
tmp:free()
end

if(isInArray({"accept", "reject", "cancel"}, t[1])) then
local query = "`guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild
if(t[1] == "cancel") then
query = "`guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy
end

tmp = db.getResult("SELECT `id`, `begin`, `end`, `payment` FROM `guild_wars` WHERE " .. query .. " AND `status` = 0")
if(tmp:getID() == -1) then
doPlayerSendChannelMessage(cid, "", "Currently there's no pending invitation for a war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end

if(t[1] == "accept") then
local _tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)
local state = _tmp:getID() < 0 or _tmp:getDataInt("balance") < tmp:getDataInt("payment")

_tmp:free()
if(state) then
doPlayerSendChannelMessage(cid, "", "Your guild balance is too low to accept this invitation.", TALKTYPE_CHANNEL_W, 0)
return true
end

db.query("UPDATE `guilds` SET `balance` = `balance` - " .. tmp:getDataInt("payment") .. " WHERE `id` = " .. guild)
end

query = "UPDATE `guild_wars` SET "
local msg = "accepted " .. enemyName .. " invitation to war."
if(t[1] == "reject") then
query = query .. "`end` = " .. os.time() .. ", `status` = 2"
msg = "rejected " .. enemyName .. " invitation to war."
elseif(t[1] == "cancel") then
query = query .. "`end` = " .. os.time() .. ", `status` = 3"
msg = "canceled invitation to a war with " .. enemyName .. "."
else
query = query .. "`begin` = " .. os.time() .. ", `end` = " .. (tmp:getDataInt("end") > 0 and (os.time() + ((tmp:getDataInt("begin") - tmp:getDataInt("end")) / 86400)) or 0) .. ", `status` = 1"
end

tmp:free()
db.query(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. msg, MESSAGE_EVENT_ADVANCE)
return true
end

if(t[1] == "invite") then
local str = ""
tmp = db.getResult("SELECT `guild_id`, `status` FROM `guild_wars` WHERE `guild_id` IN (" .. guild .. "," .. enemy .. ") AND `enemy_id` IN (" .. enemy .. "," .. guild .. ") AND `status` IN (0, 1)")
if(tmp:getID() ~= -1) then
if(tmp:getDataInt("status") == 0) then
if(tmp:getDataInt("guild_id") == guild) then
str = "You have already invited " .. enemyName .. " to war."
else
str = enemyName .. " have already invited you to war."
end
else
str = "You are already on a war with " .. enemyName .. "."
end

tmp:free()
end

if(str ~= "") then
doPlayerSendChannelMessage(cid, "", str, TALKTYPE_CHANNEL_W, 0)
return true
end

local frags = tonumber(t[3])
if(frags ~= nil) then
frags = math.max(10, math.min(1000, frags))
else
frags = 100
end

local payment = tonumber(t[4])
if(payment ~= nil) then
payment = math.max(100000, math.min(1000000000, payment))
tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)

local state = tmp:getID() < 0 or tmp:getDataInt("balance") < payment
tmp:free()
if(state) then
doPlayerSendChannelMessage(cid, "", "Your guild balance is too low for such payment.", TALKTYPE_CHANNEL_W, 0)
return true
end

db.query("UPDATE `guilds` SET `balance` = `balance` - " .. payment .. " WHERE `id` = " .. guild)
else
payment = 0
end

local begining, ending = os.time(), tonumber(t[5])
if(ending ~= nil and ending ~= 0) then
ending = begining + (ending * 86400)
else
ending = 0
end

db.query("INSERT INTO `guild_wars` (`guild_id`, `enemy_id`, `begin`, `end`, `frags`, `payment`) VALUES (" .. guild .. ", " .. enemy .. ", " .. begining .. ", " .. ending .. ", " .. frags .. ", " .. payment .. ");")
doBroadcastMessage(getPlayerGuildName(cid) .. " has invited " .. enemyName .. " to war till " .. frags .. " frags.", MESSAGE_EVENT_ADVANCE)
return true
end

if(not isInArray({"end", "finish"}, t[1])) then
return false
end

local status = (t[1] == "end" and 1 or 4)
tmp = db.getResult("SELECT `id` FROM `guild_wars` WHERE `guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy .. " AND `status` = " .. status)
if(tmp:getID() ~= -1) then
local query = "UPDATE `guild_wars` SET `end` = " .. os.time() .. ", `status` = 5 WHERE `id` = " .. tmp:getDataInt("id")
tmp:free()
doGuildRemoveEnemy(guild, enemy)
doGuildRemoveEnemy(enemy, guild)

db.query(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. (status == 4 and "mend fences" or "ended up a war") .. " with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
return true
end

if(status == 4) then
doPlayerSendChannelMessage(cid, "", "Currently there's no pending war truce from " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end

tmp = db.getResult("SELECT `id`, `end` FROM `guild_wars` WHERE `guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild .. " AND `status` = 1")
if(tmp:getID() ~= -1) then
if(tmp:getDataInt("end") > 0) then
tmp:free()
doPlayerSendChannelMessage(cid, "", "You cannot request ending for war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end

local query = "UPDATE `guild_wars` SET `status` = 4, `end` = " .. os.time() .. " WHERE `id` = " .. tmp:getDataInt("id")
tmp:free()

db.query(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has signed an armstice declaration on a war with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
return true
end

doPlayerSendChannelMessage(cid, "", "Currently there's no active war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end

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_W, 0)
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_W, 0)
return true
end

if(not db.query('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_W, 0)
else
doPlayerSendChannelMessage(cid, '', 'Invalid sub-command.', TALKTYPE_CHANNEL_W, 0)
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_W, 0)
return true
end

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

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

db.query('UPDATE `guilds` SET `balance` = `balance` + ' .. money .. ' WHERE `id` = ' .. guild .. ' LIMIT 1;')
doPlayerSendChannelMessage(cid, '', 'You have transfered ' .. money .. ' money to your guild balance.', TALKTYPE_CHANNEL_W, 0)
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_W, 0)
result:free()
end

return true
end                                                 

 

 

 

se não for tente assim

 

 

 

function onSay(cid, words, param, channel)
local guild = getPlayerGuildId(cid)
if(not guild or getPlayerGuildLevel(cid) < GUILDLEVEL_LEADER) then
doPlayerSendChannelMessage(cid, "", "You cannot execute this talkaction.", TALKTYPE_CHANNEL_W, 0)
return true
end

local t = string.explode(param, ",")
if(not t[2]) then
doPlayerSendChannelMessage(cid, "", "Not enough param(s).", TALKTYPE_CHANNEL_W, 0)
return true
end

local enemy = getGuildId(t[2])
if(not enemy) then
doPlayerSendChannelMessage(cid, "", "Guild \"" .. t[2] .. "\" does not exists.", TALKTYPE_CHANNEL_W, 0)
return true
end

if(enemy == guild) then
doPlayerSendChannelMessage(cid, "", "You cannot perform war action on your own guild.", TALKTYPE_CHANNEL_W, 0)
return true
end

local enemyName, tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
if(tmp:getID() ~= -1) then
enemyName = tmp:getDataString("name")
tmp:free()
end

if(isInArray({"accept", "reject", "cancel"}, t[1])) then
local query = "`guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild
if(t[1] == "cancel") then
query = "`guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy
end

tmp = db.getResult("SELECT `id`, `begin`, `end`, `payment` FROM `guild_wars` WHERE " .. query .. " AND `status` = 0")
if(tmp:getID() == -1) then
doPlayerSendChannelMessage(cid, "", "Currently there's no pending invitation for a war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end

if(t[1] == "accept") then
local _tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)
local state = _tmp:getID() < 0 or _tmp:getDataInt("balance") < tmp:getDataInt("payment")

_tmp:free()
if(state) then
doPlayerSendChannelMessage(cid, "", "Your guild balance is too low to accept this invitation.", TALKTYPE_CHANNEL_W, 0)
return true
end

db.query("UPDATE `guilds` SET `balance` = `balance` - " .. tmp:getDataInt("payment") .. " WHERE `id` = " .. guild)
end

query = "UPDATE `guild_wars` SET "
local msg = "accepted " .. enemyName .. " invitation to war."
if(t[1] == "reject") then
query = query .. "`end` = " .. os.time() .. ", `status` = 2"
msg = "rejected " .. enemyName .. " invitation to war."
elseif(t[1] == "cancel") then
query = query .. "`end` = " .. os.time() .. ", `status` = 3"
msg = "canceled invitation to a war with " .. enemyName .. "."
else
query = query .. "`begin` = " .. os.time() .. ", `end` = " .. (tmp:getDataInt("end") > 0 and (os.time() + ((tmp:getDataInt("begin") - tmp:getDataInt("end")) / 86400)) or 0) .. ", `status` = 1"
end

if(t[1] == "accept") then
query = query .. " WHERE `id` = " .. tmp:getDataInt("id")
doGuildAddEnemy(guild, enemy, tmp:getDataInt("id"), WAR_GUILD)
doGuildAddEnemy(enemy, guild, tmp:getDataInt("id"), WAR_ENEMY)
end

tmp:free()
db.query(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. msg, MESSAGE_EVENT_ADVANCE)
return true
end

if(t[1] == "invite") then
local str = ""
tmp = db.getResult("SELECT `guild_id`, `status` FROM `guild_wars` WHERE `guild_id` IN (" .. guild .. "," .. enemy .. ") AND `enemy_id` IN (" .. enemy .. "," .. guild .. ") AND `status` IN (0, 1)")
if(tmp:getID() ~= -1) then
if(tmp:getDataInt("status") == 0) then
if(tmp:getDataInt("guild_id") == guild) then
str = "You have already invited " .. enemyName .. " to war."
else
str = enemyName .. " have already invited you to war."
end
else
str = "You are already on a war with " .. enemyName .. "."
end

tmp:free()
end

if(str ~= "") then
doPlayerSendChannelMessage(cid, "", str, TALKTYPE_CHANNEL_W, 0)
return true
end

local frags = tonumber(t[3])
if(frags ~= nil) then
frags = math.max(10, math.min(1000, frags))
else
frags = 100
end

local payment = tonumber(t[4])
if(payment ~= nil) then
payment = math.max(100000, math.min(1000000000, payment))
tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)

local state = tmp:getID() < 0 or tmp:getDataInt("balance") < payment
tmp:free()
if(state) then
doPlayerSendChannelMessage(cid, "", "Your guild balance is too low for such payment.", TALKTYPE_CHANNEL_W, 0)
return true
end

db.query("UPDATE `guilds` SET `balance` = `balance` - " .. payment .. " WHERE `id` = " .. guild)
else
payment = 0
end

local begining, ending = os.time(), tonumber(t[5])
if(ending ~= nil and ending ~= 0) then
ending = begining + (ending * 86400)
else
ending = 0
end

db.query("INSERT INTO `guild_wars` (`guild_id`, `enemy_id`, `begin`, `end`, `frags`, `payment`) VALUES (" .. guild .. ", " .. enemy .. ", " .. begining .. ", " .. ending .. ", " .. frags .. ", " .. payment .. ");")
doBroadcastMessage(getPlayerGuildName(cid) .. " has invited " .. enemyName .. " to war till " .. frags .. " frags.", MESSAGE_EVENT_ADVANCE)
return true
end

if(not isInArray({"end", "finish"}, t[1])) then
return false
end

local status = (t[1] == "end" and 1 or 4)
tmp = db.getResult("SELECT `id` FROM `guild_wars` WHERE `guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy .. " AND `status` = " .. status)
if(tmp:getID() ~= -1) then
local query = "UPDATE `guild_wars` SET `end` = " .. os.time() .. ", `status` = 5 WHERE `id` = " .. tmp:getDataInt("id")
tmp:free()
doGuildRemoveEnemy(guild, enemy)
doGuildRemoveEnemy(enemy, guild)

db.query(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. (status == 4 and "mend fences" or "ended up a war") .. " with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
return true
end

if(status == 4) then
doPlayerSendChannelMessage(cid, "", "Currently there's no pending war truce from " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end

tmp = db.getResult("SELECT `id`, `end` FROM `guild_wars` WHERE `guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild .. " AND `status` = 1")
if(tmp:getID() ~= -1) then
if(tmp:getDataInt("end") > 0) then
tmp:free()
doPlayerSendChannelMessage(cid, "", "You cannot request ending for war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end

local query = "UPDATE `guild_wars` SET `status` = 4, `end` = " .. os.time() .. " WHERE `id` = " .. tmp:getDataInt("id")
tmp:free()

db.query(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has signed an armstice declaration on a war with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
return true
end

doPlayerSendChannelMessage(cid, "", "Currently there's no active war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end

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_W, 0)
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_W, 0)
return true
end

if(not db.query('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_W, 0)
else
doPlayerSendChannelMessage(cid, '', 'Invalid sub-command.', TALKTYPE_CHANNEL_W, 0)
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_W, 0)
return true
end

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

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

db.query('UPDATE `guilds` SET `balance` = `balance` + ' .. money .. ' WHERE `id` = ' .. guild .. ' LIMIT 1;')
doPlayerSendChannelMessage(cid, '', 'You have transfered ' .. money .. ' money to your guild balance.', TALKTYPE_CHANNEL_W, 0)
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_W, 0)
result:free()
end

return true
end

 

 

 

 

Link para o comentário
Compartilhar em outros sites

tente assim

 

 

 

function onSay(cid, words, param, channel)
local guild = getPlayerGuildId(cid)
if(not guild or getPlayerGuildLevel(cid) < GUILDLEVEL_LEADER) then
doPlayerSendChannelMessage(cid, "", "You cannot execute this talkaction.", TALKTYPE_CHANNEL_W, 0)
return true
end

local t = string.explode(param, ",")
if(not t[2]) then
doPlayerSendChannelMessage(cid, "", "Not enough param(s).", TALKTYPE_CHANNEL_W, 0)
return true
end

local enemy = getGuildId(t[2])
if(not enemy) then
doPlayerSendChannelMessage(cid, "", "Guild \"" .. t[2] .. "\" does not exists.", TALKTYPE_CHANNEL_W, 0)
return true
end

if(enemy == guild) then
doPlayerSendChannelMessage(cid, "", "You cannot perform war action on your own guild.", TALKTYPE_CHANNEL_W, 0)
return true
end

local enemyName, tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
if(tmp:getID() ~= -1) then
enemyName = tmp:getDataString("name")
tmp:free()
end

if(isInArray({"accept", "reject", "cancel"}, t[1])) then
local query = "`guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild
if(t[1] == "cancel") then
query = "`guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy
end

tmp = db.getResult("SELECT `id`, `begin`, `end`, `payment` FROM `guild_wars` WHERE " .. query .. " AND `status` = 0")
if(tmp:getID() == -1) then
doPlayerSendChannelMessage(cid, "", "Currently there's no pending invitation for a war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end

if(t[1] == "accept") then
local _tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)
local state = _tmp:getID() < 0 or _tmp:getDataInt("balance") < tmp:getDataInt("payment")

_tmp:free()
if(state) then
doPlayerSendChannelMessage(cid, "", "Your guild balance is too low to accept this invitation.", TALKTYPE_CHANNEL_W, 0)
return true
end

db.query("UPDATE `guilds` SET `balance` = `balance` - " .. tmp:getDataInt("payment") .. " WHERE `id` = " .. guild)
end

query = "UPDATE `guild_wars` SET "
local msg = "accepted " .. enemyName .. " invitation to war."
if(t[1] == "reject") then
query = query .. "`end` = " .. os.time() .. ", `status` = 2"
msg = "rejected " .. enemyName .. " invitation to war."
elseif(t[1] == "cancel") then
query = query .. "`end` = " .. os.time() .. ", `status` = 3"
msg = "canceled invitation to a war with " .. enemyName .. "."
else
query = query .. "`begin` = " .. os.time() .. ", `end` = " .. (tmp:getDataInt("end") > 0 and (os.time() + ((tmp:getDataInt("begin") - tmp:getDataInt("end")) / 86400)) or 0) .. ", `status` = 1"
end

tmp:free()
db.query(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. msg, MESSAGE_EVENT_ADVANCE)
return true
end

if(t[1] == "invite") then
local str = ""
tmp = db.getResult("SELECT `guild_id`, `status` FROM `guild_wars` WHERE `guild_id` IN (" .. guild .. "," .. enemy .. ") AND `enemy_id` IN (" .. enemy .. "," .. guild .. ") AND `status` IN (0, 1)")
if(tmp:getID() ~= -1) then
if(tmp:getDataInt("status") == 0) then
if(tmp:getDataInt("guild_id") == guild) then
str = "You have already invited " .. enemyName .. " to war."
else
str = enemyName .. " have already invited you to war."
end
else
str = "You are already on a war with " .. enemyName .. "."
end

tmp:free()
end

if(str ~= "") then
doPlayerSendChannelMessage(cid, "", str, TALKTYPE_CHANNEL_W, 0)
return true
end

local frags = tonumber(t[3])
if(frags ~= nil) then
frags = math.max(10, math.min(1000, frags))
else
frags = 100
end

local payment = tonumber(t[4])
if(payment ~= nil) then
payment = math.max(100000, math.min(1000000000, payment))
tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)

local state = tmp:getID() < 0 or tmp:getDataInt("balance") < payment
tmp:free()
if(state) then
doPlayerSendChannelMessage(cid, "", "Your guild balance is too low for such payment.", TALKTYPE_CHANNEL_W, 0)
return true
end

db.query("UPDATE `guilds` SET `balance` = `balance` - " .. payment .. " WHERE `id` = " .. guild)
else
payment = 0
end

local begining, ending = os.time(), tonumber(t[5])
if(ending ~= nil and ending ~= 0) then
ending = begining + (ending * 86400)
else
ending = 0
end

db.query("INSERT INTO `guild_wars` (`guild_id`, `enemy_id`, `begin`, `end`, `frags`, `payment`) VALUES (" .. guild .. ", " .. enemy .. ", " .. begining .. ", " .. ending .. ", " .. frags .. ", " .. payment .. ");")
doBroadcastMessage(getPlayerGuildName(cid) .. " has invited " .. enemyName .. " to war till " .. frags .. " frags.", MESSAGE_EVENT_ADVANCE)
return true
end

if(not isInArray({"end", "finish"}, t[1])) then
return false
end

local status = (t[1] == "end" and 1 or 4)
tmp = db.getResult("SELECT `id` FROM `guild_wars` WHERE `guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy .. " AND `status` = " .. status)
if(tmp:getID() ~= -1) then
local query = "UPDATE `guild_wars` SET `end` = " .. os.time() .. ", `status` = 5 WHERE `id` = " .. tmp:getDataInt("id")
tmp:free()
doGuildRemoveEnemy(guild, enemy)
doGuildRemoveEnemy(enemy, guild)

db.query(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. (status == 4 and "mend fences" or "ended up a war") .. " with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
return true
end

if(status == 4) then
doPlayerSendChannelMessage(cid, "", "Currently there's no pending war truce from " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end

tmp = db.getResult("SELECT `id`, `end` FROM `guild_wars` WHERE `guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild .. " AND `status` = 1")
if(tmp:getID() ~= -1) then
if(tmp:getDataInt("end") > 0) then
tmp:free()
doPlayerSendChannelMessage(cid, "", "You cannot request ending for war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end

local query = "UPDATE `guild_wars` SET `status` = 4, `end` = " .. os.time() .. " WHERE `id` = " .. tmp:getDataInt("id")
tmp:free()

db.query(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has signed an armstice declaration on a war with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
return true
end

doPlayerSendChannelMessage(cid, "", "Currently there's no active war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end

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_W, 0)
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_W, 0)
return true
end

if(not db.query('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_W, 0)
else
doPlayerSendChannelMessage(cid, '', 'Invalid sub-command.', TALKTYPE_CHANNEL_W, 0)
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_W, 0)
return true
end

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

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

db.query('UPDATE `guilds` SET `balance` = `balance` + ' .. money .. ' WHERE `id` = ' .. guild .. ' LIMIT 1;')
doPlayerSendChannelMessage(cid, '', 'You have transfered ' .. money .. ' money to your guild balance.', TALKTYPE_CHANNEL_W, 0)
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_W, 0)
result:free()
end

return true
end                                                 

 

 

 

se não for tente assim

 

 

 

function onSay(cid, words, param, channel)
local guild = getPlayerGuildId(cid)
if(not guild or getPlayerGuildLevel(cid) < GUILDLEVEL_LEADER) then
doPlayerSendChannelMessage(cid, "", "You cannot execute this talkaction.", TALKTYPE_CHANNEL_W, 0)
return true
end

local t = string.explode(param, ",")
if(not t[2]) then
doPlayerSendChannelMessage(cid, "", "Not enough param(s).", TALKTYPE_CHANNEL_W, 0)
return true
end

local enemy = getGuildId(t[2])
if(not enemy) then
doPlayerSendChannelMessage(cid, "", "Guild \"" .. t[2] .. "\" does not exists.", TALKTYPE_CHANNEL_W, 0)
return true
end

if(enemy == guild) then
doPlayerSendChannelMessage(cid, "", "You cannot perform war action on your own guild.", TALKTYPE_CHANNEL_W, 0)
return true
end

local enemyName, tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
if(tmp:getID() ~= -1) then
enemyName = tmp:getDataString("name")
tmp:free()
end

if(isInArray({"accept", "reject", "cancel"}, t[1])) then
local query = "`guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild
if(t[1] == "cancel") then
query = "`guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy
end

tmp = db.getResult("SELECT `id`, `begin`, `end`, `payment` FROM `guild_wars` WHERE " .. query .. " AND `status` = 0")
if(tmp:getID() == -1) then
doPlayerSendChannelMessage(cid, "", "Currently there's no pending invitation for a war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end

if(t[1] == "accept") then
local _tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)
local state = _tmp:getID() < 0 or _tmp:getDataInt("balance") < tmp:getDataInt("payment")

_tmp:free()
if(state) then
doPlayerSendChannelMessage(cid, "", "Your guild balance is too low to accept this invitation.", TALKTYPE_CHANNEL_W, 0)
return true
end

db.query("UPDATE `guilds` SET `balance` = `balance` - " .. tmp:getDataInt("payment") .. " WHERE `id` = " .. guild)
end

query = "UPDATE `guild_wars` SET "
local msg = "accepted " .. enemyName .. " invitation to war."
if(t[1] == "reject") then
query = query .. "`end` = " .. os.time() .. ", `status` = 2"
msg = "rejected " .. enemyName .. " invitation to war."
elseif(t[1] == "cancel") then
query = query .. "`end` = " .. os.time() .. ", `status` = 3"
msg = "canceled invitation to a war with " .. enemyName .. "."
else
query = query .. "`begin` = " .. os.time() .. ", `end` = " .. (tmp:getDataInt("end") > 0 and (os.time() + ((tmp:getDataInt("begin") - tmp:getDataInt("end")) / 86400)) or 0) .. ", `status` = 1"
end

if(t[1] == "accept") then
query = query .. " WHERE `id` = " .. tmp:getDataInt("id")
doGuildAddEnemy(guild, enemy, tmp:getDataInt("id"), WAR_GUILD)
doGuildAddEnemy(enemy, guild, tmp:getDataInt("id"), WAR_ENEMY)
end

tmp:free()
db.query(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. msg, MESSAGE_EVENT_ADVANCE)
return true
end

if(t[1] == "invite") then
local str = ""
tmp = db.getResult("SELECT `guild_id`, `status` FROM `guild_wars` WHERE `guild_id` IN (" .. guild .. "," .. enemy .. ") AND `enemy_id` IN (" .. enemy .. "," .. guild .. ") AND `status` IN (0, 1)")
if(tmp:getID() ~= -1) then
if(tmp:getDataInt("status") == 0) then
if(tmp:getDataInt("guild_id") == guild) then
str = "You have already invited " .. enemyName .. " to war."
else
str = enemyName .. " have already invited you to war."
end
else
str = "You are already on a war with " .. enemyName .. "."
end

tmp:free()
end

if(str ~= "") then
doPlayerSendChannelMessage(cid, "", str, TALKTYPE_CHANNEL_W, 0)
return true
end

local frags = tonumber(t[3])
if(frags ~= nil) then
frags = math.max(10, math.min(1000, frags))
else
frags = 100
end

local payment = tonumber(t[4])
if(payment ~= nil) then
payment = math.max(100000, math.min(1000000000, payment))
tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)

local state = tmp:getID() < 0 or tmp:getDataInt("balance") < payment
tmp:free()
if(state) then
doPlayerSendChannelMessage(cid, "", "Your guild balance is too low for such payment.", TALKTYPE_CHANNEL_W, 0)
return true
end

db.query("UPDATE `guilds` SET `balance` = `balance` - " .. payment .. " WHERE `id` = " .. guild)
else
payment = 0
end

local begining, ending = os.time(), tonumber(t[5])
if(ending ~= nil and ending ~= 0) then
ending = begining + (ending * 86400)
else
ending = 0
end

db.query("INSERT INTO `guild_wars` (`guild_id`, `enemy_id`, `begin`, `end`, `frags`, `payment`) VALUES (" .. guild .. ", " .. enemy .. ", " .. begining .. ", " .. ending .. ", " .. frags .. ", " .. payment .. ");")
doBroadcastMessage(getPlayerGuildName(cid) .. " has invited " .. enemyName .. " to war till " .. frags .. " frags.", MESSAGE_EVENT_ADVANCE)
return true
end

if(not isInArray({"end", "finish"}, t[1])) then
return false
end

local status = (t[1] == "end" and 1 or 4)
tmp = db.getResult("SELECT `id` FROM `guild_wars` WHERE `guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy .. " AND `status` = " .. status)
if(tmp:getID() ~= -1) then
local query = "UPDATE `guild_wars` SET `end` = " .. os.time() .. ", `status` = 5 WHERE `id` = " .. tmp:getDataInt("id")
tmp:free()
doGuildRemoveEnemy(guild, enemy)
doGuildRemoveEnemy(enemy, guild)

db.query(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. (status == 4 and "mend fences" or "ended up a war") .. " with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
return true
end

if(status == 4) then
doPlayerSendChannelMessage(cid, "", "Currently there's no pending war truce from " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end

tmp = db.getResult("SELECT `id`, `end` FROM `guild_wars` WHERE `guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild .. " AND `status` = 1")
if(tmp:getID() ~= -1) then
if(tmp:getDataInt("end") > 0) then
tmp:free()
doPlayerSendChannelMessage(cid, "", "You cannot request ending for war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end

local query = "UPDATE `guild_wars` SET `status` = 4, `end` = " .. os.time() .. " WHERE `id` = " .. tmp:getDataInt("id")
tmp:free()

db.query(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has signed an armstice declaration on a war with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
return true
end

doPlayerSendChannelMessage(cid, "", "Currently there's no active war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end

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_W, 0)
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_W, 0)
return true
end

if(not db.query('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_W, 0)
else
doPlayerSendChannelMessage(cid, '', 'Invalid sub-command.', TALKTYPE_CHANNEL_W, 0)
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_W, 0)
return true
end

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

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

db.query('UPDATE `guilds` SET `balance` = `balance` + ' .. money .. ' WHERE `id` = ' .. guild .. ' LIMIT 1;')
doPlayerSendChannelMessage(cid, '', 'You have transfered ' .. money .. ' money to your guild balance.', TALKTYPE_CHANNEL_W, 0)
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_W, 0)
result:free()
end

return true
end

 

 

 

deu não fika aparecendo pra invita ou cancela ou aceitar a war system

 

so aparece isso no guild chat

22:27 Current balance of guild cuca is: 0 bronze coins.

 

 

 

Link para o comentário
Compartilhar em outros sites

 

 

 

Tenta ai!

 

war.lua

 

 

function onSay(cid, words, param, channel)
local guild = getPlayerGuildId(cid)
if(not guild or getPlayerGuildLevel(cid) < GUILDLEVEL_LEADER) then
doPlayerSendChannelMessage(cid, "", "You cannot execute this talkaction.", TALKTYPE_CHANNEL_W, 0)
return true
end
local t = string.explode(param, ",")
if(not t[2]) then
doPlayerSendChannelMessage(cid, "", "Not enough param(s).", TALKTYPE_CHANNEL_W, 0)
return true
end
local enemy = getGuildId(t[2])
if(not enemy) then
doPlayerSendChannelMessage(cid, "", "Guild \"" .. t[2] .. "\" does not exists.", TALKTYPE_CHANNEL_W, 0)
return true
end
if(enemy == guild) then
doPlayerSendChannelMessage(cid, "", "You cannot perform war action on your own guild.", TALKTYPE_CHANNEL_W, 0)
return true
end
local enemyName, tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
if(tmp:getID() ~= -1) then
enemyName = tmp:getDataString("name")
tmp:free()
end
if(isInArray({"accept", "reject", "cancel"}, t[1])) then
local query = "`guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild
if(t[1] == "cancel") then
query = "`guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy
end
tmp = db.getResult("SELECT `id`, `begin`, `end`, `payment` FROM `guild_wars` WHERE " .. query .. " AND `status` = 0")
if(tmp:getID() == -1) then
doPlayerSendChannelMessage(cid, "", "Currently there's no pending invitation for a war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end
if(t[1] == "accept") then
local _tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)
local state = _tmp:getID() < 0 or _tmp:getDataInt("balance") < tmp:getDataInt("payment")
_tmp:free()
if(state) then
doPlayerSendChannelMessage(cid, "", "Your guild balance is too low to accept this invitation.", TALKTYPE_CHANNEL_W, 0)
return true
end
db.query("UPDATE `guilds` SET `balance` = `balance` - " .. tmp:getDataInt("payment") .. " WHERE `id` = " .. guild)
end
query = "UPDATE `guild_wars` SET "
local msg = "accepted " .. enemyName .. " invitation to war."
if(t[1] == "reject") then
query = query .. "`end` = " .. os.time() .. ", `status` = 2"
msg = "rejected " .. enemyName .. " invitation to war."
elseif(t[1] == "cancel") then
query = query .. "`end` = " .. os.time() .. ", `status` = 3"
msg = "canceled invitation to a war with " .. enemyName .. "."
else
query = query .. "`begin` = " .. os.time() .. ", `end` = " .. (tmp:getDataInt("end") > 0 and (os.time() + ((tmp:getDataInt("begin") - tmp:getDataInt("end")) / 86400)) or 0) .. ", `status` = 1"
end
query = query .. " WHERE `id` = " .. tmp:getDataInt("id")
if(t[1] == "accept") then
doGuildAddEnemy(guild, enemy, tmp:getDataInt("id"), WAR_GUILD)
doGuildAddEnemy(enemy, guild, tmp:getDataInt("id"), WAR_ENEMY)
end
tmp:free()
db.query(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. msg, MESSAGE_EVENT_ADVANCE)
return true
end
if(t[1] == "invite") then
local str = ""
tmp = db.getResult("SELECT `guild_id`, `status` FROM `guild_wars` WHERE `guild_id` IN (" .. guild .. "," .. enemy .. ") AND `enemy_id` IN (" .. enemy .. "," .. guild .. ") AND `status` IN (0, 1)")
if(tmp:getID() ~= -1) then
if(tmp:getDataInt("status") == 0) then
if(tmp:getDataInt("guild_id") == guild) then
str = "You have already invited " .. enemyName .. " to war."
else
str = enemyName .. " have already invited you to war."
end
else
str = "You are already on a war with " .. enemyName .. "."
end
tmp:free()
end
if(str ~= "") then
doPlayerSendChannelMessage(cid, "", str, TALKTYPE_CHANNEL_W, 0)
return true
end
local frags = tonumber(t[3])
if(frags ~= nil) then
frags = math.max(10, math.min(1000, frags))
else
frags = 100
end
local payment = tonumber(t[4])
if(payment ~= nil) then
payment = math.max(100000, math.min(1000000000, payment))
tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)
local state = tmp:getID() < 0 or tmp:getDataInt("balance") < payment
tmp:free()
if(state) then
doPlayerSendChannelMessage(cid, "", "Your guild balance is too low for such payment.", TALKTYPE_CHANNEL_W, 0)
return true
end
db.query("UPDATE `guilds` SET `balance` = `balance` - " .. payment .. " WHERE `id` = " .. guild)
else
payment = 0
end
local begining, ending = os.time(), tonumber(t[5])
if(ending ~= nil and ending ~= 0) then
ending = begining + (ending * 86400)
else
ending = 0
end
db.query("INSERT INTO `guild_wars` (`guild_id`, `enemy_id`, `begin`, `end`, `frags`, `payment`) VALUES (" .. guild .. ", " .. enemy .. ", " .. begining .. ", " .. ending .. ", " .. frags .. ", " .. payment .. ");")
doBroadcastMessage(getPlayerGuildName(cid) .. " has invited " .. enemyName .. " to war till " .. frags .. " frags.", MESSAGE_EVENT_ADVANCE)
return true
end
if(not isInArray({"end", "finish"}, t[1])) then
return false
end
local status = (t[1] == "end" and 1 or 4)
tmp = db.getResult("SELECT `id` FROM `guild_wars` WHERE `guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy .. " AND `status` = " .. status)
if(tmp:getID() ~= -1) then
local query = "UPDATE `guild_wars` SET `end` = " .. os.time() .. ", `status` = 5 WHERE `id` = " .. tmp:getDataInt("id")
tmp:free()
doGuildRemoveEnemy(guild, enemy)
doGuildRemoveEnemy(enemy, guild)
db.query(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. (status == 4 and "mend fences" or "ended up a war") .. " with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
return true
end
if(status == 4) then
doPlayerSendChannelMessage(cid, "", "Currently there's no pending war truce from " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end
tmp = db.getResult("SELECT `id`, `end` FROM `guild_wars` WHERE `guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild .. " AND `status` = 1")
if(tmp:getID() ~= -1) then
if(tmp:getDataInt("end") > 0) then
tmp:free()
doPlayerSendChannelMessage(cid, "", "You cannot request ending for war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end
local query = "UPDATE `guild_wars` SET `status` = 4, `end` = " .. os.time() .. " WHERE `id` = " .. tmp:getDataInt("id")
tmp:free()
db.query(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has signed an armstice declaration on a war with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
return true
end
doPlayerSendChannelMessage(cid, "", "Currently there's no active war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end

Comandos:
/war invite, GUILD, FRAGS
/war accept, GUILD INVITING
/balance
Link para o comentário
Compartilhar em outros sites

 

 

Tenta ai!

 

war.lua

 

 

function onSay(cid, words, param, channel)
local guild = getPlayerGuildId(cid)
if(not guild or getPlayerGuildLevel(cid) < GUILDLEVEL_LEADER) then
doPlayerSendChannelMessage(cid, "", "You cannot execute this talkaction.", TALKTYPE_CHANNEL_W, 0)
return true
end
local t = string.explode(param, ",")
if(not t[2]) then
doPlayerSendChannelMessage(cid, "", "Not enough param(s).", TALKTYPE_CHANNEL_W, 0)
return true
end
local enemy = getGuildId(t[2])
if(not enemy) then
doPlayerSendChannelMessage(cid, "", "Guild \"" .. t[2] .. "\" does not exists.", TALKTYPE_CHANNEL_W, 0)
return true
end
if(enemy == guild) then
doPlayerSendChannelMessage(cid, "", "You cannot perform war action on your own guild.", TALKTYPE_CHANNEL_W, 0)
return true
end
local enemyName, tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
if(tmp:getID() ~= -1) then
enemyName = tmp:getDataString("name")
tmp:free()
end
if(isInArray({"accept", "reject", "cancel"}, t[1])) then
local query = "`guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild
if(t[1] == "cancel") then
query = "`guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy
end
tmp = db.getResult("SELECT `id`, `begin`, `end`, `payment` FROM `guild_wars` WHERE " .. query .. " AND `status` = 0")
if(tmp:getID() == -1) then
doPlayerSendChannelMessage(cid, "", "Currently there's no pending invitation for a war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end
if(t[1] == "accept") then
local _tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)
local state = _tmp:getID() < 0 or _tmp:getDataInt("balance") < tmp:getDataInt("payment")
_tmp:free()
if(state) then
doPlayerSendChannelMessage(cid, "", "Your guild balance is too low to accept this invitation.", TALKTYPE_CHANNEL_W, 0)
return true
end
db.query("UPDATE `guilds` SET `balance` = `balance` - " .. tmp:getDataInt("payment") .. " WHERE `id` = " .. guild)
end
query = "UPDATE `guild_wars` SET "
local msg = "accepted " .. enemyName .. " invitation to war."
if(t[1] == "reject") then
query = query .. "`end` = " .. os.time() .. ", `status` = 2"
msg = "rejected " .. enemyName .. " invitation to war."
elseif(t[1] == "cancel") then
query = query .. "`end` = " .. os.time() .. ", `status` = 3"
msg = "canceled invitation to a war with " .. enemyName .. "."
else
query = query .. "`begin` = " .. os.time() .. ", `end` = " .. (tmp:getDataInt("end") > 0 and (os.time() + ((tmp:getDataInt("begin") - tmp:getDataInt("end")) / 86400)) or 0) .. ", `status` = 1"
end
query = query .. " WHERE `id` = " .. tmp:getDataInt("id")
if(t[1] == "accept") then
doGuildAddEnemy(guild, enemy, tmp:getDataInt("id"), WAR_GUILD)
doGuildAddEnemy(enemy, guild, tmp:getDataInt("id"), WAR_ENEMY)
end
tmp:free()
db.query(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. msg, MESSAGE_EVENT_ADVANCE)
return true
end
if(t[1] == "invite") then
local str = ""
tmp = db.getResult("SELECT `guild_id`, `status` FROM `guild_wars` WHERE `guild_id` IN (" .. guild .. "," .. enemy .. ") AND `enemy_id` IN (" .. enemy .. "," .. guild .. ") AND `status` IN (0, 1)")
if(tmp:getID() ~= -1) then
if(tmp:getDataInt("status") == 0) then
if(tmp:getDataInt("guild_id") == guild) then
str = "You have already invited " .. enemyName .. " to war."
else
str = enemyName .. " have already invited you to war."
end
else
str = "You are already on a war with " .. enemyName .. "."
end
tmp:free()
end
if(str ~= "") then
doPlayerSendChannelMessage(cid, "", str, TALKTYPE_CHANNEL_W, 0)
return true
end
local frags = tonumber(t[3])
if(frags ~= nil) then
frags = math.max(10, math.min(1000, frags))
else
frags = 100
end
local payment = tonumber(t[4])
if(payment ~= nil) then
payment = math.max(100000, math.min(1000000000, payment))
tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)
local state = tmp:getID() < 0 or tmp:getDataInt("balance") < payment
tmp:free()
if(state) then
doPlayerSendChannelMessage(cid, "", "Your guild balance is too low for such payment.", TALKTYPE_CHANNEL_W, 0)
return true
end
db.query("UPDATE `guilds` SET `balance` = `balance` - " .. payment .. " WHERE `id` = " .. guild)
else
payment = 0
end
local begining, ending = os.time(), tonumber(t[5])
if(ending ~= nil and ending ~= 0) then
ending = begining + (ending * 86400)
else
ending = 0
end
db.query("INSERT INTO `guild_wars` (`guild_id`, `enemy_id`, `begin`, `end`, `frags`, `payment`) VALUES (" .. guild .. ", " .. enemy .. ", " .. begining .. ", " .. ending .. ", " .. frags .. ", " .. payment .. ");")
doBroadcastMessage(getPlayerGuildName(cid) .. " has invited " .. enemyName .. " to war till " .. frags .. " frags.", MESSAGE_EVENT_ADVANCE)
return true
end
if(not isInArray({"end", "finish"}, t[1])) then
return false
end
local status = (t[1] == "end" and 1 or 4)
tmp = db.getResult("SELECT `id` FROM `guild_wars` WHERE `guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy .. " AND `status` = " .. status)
if(tmp:getID() ~= -1) then
local query = "UPDATE `guild_wars` SET `end` = " .. os.time() .. ", `status` = 5 WHERE `id` = " .. tmp:getDataInt("id")
tmp:free()
doGuildRemoveEnemy(guild, enemy)
doGuildRemoveEnemy(enemy, guild)
db.query(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. (status == 4 and "mend fences" or "ended up a war") .. " with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
return true
end
if(status == 4) then
doPlayerSendChannelMessage(cid, "", "Currently there's no pending war truce from " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end
tmp = db.getResult("SELECT `id`, `end` FROM `guild_wars` WHERE `guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild .. " AND `status` = 1")
if(tmp:getID() ~= -1) then
if(tmp:getDataInt("end") > 0) then
tmp:free()
doPlayerSendChannelMessage(cid, "", "You cannot request ending for war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end
local query = "UPDATE `guild_wars` SET `status` = 4, `end` = " .. os.time() .. " WHERE `id` = " .. tmp:getDataInt("id")
tmp:free()
db.query(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has signed an armstice declaration on a war with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
return true
end
doPlayerSendChannelMessage(cid, "", "Currently there's no active war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end

Comandos:
/war invite, GUILD, FRAGS
/war accept, GUILD INVITING
/balance

 

 

deu pra invita deu pra cancelar como antes .... porem deu erro ao aceitar !!!

post-381868-0-09330400-1440430349_thumb.png

 

bom pesquisei muito e axei uma coisa que faz sentido bom esse erro é sobre a compilação

 

falta adc essa tag -D__WAR_SYSTEM__

ja tentei de tudo jeito tenho as source do serve intão alguem poderia compilar pra min por favor ai manda o skype pra min que eu entro em contato

Link para o comentário
Compartilhar em outros sites

pqp uahsuahsuahsas, add ai: suicunei, mas se quiser, usa o TFS que eu compilei, ela contém o War System, Cast System, aceita qualquer items.otb, não tem o erro de malformed file, não checa versão, não tem salt e aceita encypt plain.

 

 

Aqui vai o link de download:

https://www.sendspace.com/file/jayoiz

Link para o comentário
Compartilhar em outros sites

pqp uahsuahsuahsas, add ai: suicunei, mas se quiser, usa o TFS que eu compilei, ela contém o War System, Cast System, aceita qualquer items.otb, não tem o erro de malformed file, não checa versão, não tem salt e aceita encypt plain.

 

 

Aqui vai o link de download:

https://www.sendspace.com/file/jayoiz

 

quando vo abrir da esse erro aki oque seria ... oq pod ta errado no meu config.lua

post-381868-0-51402600-1440915110_thumb.png

 

 

accountManager = true

namelockManager = true

newPlayerChooseVoc = true

newPlayerSpawnPosX = 32369

newPlayerSpawnPosY = 32241

newPlayerSpawnPosZ = 7

newPlayerTownId = 1

newPlayerLevel = 10

newPlayerMagicLevel = 0

generateAccountNumber = false

generateAccountSalt = false

 

useFragHandler = true

redSkullLength = 2 * 24 * 60 * 60

blackSkullLength = 3 * 24 * 60 * 60

dailyFragsToRedSkull = 12

weeklyFragsToRedSkull = 25

monthlyFragsToRedSkull = 100

dailyFragsToBlackSkull = 50

weeklyFragsToBlackSkull = 60

monthlyFragsToBlackSkull = 200

dailyFragsToBanishment = dailyFragsToRedSkull

weeklyFragsToBanishment = weeklyFragsToRedSkull

monthlyFragsToBanishment = monthlyFragsToRedSkull

blackSkulledDeathHealth = 40

blackSkulledDeathMana = 0

useBlackSkull = true

advancedFragList = false

 

notationsToBan = 3

warningsToFinalBan = 4

warningsToDeletion = 5

banLength = 7 * 24 * 60 * 60

killsBanLength = 7 * 24 * 60 * 60

finalBanLength = 30 * 24 * 60 * 60

ipBanishmentLength = 1 * 24 * 60 * 60

broadcastBanishments = false

maxViolationCommentSize = 200

violationNameReportActionType = 2

autoBanishUnknownBytes = false

 

worldType = "open"

protectionLevel = 30

pvpTileIgnoreLevelAndVocationProtection = true

pzLocked = 60 * 1000

huntingDuration = 60 * 1000

criticalHitChance = 7

criticalHitMultiplier = 1

displayCriticalHitNotify = false

removeWeaponAmmunition = false

removeWeaponCharges = true

removeRuneCharges = true

whiteSkullTime = 10 * 60 * 1000

noDamageToSameLookfeet = false

showHealingDamage = false

showHealingDamageForMonsters = false

fieldOwnershipDuration = 5 * 1000

stopAttackingAtExit = false

loginProtectionPeriod = 10 * 1000

deathLostPercent = 10

stairhopDelay = 2 * 1000

pushCreatureDelay = 2 * 500

deathContainerId = 1987

gainExperienceColor = 215

addManaSpentInPvPZone = true

squareColor = 0

allowFightback = true

fistBaseAttack = 7

 

worldId = 0

ip = "127.0.0.1"

bindOnlyGlobalAddress = false

loginPort = 7171

gamePort = 7172

loginTries = 10

retryTimeout = 5 * 1000

loginTimeout = 60 * 1000

maxPlayers = 400

motd = "*Welcome to KingsWorld OTserv.*"

displayOnOrOffAtCharlist = false

onePlayerOnlinePerAccount = true

allowClones = false

serverName = "KingsWorld OTserv"

loginMessage = "Welcome to KingsWorld OTserv."

statusTimeout = 5 * 60 * 1000

replaceKickOnLogin = true

forceSlowConnectionsToDisconnect = false

loginOnlyWithLoginServer = false

premiumPlayerSkipWaitList = false

 

sqlType = "mysql"

sqlHost = "localhost"

sqlPort = 3306

sqlUser = "root"

sqlPass = "kc8o8iod"

sqlDatabase = "tepas"

sqlFile = "kingsworld.s3db"

sqlKeepAlive = 0

mysqlReadTimeout = 10

mysqlWriteTimeout = 10

encryptionType = "sha1"

 

deathListEnabled = true

deathListRequiredTime = 1 * 60 * 1000

deathAssistCount = 19

maxDeathRecords = 5

 

ingameGuildManagement = false

levelToFormGuild = 8

premiumDaysToFormGuild = 0

guildNameMinLength = 4

guildNameMaxLength = 20

 

highscoreDisplayPlayers = 15

updateHighscoresAfterMinutes = 60

 

buyableAndSellableHouses = true

houseNeedPremium = false

bedsRequirePremium = false

levelToBuyHouse = 100

housesPerAccount = 1

houseRentAsPrice = true

housePriceAsRent = true

housePriceEachSquare = 1000

houseRentPeriod = true

houseCleanOld = 0

guildHalls = false

 

timeBetweenActions = 200

timeBetweenExActions = 1000

hotkeyAimbotEnabled = true

 

mapName = "kingsworld.otbm"

mapAuthor = "CiptSoft"

randomizeTiles = true

storeTrash = true

cleanProtectedZones = true

mailboxDisabledTowns = ""

 

defaultPriority = "high"

niceLevel = 5

coresUsed = "-1"

 

startupDatabaseOptimization = true

updatePremiumStateAtStartup = true

confirmOutdatedVersion = false

 

formulaLevel = 5.0

formulaMagic = 1.0

bufferMutedOnSpellFailure = false

spellNameInsteadOfWords = false

emoteSpells = false

 

allowChangeOutfit = true

allowChangeColors = true

allowChangeAddons = true

disableOutfitsForPrivilegedPlayers = false

addonsOnlyPremium = false

 

dataDirectory = "data/"

logsDirectory = "data/logs/"

bankSystem = true

displaySkillLevelOnAdvance = false

promptExceptionTracerErrorBox = true

maximumDoorLevel = 500

maxMessageBuffer = 4

 

separateVipListPerCharacter = false

vipListDefaultLimit = 20

vipListDefaultPremiumLimit = 100

 

saveGlobalStorage = true

useHouseDataStorage = false

storePlayerDirection = false

 

checkCorpseOwner = true

monsterLootMessage = 3

monsterLootMessageType = 25

 

ghostModeInvisibleEffect = false

ghostModeSpellEffects = true

 

idleWarningTime = 14 * 60 * 10000000000

idleKickTime = 14 * 60 * 10000000000

reportsExpirationAfterReads = 1

playerQueryDeepness = 2

tileLimit = 0

protectionTileLimit = 0

houseTileLimit = 0

 

freePremium = false

premiumForPromotion = false

 

blessings = true

blessingOnlyPremium = false

blessingReductionBase = 30

blessingReductionDecrement = 5

eachBlessReduction = 8

 

experienceStages = false

rateExperience = 100

rateExperienceFromPlayers = 2

rateSkill = 50.0

rateMagic = 40.0

rateLoot = 10

rateSpawn = 2

 

rateMonsterHealth = 1.0

rateMonsterMana = 1.0

rateMonsterAttack = 1.0

rateMonsterDefense = 1.0

 

minLevelThresholdForKilledPlayer = 0.9

maxLevelThresholdForKilledPlayer = 1.1

 

rateStaminaLoss = 1

rateStaminaGain = 3

rateStaminaThresholdGain = 24

staminaRatingLimitTop = 40 * 60

staminaRatingLimitBottom = 14 * 60

staminaLootLimit = 14 * 60

rateStaminaAboveNormal = 1.0

rateStaminaUnderNormal = 0.5

staminaThresholdOnlyPremium = true

 

experienceShareRadiusX = 30

experienceShareRadiusY = 30

experienceShareRadiusZ = 1

experienceShareLevelDifference = 2 / 3

extraPartyExperienceLimit = 20

extraPartyExperiencePercent = 5

experienceShareActivity = 2 * 60 * 1000

 

globalSaveEnabled = false

globalSaveHour = 8

globalSaveMinute = 0

shutdownAtGlobalSave = true

cleanMapAtGlobalSave = false

 

deSpawnRange = 2

deSpawnRadius = 50

 

maxPlayerSummons = 2

teleportAllSummons = false

teleportPlayerSummons = false

 

statusPort = 7171

ownerName = "KingsWorld OTserv"

ownerEmail = "blumaster@r7.com"

url = "www.otserver.com.br"

location = "brazil"

displayGamemastersWithOnlineCommand = false

 

displayPlayersLogging = true

prefixChannelLogs = ""

runFile = ""

outputLog = ""

truncateLogOnStartup = false

 

managerPort = 7171

managerLogs = true

managerPassword = ""

managerLocalhostOnly = true

managerConnectionsLimit = 1

 

adminPort = 7171

adminLogs = true

adminPassword = ""

adminLocalhostOnly = true

adminConnectionsLimit = 1

adminRequireLogin = true

adminEncryption = ""

adminEncryptionData = ""

 

 

Link para o comentário
Compartilhar em outros sites

@@sk8sk8ter,

 

Tenta assim:

 

function onSay(cid, words, param, channel)
	local guild = getPlayerGuildId(cid)
	if(not guild or getPlayerGuildLevel(cid) < GUILDLEVEL_LEADER) then
		doPlayerSendChannelMessage(cid, "", "You cannot execute this talkaction.", TALKTYPE_CHANNEL_W, 0)
		return true
	end
	
	local t = string.explode(param, ",")
	if(not t[2]) then
		doPlayerSendChannelMessage(cid, "", "Not enough param(s).", TALKTYPE_CHANNEL_W, 0)
		return true
	end
	
	local enemy = getGuildId(t[2])
	if(not enemy) then
		doPlayerSendChannelMessage(cid, "", "Guild \"" .. t[2] .. "\" does not exists.", TALKTYPE_CHANNEL_W, 0)
		return true
	end
	
	if(enemy == guild) then
		doPlayerSendChannelMessage(cid, "", "You cannot perform war action on your own guild.", TALKTYPE_CHANNEL_W, 0)
		return true
	end
	
	local enemyName, tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
	if(tmp:getID() ~= -1) then
		enemyName = tmp:getDataString("name")
		tmp:free()
	end
	
	if(isInArray({"accept", "reject", "cancel"}, t[1])) then
		local query = "`guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild
		if(t[1] == "cancel") then
			query = "`guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy
		end
		
		tmp = db.getResult("SELECT `id`, `begin`, `end`, `payment` FROM `guild_wars` WHERE " .. query .. " AND `status` = 0")
		if(tmp:getID() == -1) then
			doPlayerSendChannelMessage(cid, "", "Currently there's no pending invitation for a war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
			return true
		end
		
		query = "UPDATE `guild_wars` SET "
		local msg = "accepted " .. enemyName .. " invitation to war."
		if(t[1] == "reject") then
			query = query .. "`end` = " .. os.time() .. ", `status` = 2"
			msg = "rejected " .. enemyName .. " invitation to war."
		elseif(t[1] == "cancel") then
			query = query .. "`end` = " .. os.time() .. ", `status` = 3"
			msg = "canceled invitation to a war with " .. enemyName .. "."
		else
			query = query .. "`begin` = " .. os.time() .. ", `end` = " .. (tmp:getDataInt("end") > 0 and (os.time() + ((tmp:getDataInt("begin") - tmp:getDataInt("end")) / 86400)) or 0) .. ", `status` = 1"
		end
		
		query = query .. " WHERE `id` = " .. tmp:getDataInt("id")
		if(t[1] == "accept") then
			local _tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)
			local state = _tmp:getID() < 0 or _tmp:getDataInt("balance") < tmp:getDataInt("payment")
			
			if(state) then
				doPlayerSendChannelMessage(cid, "", "Your guild balance is too low to accept this invitation.", TALKTYPE_CHANNEL_W, 0)
				return true
			end
			
			db.query("UPDATE `guilds` SET `balance` = `balance` - " .. tmp:getDataInt("payment") .. " WHERE `id` = " .. guild)
			doGuildAddEnemy(guild, enemy, tmp:getDataInt("id"), WAR_GUILD)
			doGuildAddEnemy(enemy, guild, tmp:getDataInt("id"), WAR_ENEMY)
		end
		
		tmp:free()
		db.query(query)
		doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. msg, MESSAGE_EVENT_ADVANCE)
		return true
	end
	
	if(t[1] == "invite") then
		local str = ""
		tmp = db.getResult("SELECT `guild_id`, `status` FROM `guild_wars` WHERE `guild_id` IN (" .. guild .. "," .. enemy .. ") AND `enemy_id` IN (" .. enemy .. "," .. guild .. ") AND `status` IN (0, 1)")
		if(tmp:getID() ~= -1) then
			if(tmp:getDataInt("status") == 0) then
				if(tmp:getDataInt("guild_id") == guild) then
					str = "You have already invited " .. enemyName .. " to war."
				else
					str = enemyName .. " have already invited you to war."
				end
			else
				str = "You are already on a war with " .. enemyName .. "."
			end
			
			tmp:free()
		end
		
		if(str ~= "") then
			doPlayerSendChannelMessage(cid, "", str, TALKTYPE_CHANNEL_W, 0)
			return true
		end
		
		local frags = tonumber(t[3])
		if(frags ~= nil) then
			frags = math.max(10, math.min(1000, frags))
		else
			frags = 100
		end
		
		local payment = tonumber(t[4])
		if(payment ~= nil) then
			payment = math.max(100000, math.min(1000000000, payment))
			tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)
			
			local state = tmp:getID() < 0 or tmp:getDataInt("balance") < payment
			tmp:free()
			if(state) then
				doPlayerSendChannelMessage(cid, "", "Your guild balance is too low for such payment.", TALKTYPE_CHANNEL_W, 0)
				return true
			end
			
			db.query("UPDATE `guilds` SET `balance` = `balance` - " .. payment .. " WHERE `id` = " .. guild)
		else
			payment = 0
		end
		
		local begining, ending = os.time(), tonumber(t[5])
		if(ending ~= nil and ending ~= 0) then
			ending = begining + (ending * 86400)
		else
			ending = 0
		end
		
		db.query("INSERT INTO `guild_wars` (`guild_id`, `enemy_id`, `begin`, `end`, `frags`, `payment`) VALUES (" .. guild .. ", " .. enemy .. ", " .. begining .. ", " .. ending .. ", " .. frags .. ", " .. payment .. ");")
		doBroadcastMessage(getPlayerGuildName(cid) .. " has invited " .. enemyName .. " to war till " .. frags .. " frags.", MESSAGE_EVENT_ADVANCE)
		return true
	end
	
	if(not isInArray({"end", "finish"}, t[1])) then
		return false
	end
	
	local status = (t[1] == "end" and 1 or 4)
	tmp = db.getResult("SELECT `id` FROM `guild_wars` WHERE `guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy .. " AND `status` = " .. status)
	if(tmp:getID() ~= -1) then
		local query = "UPDATE `guild_wars` SET `end` = " .. os.time() .. ", `status` = 5 WHERE `id` = " .. tmp:getDataInt("id")
		tmp:free()
		doGuildRemoveEnemy(guild, enemy)
		doGuildRemoveEnemy(enemy, guild)
		
		db.query(query)
		doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. (status == 4 and "mend fences" or "ended up a war") .. " with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
		return true
	end
	
	if(status == 4) then
		doPlayerSendChannelMessage(cid, "", "Currently there's no pending war truce from " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
		return true
	end
	
	tmp = db.getResult("SELECT `id`, `end` FROM `guild_wars` WHERE `guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild .. " AND `status` = 1")
	if(tmp:getID() ~= -1) then
		if(tmp:getDataInt("end") > 0) then
			tmp:free()
			doPlayerSendChannelMessage(cid, "", "You cannot request ending for war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
			return true
		end
		
		local query = "UPDATE `guild_wars` SET `status` = 4, `end` = " .. os.time() .. " WHERE `id` = " .. tmp:getDataInt("id")
		tmp:free()
		
		db.query(query)
		doBroadcastMessage(getPlayerGuildName(cid) .. " has signed an armstice declaration on a war with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
		return true
	end
	
	doPlayerSendChannelMessage(cid, "", "Currently there's no active war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
	return true
end

 

Link para o comentário
Compartilhar em outros sites

deu esse erro agora

 

E agora?

 

 

function onSay(cid, words, param, channel)
    local guild = getPlayerGuildId(cid)
    if(not guild or getPlayerGuildLevel(cid) < GUILDLEVEL_LEADER) then
        doPlayerSendChannelMessage(cid, "", "You cannot execute this talkaction.", TALKTYPE_CHANNEL_W, 0)
        return true
    end
    local t = string.explode(param, ",")
    if(not t[2]) then
        doPlayerSendChannelMessage(cid, "", "Not enough param(s).", TALKTYPE_CHANNEL_W, 0)
        return true
    end
    local enemy = getGuildId(t[2])
    if(not enemy) then
        doPlayerSendChannelMessage(cid, "", "Guild \"" .. t[2] .. "\" does not exists.", TALKTYPE_CHANNEL_W, 0)
        return true
    end
    if(enemy == guild) then
        doPlayerSendChannelMessage(cid, "", "You cannot perform war action on your own guild.", TALKTYPE_CHANNEL_W, 0)
        return true
    end
    local enemyName, tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
    if(tmp:getID() ~= -1) then
        enemyName = tmp:getDataString("name")
        tmp:free()
    end
    if(isInArray({"accept", "reject", "cancel"}, t[1])) then
        local query = "`guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild
        if(t[1] == "cancel") then
            query = "`guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy
        end
        tmp = db.getResult("SELECT `id`, `begin`, `end`, `payment` FROM `guild_wars` WHERE " .. query .. " AND `status` = 0")
        if(tmp:getID() == -1) then
            doPlayerSendChannelMessage(cid, "", "Currently there's no pending invitation for a war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
            return true
        end
        if(t[1] == "accept") then
            local _tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)
            local state = _tmp:getID() < 0 or _tmp:getDataInt("balance") < tmp:getDataInt("payment")
            _tmp:free()
            if(state) then
                doPlayerSendChannelMessage(cid, "", "Your guild balance is too low to accept this invitation.", TALKTYPE_CHANNEL_W, 0)
                return true
            end
            db.query("UPDATE `guilds` SET `balance` = `balance` - " .. tmp:getDataInt("payment") .. " WHERE `id` = " .. guild)
        end
        query = "UPDATE `guild_wars` SET "
        local msg = "accepted " .. enemyName .. " invitation to war."
        if(t[1] == "reject") then
            query = query .. "`end` = " .. os.time() .. ", `status` = 2"
            msg = "rejected " .. enemyName .. " invitation to war."
        elseif(t[1] == "cancel") then
            query = query .. "`end` = " .. os.time() .. ", `status` = 3"
            msg = "canceled invitation to a war with " .. enemyName .. "."
        else
            query = query .. "`begin` = " .. os.time() .. ", `end` = " .. (tmp:getDataInt("end") > 0 and (os.time() + ((tmp:getDataInt("begin") - tmp:getDataInt("end")) / 86400)) or 0) .. ", `status` = 1"
        end
        query = query .. " WHERE `id` = " .. tmp:getDataInt("id")
        if(t[1] == "accept") then
            doGuildAddEnemy(guild, enemy, tmp:getDataInt("id"), WAR_GUILD)
            doGuildAddEnemy(enemy, guild, tmp:getDataInt("id"), WAR_ENEMY)
        end
        tmp:free()
        db.query(query)
        doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. msg, MESSAGE_EVENT_ADVANCE)
        return true
    end
    if(t[1] == "invite") then
        local str = ""
        tmp = db.getResult("SELECT `guild_id`, `status` FROM `guild_wars` WHERE `guild_id` IN (" .. guild .. "," .. enemy .. ") AND `enemy_id` IN (" .. enemy .. "," .. guild .. ") AND `status` IN (0, 1)")
        if(tmp:getID() ~= -1) then
            if(tmp:getDataInt("status") == 0) then
                if(tmp:getDataInt("guild_id") == guild) then
                    str = "You have already invited " .. enemyName .. " to war."
                else
                    str = enemyName .. " have already invited you to war."
                end
            else
                str = "You are already on a war with " .. enemyName .. "."
            end
            tmp:free()
        end
        if(str ~= "") then
            doPlayerSendChannelMessage(cid, "", str, TALKTYPE_CHANNEL_W, 0)
            return true
        end
        local frags = tonumber(t[3])
        if(frags ~= nil) then
            frags = math.max(10, math.min(1000, frags))
        else
            frags = 100
        end
        local payment = tonumber(t[4])
        if(payment ~= nil) then
            payment = math.max(100000, math.min(1000000000, payment))
            tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)
            local state = tmp:getID() < 0 or tmp:getDataInt("balance") < payment
            tmp:free()
            if(state) then
                doPlayerSendChannelMessage(cid, "", "Your guild balance is too low for such payment.", TALKTYPE_CHANNEL_W, 0)
                return true
            end
            db.query("UPDATE `guilds` SET `balance` = `balance` - " .. payment .. " WHERE `id` = " .. guild)
        else
            payment = 0
        end
        local begining, ending = os.time(), tonumber(t[5])
        if(ending ~= nil and ending ~= 0) then
            ending = begining + (ending * 86400)
        else
            ending = 0
        end
        db.query("INSERT INTO `guild_wars` (`guild_id`, `enemy_id`, `begin`, `end`, `frags`, `payment`) VALUES (" .. guild .. ", " .. enemy .. ", " .. begining .. ", " .. ending .. ", " .. frags .. ", " .. payment .. ");")
        doBroadcastMessage(getPlayerGuildName(cid) .. " has invited " .. enemyName .. " to war till " .. frags .. " frags.", MESSAGE_EVENT_ADVANCE)
        return true
    end
    if(not isInArray({"end", "finish"}, t[1])) then
        return false
    end
    local status = (t[1] == "end" and 1 or 4)
    tmp = db.getResult("SELECT `id` FROM `guild_wars` WHERE `guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy .. " AND `status` = " .. status)
    if(tmp:getID() ~= -1) then
        local query = "UPDATE `guild_wars` SET `end` = " .. os.time() .. ", `status` = 5 WHERE `id` = " .. tmp:getDataInt("id")
        tmp:free()
        doGuildRemoveEnemy(guild, enemy)
        doGuildRemoveEnemy(enemy, guild)
        db.query(query)
        doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. (status == 4 and "mend fences" or "ended up a war") .. " with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
        return true
    end
    if(status == 4) then
        doPlayerSendChannelMessage(cid, "", "Currently there's no pending war truce from " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
        return true
    end
    tmp = db.getResult("SELECT `id`, `end` FROM `guild_wars` WHERE `guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild .. " AND `status` = 1")
    if(tmp:getID() ~= -1) then
        if(tmp:getDataInt("end") > 0) then
            tmp:free()
            doPlayerSendChannelMessage(cid, "", "You cannot request ending for war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
            return true
        end
        local query = "UPDATE `guild_wars` SET `status` = 4, `end` = " .. os.time() .. " WHERE `id` = " .. tmp:getDataInt("id")
        tmp:free()
        db.query(query)
        doBroadcastMessage(getPlayerGuildName(cid) .. " has signed an armstice declaration on a war with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
        return true
    end
    doPlayerSendChannelMessage(cid, "", "Currently there's no active war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
    return true
end

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...