• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Help create function "isplayerinwar"

chiitus

Member
Joined
Jun 1, 2009
Messages
206
Reaction score
12
Hi guys, i need to create a message every time someone is killed and this player is on war system against other guild to show the score, like:

[WAR-SYSTEM] Your guild score: X / Enemy guild score: Y

Build-in some function, like "onpreparedeath":

function onpreparedeath(i don't remember exactly what go here)
function isplayerinwar(cid)
some sql querys here to get info about guild war is going on(i'm really noob in sql codes)
-- return the value in 1 or 0
end
if isplayerinwar(killer) and isplayerinwar(cid) then
local players = getPlayersOnline()
for _, pid in ipairs(players) do
if isplayerinwar(killer) or isplayerinwar(cid) then
doPlayerSendChannelMessage(pid, "[WAR-SYSTEM]", "The values here", TALKTYPE_CHANNEL_W, CHANNEL_GUILD)
end
end
end
return true
end

Please this is very usefull to war with too much frags, because i have this in gesior acc, but not in server itself.
Thanks adv!
 
EDIT: I tried this function in playerdeath, but the script don't do anything and don't return any errors:

local result = db.getResult("SELECT * FROM `guild_wars` WHERE `end` = 0;")
if result:getID() ~= -1 then
while(true) do
--here comes your code
if getPlayerGuildId(cid) == result:getDataInt("guild_id") and getPlayerGuildId(lastHitKiller) == result:getDataInt("enemy_id") then
local msg = "PONTUAÇÃO: SUA GUILD - " .. result:getDataInt("guild_kills") .. " de " .. result:getDataInt("frags") .. " frags. GUILD INIMIGA" .. result:getDataInt("enemy_kills") .. " de " .. result:getDataInt("frags") .. " frags."
elseif getPlayerGuildId(cid) == result:getDataInt("enemy_id") and getPlayerGuildId(lastHitKiller) == result:getDataInt("guild_id") then
local msg = "PONTUAÇÃO: SUA GUILD - " .. result:getDataInt("enemy_kills") .. " de " .. result:getDataInt("frags") .. " frags. GUILD INIMIGA" .. result:getDataInt("guild_kills") .. " de " .. result:getDataInt("frags") .. " frags."
end
if not result:next() then break end
end
end

for _, pid in ipairs(getPlayersOnline()) do
if getPlayerGuildId(pid) == result:getDataInt("guild_id") or getPlayerGuildId(pid) == result:getDataInt("enemy_id") then
doPlayerOpenChannel(pid, CHANNEL_GUILD)
addEvent(doPlayerSendChannelMessage, 1000, pid, "[WAR-SYSTEM]", msg, TALKTYPE_CHANNEL_O, CHANNEL_GUILD)
end
end

Any help please?
 
Back
Top