Siema, jeszcze nie skończyłem, ale wam się podjaram co mam (nie testowane) i dajcie swoje sugestie co zmienić/poprawić.
To jest LIB
Niedługo zrobię do tego talkactiony /tribunal help /tribunal report namegracza, powod /tribunal vote idreportu, yesLUBno
Do tego dodam addEvent po złożeniu reportu, który po X czasie sprawdzi czy jest wymagana większość lub globalevent, który będzie sprawdzał co jakiś czas liczbę głosów
Dawajcie swoje sugestie.
Chyba dodam też datę reportu kiedy został złożony ;p
11/03/2013 17:22 zaktualizowałem LIB, więcej opcji i funkcji i zmieniłem nazwy zmiennych na angielskie
11/03/2013 17:52 zaktualizowałem LIB, poprawiłem parę funkcji i zastąpiłem jedną z pętli jako nowa funkcja jakby
To jest LIB
Lua:
-- Tribunal System --
-- ~~~~~~~~ By Seminari ~~~~~~ --
-- //// | \\\\ --
-- / __ __ \ --
-- |[*] | [*]| --
-- | ^ | --
-- \ \_____/ / --
-- --\___/-- --
-- \______/ --
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ --
-- (the_hide = seminari = iranimes)
--[[
Paste it to database:
CREATE TABLE IF NOT EXISTS `tribunal_reports` (
`id` smallint(5) unsigned NOT NULL auto_increment,
`report_player` varchar(255) NOT NULL,
`tutor_name` varchar(255) NOT NULL,
`reason` varchar(255) NOT NULL,
`status` varchar(255) NOT NULL,
`vote_yes` varchar(255) NOT NULL,
`vote_no` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
)ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
CREATE TABLE IF NOT EXISTS `tribunal_tutor_voted` (
`id` smallint(5) unsigned NOT NULL auto_increment,
`report_id` varchar(255) NOT NULL,
`tutor_name` varchar(255) NOT NULL,
`voted` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
)ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
---------------------------------------------------->
]]--
--[[
[done] 1. tutor reportuj gracza
[done] 2. tworzy w bazie danych; reportowny gracz, tutor, powod(reason), i pola na vote yes/no (przy reporcie od razu dodaje do Yes 1
[done] 3. wysyla tutorom info, ze zostal zraportowany gracz przez tutora z powodu iz
[done] 4. tutorzy moga zaglosowac yes/no czy go zbanowac (uzywaja komendy najpierw do wyswietlenia raportu, a potem glosouja komenda)
>>>>>>> Punkty 5-8 zmienic by nie przy kazdym reporcie sprawdzalo tak/nie tylko globalevent lub addevent
5. przy kazdym glosowanie skrypt sprawdza ile juz jest na yes, jesli na tak jest okreslona liczba tutorow, to dana osoba dostaje bana
6. gdy osoba dostaje bana to tutorzy i caly server jest informowany o tym
7. mozna uniewinnic gracza, jesli na nie bedzie okreslona liczba tutorow
8. jesli wymog minimalny na tak/nie zostanie przekroczony to decyduje wiekszosc 2/3 glosow lub admin
]]--
TRIBUNAL_BY_SEMI_CONFIG = {
tutor_acces = 2,
name_of_database = getConfigInfo('sqlDatabase'),
minimum_vote_on_yes_to_ban = 5,
minimum_vote_on_no_to_block_verdict = 5,
how_many_percent_votes_on_YES_to_ban_player = 60,
ban_lenght = 10,
}
function TRIBUNAL_BY_SEMI_dbquery(tresc)
db.query(tresc)
end
function TRIBUNAL_BY_SEMI_dbgetResult(tresc)
db.getResult(tresc)
end
function TRIBUNAL_BY_SEMI_send_player_white_text(cid, text)
doPlayerSendTextMessage(cid, 18, text)
end
function TRIBUNAL_BY_SEMI_send_msg_to_tutors(type, text)
online_players = getOnlinePlayers()
for i = 1, #online_players do
if getPlayerAccess(getPlayerByName(online_players[i])) >= c.tutor_acces then
if type == "white" then
TRIBUNAL_BY_SEMI_send_player_white_text(getPlayerByName(online_players[i]), text)
end
end
end
end
function TRIBUNAL_BY_SEMI_ban(report_id, reason, reported_player_name)
c = {
ban_lenght = TRIBUNAL_BY_SEMI_CONFIG.ban_lenght, -- in hours
}
text_to_broadcast = "<><><><><><><><><><><> ERROR IN TRIBUNAL SYSTEM IN VERDICT <><><><><><><>><><><><>"
player_GUID = getPlayerGUIDByName(reported_player_name, true)
player_account = getAccountIdByName(reported_player_name)
doAddAccountBanishment(player_account, player_GUID, c.ban_lenght * 3600 + os.time(),18, ACTION_BANISHMENT, "[Tribunal]: ".. reason .."")
local change_status_this_report = TRIBUNAL_BY_SEMI_dbgetResult("SELECT `id`, `status` FROM `tribunal_reports` WHERE `id`='" .. tonumber(report_id) .. "' AND `status`='waiting'")
if(change_status_this_report:getID() ~= -1) then
current_status = change_status_this_report:getDataString("status")
TRIBUNAL_BY_SEMI_dbquery("UPDATE `tribunal_reports` SET `status` = 'banned' WHERE `id` = " .. tonumber(report_id) .. ";")
text_to_broadcast = "[Tribunal] Banned player with name: ".. reported_player_name ..", for: ".. reason .."."
else
text_to_broadcast = "[Tribunal] Banned player, but can't update in database, report it."
print("[Tribunal] Banned player, but can't update in database, report it.")
end
doBroadcastMessage(text_to_broadcast)
end
function TRIBUNAL_BY_SEMI_verdict(report_id)
local c = {
minimum_vote_on_yes_to_ban = TRIBUNAL_BY_SEMI_CONFIG.minimum_vote_on_yes_to_ban,
minimum_vote_on_no_to_block_verdict = TRIBUNAL_BY_SEMI_CONFIG.minimum_vote_on_no_to_block_verdict,
how_many_percent_votes_on_YES_to_ban_player = TRIBUNAL_BY_SEMI_CONFIG.how_many_percent_votes_on_YES_to_ban_player,
--[[
if minimum vote on yes to ban and minimum vote on no to block verdict are broken, then to banishment player, tribunal needs X% votes on YES.
]]--
}
local verdict_text = "[TRIBUNAL] "
local select_report = TRIBUNAL_BY_SEMI_dbgetResult("SELECT `report_player`, `tutor_name` ,`reason` ,`vote_yes`, `vote_no` FROM `tribunal_reports` WHERE `id`='" .. tonumber(report_id) .. "' AND `status`='waiting'")
if(select_report:getID() ~= -1) then
how_many_vote_on_yes = select_report:getDataInt("vote_yes")
how_many_vote_on_no = select_report:getDataInt("vote_no")
o_id = select_report:getDataString("id")
reported_player = select_report:getDataString("report_player")
tutor = select_report:getDataString("tutor_name")
reason = select_report:getDataString("reason")
all_votes = how_many_vote_on_yes + how_many_vote_on_no
if how_many_vote_on_yes < c.minimum_vote_on_yes_to_ban then
verdict_text = "Report [".. o_id .."] about player:".. player_name ..". Votes: [Yes: ".. how_many_vote_on_yes ..", No: ".. how_many_vote_on_no .."]. Minimum vote on yes to ban: ".. c.minimum_vote_on_yes_to_ban .."."
elseif how_many_vote_on_yes >= c.minimum_vote_on_yes_to_ban then
if how_many_vote_on_no < c.minimum_vote_on_no_to_block_verdict then
verdict_text = "Report [".. o_id .."] about player:".. player_name ..". Votes: [Yes: ".. how_many_vote_on_yes ..", No: ".. how_many_vote_on_no .."]. Tribunal added banishment to this player."
TRIBUNAL_BY_SEMI_ban(o_id, reason, reported_player)
elseif how_many_vote_on_no >= c.minimum_vote_on_no_to_block_verdict then
one_percent_of_all_votes = all_votes/100
votes_on_YES_in_percet = how_many_vote_on_yes/one_percent_of_all_votes
votes_on_NO_in_percet = how_many_vote_on_no/one_percent_of_all_votes
if votes_on_YES_in_percet >= c.how_many_percent_votes_on_YES_to_ban_player then
verdict_text = "Report [".. o_id .."] about player:".. player_name ..". Votes: [Yes: ".. how_many_vote_on_yes .." (".. votes_on_YES_in_percet .."%), No: ".. how_many_vote_on_no .." (".. votes_on_NO_in_percet .."%)]. Tribunal added banishment to this player."
TRIBUNAL_BY_SEMI_ban(o_id, reason, reported_player)
else
verdict_text = "Report [".. o_id .."] about player:".. player_name ..". Votes: [Yes: ".. how_many_vote_on_yes .." (".. votes_on_YES_in_percet .."%), No: ".. how_many_vote_on_no .." (".. votes_on_NO_in_percet .."%)]. Tribunal can't ban because he need minimum ".. c.how_many_percent_votes_on_YES_to_ban_player .."% votes on yes."
end
end
end
TRIBUNAL_BY_SEMI_send_msg_to_tutors("white", verdict_text)
end
end
function TRIBUNAL_BY_SEMI_reportPlayer(name_of_tutor_which_is_reporting, reported_player_name, reason_text)
local c = {
name_of_database = TRIBUNAL_BY_SEMI_CONFIG.name_of_database,
tutor_acces = TRIBUNAL_BY_SEMI_CONFIG.tutor_acces,
}
report_player = reported_player_name
tutor_name = name_of_tutor_which_is_reporting
reason = reason_text
status = "waiting"
vote_yes = 1
vote_no = 0
TRIBUNAL_BY_SEMI_dbquery("INSERT INTO `" .. c.name_of_database .."`.`tribunal_reports`(`report_player`, `tutor_name` ,`reason` ,`status`,`vote_yes`, `vote_no` )VALUES ('" .. report_player .. "', '1', '" .. tutor_name .. "', '" .. reason .. "', '" .. status .. "', '" .. vote_yes .. "', '" .. vote_no .. "');")
TRIBUNAL_BY_SEMI_send_msg_to_tutors("white", "Tutor with name: ".. tutor_name .." reported: ".. report_player ..", please vote in tribunal, for more info use /tribunal help.")
end
function TRIBUNAL_BY_SEMI_more_info(cid)
info_about_tribunal_text = "Avivable commands:\n \t/tribunal help - display info about tribunal system and commands\n\t/tribunal report param1, param2 - report player with name (param1) for reason (param2)\n\t\tExample: /tribunal report Lanceq, He is trolling in depo\n\t/tribunal check - display info about reported players\n\t/tribunal vote param1, param2, param3 - vote for report with id (param1) <-- use /tribunal check to check id of report, param2 <-- yes or no, param3 <-- put here your commet why you voting yes or no\n\t\tExample: /tribunal vote 15, yes, This player is trolling rlly.\n\nHave fun :)\n\t\t\t Your Seminari(the_hide)(iranimes)"
TRIBUNAL_BY_SEMI_send_player_white_text(cid, "Avivable commands are displayed in text book.")
doShowTextDialog(cid, 2529, info_about_tribunal_text)
end
function TRIBUNAL_BY_SEMI_check_reports(cid)
local lista = TRIBUNAL_BY_SEMI_dbgetResult("SELECT `id`, `report_player`, `tutor_name` ,`reason` ,`vote_yes`, `vote_no` FROM `tribunal_reports` WHERE `status`='waiting'")
if(lista:getID() ~= -1) then
local reports_in_check_reports_text = ''
repeat
o_id = lista:getDataString("id")
reported_player = lista:getDataString("report_player")
tutor = lista:getDataString("tutor_name")
reason = lista:getDataString("reason")
vote_yes = lista:getDataInt("vote_yes")
vote_no = lista:getDataInt("vote_no")
reports_in_check_reports_text = reports_in_check_reports_text .. "[".. o_id .. "] Reported: " .. reported_player .. ". Tutor: " .. tutor .. ". Reason: " .. reason ..". Votes: [Yes(Ban):" .. vote_yes ..", No(don't ban):" .. vote_no .. "] \n"
until not lista:next()
lista:free()
first_line_of_check_reports_text = "Remember ID of report and then vote using command /tribunal vote ID, yes or no\nMore info about tribunal by /tribunal help\n\n"
check_reports_text = first_line_of_check_reports_text .. reports_in_check_reports_text
else
check_reports_text = "Sorry but at this time there is no reports active."
end
doShowTextDialog(cid, 2529, check_reports_text)
end
function TRIBUNAL_BY_SEMI_vote(cid, report_id, vote, comment_from_voting_tutor)
local c = {
name_of_database = TRIBUNAL_BY_SEMI_CONFIG.name_of_database,
}
if (vote == "yes" or vote == "no") and comment_from_voting_tutor ~= nil and comment_from_voting_tutor ~= "" then
local check_is_this_tutor_allready_voted_this_report = TRIBUNAL_BY_SEMI_dbgetResult("SELECT `id`, `voted` FROM `tribunal_tutor_voted` WHERE `id`='" .. tonumber(report_id) .. "' AND `tutor_name`='".. getPlayerName(cid) .."'")
if(check_is_this_tutor_allready_voted_this_report:getID() ~= -1) then
how_he_voted = check_is_this_tutor_allready_voted_this_report:getDataString("voted")
TRIBUNAL_BY_SEMI_send_player_white_text(cid, "You allready voted in report with id [".. report_id .."], you voted [".. how_he_voted .."]")
check_is_this_tutor_allready_voted_this_report:free()
else
local reporcik = TRIBUNAL_BY_SEMI_dbgetResult("SELECT `report_player`, `tutor_name` ,`reason` ,`vote_yes`, `vote_no` FROM `tribunal_reports` WHERE `id`='" .. tonumber(report_id) .. "' AND `status`='waiting'")
if(reporcik:getID() ~= -1) then
how_many_vote_on_yes = reporcik:getDataInt("vote_yes")
how_many_vote_on_no = reporcik:getDataInt("vote_no")
if vote == "yes" then
TRIBUNAL_BY_SEMI_dbquery("UPDATE `tribunal_reports` SET `vote_yes` = '".. how_many_vote_on_yes + 1 .."' WHERE `id` = " .. tonumber(report_id) .. ";")
elseif vote == "no" then
TRIBUNAL_BY_SEMI_dbquery("UPDATE `tribunal_reports` SET `vote_no` = '".. how_many_vote_on_no + 1 .."' WHERE `id` = " .. tonumber(report_id) .. ";")
end
db.query("INSERT INTO `" .. c.name_of_database .."`.`tribunal_tutor_voted`(`report_id` ,`tutor_name` ,`voted`, `comment` )VALUES ('" .. report_id .. "', '" .. getPlayerName(cid) .. "', '" .. vote .. "', '".. comment_from_voting_tutor .."');")
TRIBUNAL_BY_SEMI_send_player_white_text(cid, "You voted in report [".. report_id .."], on [".. vote .."]. Thanks.")
if how_many_vote_on_yes >= TRIBUNAL_BY_SEMI_CONFIG.minimum_vote_on_yes_to_ban - 1 then
TRIBUNAL_BY_SEMI_verdict(report_id)
end
end
end
else
TRIBUNAL_BY_SEMI_send_player_white_text(cid, "Sorry but you can only vote 'yes' or 'no'. You voted [".. vote .."]. Vote again!")
end
end
Niedługo zrobię do tego talkactiony /tribunal help /tribunal report namegracza, powod /tribunal vote idreportu, yesLUBno
Do tego dodam addEvent po złożeniu reportu, który po X czasie sprawdzi czy jest wymagana większość lub globalevent, który będzie sprawdzał co jakiś czas liczbę głosów
Dawajcie swoje sugestie.
Chyba dodam też datę reportu kiedy został złożony ;p
11/03/2013 17:22 zaktualizowałem LIB, więcej opcji i funkcji i zmieniłem nazwy zmiennych na angielskie
11/03/2013 17:52 zaktualizowałem LIB, poprawiłem parę funkcji i zastąpiłem jedną z pętli jako nowa funkcja jakby
Last edited: