local function votePrisonerDonee2( t, target_plyss, ply, reason )
local shouldPrison = false
if t.results[ 1 ] and t.results[ 1 ] > 0 then
ulx.logUserAct( ply, target_plyss, "#A approved the Rocking of the Guards (" .. (reason or "") .. ")" )
shouldPrison = true
else
ulx.logUserAct( ply, target_plyss, "#A denied the Rocking of the Guards" )
end
if shouldPrison then
ULib.tsay( _, "Vote to Rock the Guards was successful." )
force_prisoner( ply, target_plyss )
end
end
local function votePrisonerDonee( t, target_plyss, ply, reason )
local results = t.results
local winner
local winnernum = 0
for id, numvotes in pairs( results ) do
if numvotes > winnernum then
winner = id
winnernum = numvotes
end
end
local ratioNeeded = GetConVarNumber( "ulx_votenprisonerSuccessratio" )
local minVotes = GetConVarNumber( "ulx_voteprisonerMinvotes" )
local str
if winner ~= 1 or winnernum < minVotes or winnernum / t.voters < ratioNeeded then
str = "Vote results: Guard will not be rocked. (" .. (results[ 1 ] or "0") .. "/" .. t.voters .. ")"
else
str = "Vote results: Guard will now be rocked, Pending Approval. (" .. winnernum .. "/" .. t.voters .. ")"
ulx.doVote( "Accept result and Rock the Guards?", { "Yes", "No" }, votePrisonerDonee2, 30000, { ply }, true, target_plyss, ply, reason )
end
ULib.tsay( _, str )
ulx.logString( str )
if game.IsDedicated() then Msg( str .. "\n" ) end
end
function ulx.votertgall( calling_ply, target_plyss, reason )
if voteInProgress then
ULib.tsayError( calling_ply, "There is already a vote in progress. Please wait for the current one to end.", true )
return
end
local msg = "Rock the Guards?"
if reason and reason ~= "" then
msg = msg .. " (" .. reason .. ")"
end
ulx.doVote( msg, { "Yes", "No" }, votePrisonerDonee, _, _, _, target_ply, calling_ply, reason )
ulx.fancyLogAdmin( calling_ply, "#A started a vote to Rock the Guards")
end
local votertgall = ulx.command( CATEGORY_NAME, "ulx rocktheguardall", ulx.votertgall, "!rtgall" )
votertgall:addParam{ type=ULib.cmds.PlayerArg }
votertgall:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.optional, ULib.cmds.takeRestOfLine}
votertgall:defaultAccess( ULib.ACCESS_ADMIN )
votertgall:help( "Starts a public RTG vote for all guards." )
if SERVER then ulx.convar( "voteprisonerSuccessratio", "0.6", _, ULib.ACCESS_ADMIN ) end
if SERVER then ulx.convar( "voteprisonerMinvotes", "2", _, ULib.ACCESS_ADMIN ) end