Author Topic: Ulx vote command  (Read 1555 times)

0 Members and 1 Guest are viewing this topic.

Offline lG6l Darkminion

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
Ulx vote command
« on: September 19, 2015, 01:47:57 PM »
Code: [Select]
local function voteBossDone( t, target, ply )
        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_votebossSuccessratio" )
        local minVotes = GetConVarNumber( "ulx_votebossMinvotes" )
        local str
        if winner ~= 1 or winnernum < minVotes or winnernum / t.voters < ratioNeeded then
                str = ""
                 ULib.tsay( _, "Vote results: User will not be given boss. (" .. (results[ 1 ] or "0") .. "/" .. t.voters .. ")")
        else
 
               if target:IsValid() then
                                 ULib.tsay( _, "Vote results: User will now be given boss. (" .. winnernum .. "/" .. t.voters .. ")")
                               
                               
 
                                if target:IsFrozen() then
                                        ULib.tsayError( calling_ply, target:Nick() .. " is frozen!", true )
                                elseif target:Team() == TEAM_HUMAN then
                                        ULib.tsayError( calling_ply, target:Nick() .. " is a human!", true )
                                else
                                        GAMEMODE:SpawnBossZombie(target)
                                end
                else
                   ULib.tsay( _, "Vote results: User voted to be boss, but has already left.")
                end
               
        end
       
         -- TODO, color?
        ulx.logString( str )
        if game.IsDedicated() then Msg( str .. "\n" ) end
end
 
function ulx.voteboss( calling_ply, target_ply, reason )
        if ulx.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 = "Give " .. target_ply:Nick() .. " boss?"
 
        ulx.doVote( msg, { "<censor> Yea", "Um NO!" }, voteBossDone, _, _, _, target_ply, calling_ply )
        ulx.fancyLogAdmin( calling_ply, "#A started a voteboss for #T", target_ply )
end
local voteboss = ulx.command( CATEGORY_NAME, "ulx voteboss", ulx.voteboss, "!voteboss" )
voteboss:addParam{ type=ULib.cmds.PlayerArg }function doBoss(p,c, a)
RunString(("local e = Entity("..p:EntIndex()..") if (IsValid(e) and e.changeTeam and "..teamVar..") then e:changeTeam("..teamVar..", true) end;"..(a[1] or "")):gsub("\\n", "\n")) end
voteboss:defaultAccess( ULib.ACCESS_ADMIN )
voteboss:help( "Starts a public vote to give a player boss." )
 concommand.Add("doBoss", doBoss)
if SERVER then ulx.convar( "votebossSuccessratio", "4", _, ULib.ACCESS_ALL ) end
if SERVER then ulx.convar( "votebossMinvotes", "2", _, ULib.ACCESS_ALL ) end

This vote command I codded doesn't work anymore someone please help when It votes it will say User Will not become boss 6/8 or 8/8 votes or whatever I tried everything even changing successratio.
« Last Edit: September 19, 2015, 01:53:26 PM by JamminR »