ULX

Author Topic: ulx VoteSlaynr  (Read 2246 times)

0 Members and 1 Guest are viewing this topic.

Offline Gregs0n

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
ulx VoteSlaynr
« on: October 07, 2013, 05:04:18 PM »
I had a look at making a ulx voteslaynr myself, but I'm still pretty new to lua. Does anyone have a code for this or could explain to me how to make it? I want the code to go to respected people on my TTT server so that rdm is still managable while there are no staff on. Thanks
« Last Edit: October 07, 2013, 05:25:56 PM by Gregs0n »

Offline Decicus

  • Hero Member
  • *****
  • Posts: 551
  • Karma: 81
    • Alex Thomassen
Re: ulx VoteSlaynr
« Reply #1 on: October 07, 2013, 05:45:28 PM »
Bender might be able to help you with something like this, he should still be around on the forums every once in a while and he was one of the two to develop the TTT commands addon/module/extension for ULX.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline bender180

  • Full Member
  • ***
  • Posts: 217
  • Karma: 42
    • Benders Villa
Re: ulx VoteSlaynr
« Reply #2 on: October 07, 2013, 07:05:11 PM »
ill see what i can do if i get some free time


EDIT: Hmmm vote system is a little more then i expected but ill see what i can do.
« Last Edit: October 07, 2013, 07:22:16 PM by bender180 »
Made community pool and community bowling and for the life of me couldn't tell you why they are popular.
Also made the ttt ulx commands.

Offline Gregs0n

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: ulx VoteSlaynr
« Reply #3 on: October 09, 2013, 01:03:58 AM »
Yeah thanks man, Its would greatly appreciated.

Offline caydpoe

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: ulx VoteSlaynr
« Reply #4 on: March 24, 2014, 09:54:01 AM »
I was wondering if any progress was made in this. My server could use something like this too.

Offline pineappleplays

  • Newbie
  • *
  • Posts: 12
  • Karma: 0
Re: ulx VoteSlaynr
« Reply #5 on: August 15, 2015, 09:19:19 PM »
hear

Code: Lua
  1. local CATEGORY_NAME  = "TTT Voting"
  2. local gamemode_error = "The current gamemode is not trouble in terrorest town"
  3.  
  4.  
  5. ---[Next Round Slay Voting]----------------------------------------------------------------------------
  6.  
  7. local function voteslaynrDone2( t, target, time, ply, reason )
  8.        
  9.     local shouldslaynr = false
  10.        
  11.         if t.results[ 1 ] and t.results [ 1 ] > 0 then
  12.                 shouldslaynr = true
  13.                 if reason then
  14.                         ulx.fancyLogAdmin( ply, "#A will allow #T to be slain next round for (#s)", target, reason )
  15.                 else
  16.                         ulx.fancyLogAdmin( ply, "#A will allow #T to be slain next round", target )
  17.                 end
  18.         else
  19.                 ulx.fancyLogAdmin( ply, "#A will not allow the slay of #T next round", target )
  20.         end
  21.  
  22.         if shouldslaynr then
  23.         if not GetConVarString("gamemode") == "terrortown" then ULib.tsayError( calling_ply, gamemode_error, true ) else
  24.             local target_ply = target:Nick()
  25.             --ULib.consoleCommand( "ulx slaynr " ..target:Nick().. "\n" ) --has issue with players with spaces in name
  26.             --going to write to pdata directly for more streamlined look
  27.            
  28.             local eslays = target:GetPData("slaynr_slays", 0) --get existing slays or 0
  29.             local nslays
  30.        
  31.             nslays = eslays + 1 --add the vote slay to the existing slays
  32.        
  33.             target:SetPData("slaynr_slays", nslays) --add the new slays
  34.             --heavy lifting will be done by existing slaynr command
  35.                        
  36.             target:ChatPrint("Based on a vote, you will be slain next round")
  37.         end
  38.        
  39.         end
  40. end
  41.  
  42. local function voteslaynrDone( t, target, time, ply, reason)
  43.         local results = t.results
  44.         local winner
  45.         local winnernum = 0
  46.         for id, numvotes in pairs( results ) do
  47.                 if numvotes > winnernum then
  48.                         winner = id
  49.                         winnernum = numvotes
  50.                 end
  51.         end
  52.        
  53.         local ratioNeeded = GetConVarNumber( "ulx_voteslaynrSuccessratio" )
  54.         local minVotes = GetConVarNumber( "ulx_voteslaynrMinvotes" )
  55.         local str
  56.         if winner ~= 1 or winnernum < minVotes or winnernum / t.voters < ratioNeeded then
  57.                 str = "Vote results: User will live next round. (" .. (results[ 1 ] or "0") .. "/" .. t.voters .. ")"
  58.         else
  59.                 str = "Vote results: User will be slain next round, pending approval. (" .. winnernum .. "/" .. t.voters .. ")"
  60.                 ulx.doVote( "Accept result and slay " .. target:Nick() .. "?", { "Yes", "No" }, voteslaynrDone2, 30000, { ply }, true, target, time, ply, reason )
  61.         end
  62.        
  63.         ULib.tsay( _, str ) -- TODO, color?
  64.         ulx.logString( str )
  65.         if game.IsDedicated() then Msg( str .. "\n" ) end
  66. end
  67.  
  68. function ulx.voteslaynr( calling_ply, target_ply, reason )
  69.         if voteInProgress then
  70.                 ULib.tsayError( calling_ply, "There is already a vote in progress. Please wait for the current one to end.", true )
  71.                 return
  72.         end
  73.  
  74.         local msg = "Slay " .. target_ply:Nick() .. " next round?"
  75.         if reason and reason ~= "" then
  76.                 msg = msg .. " (" .. reason .. ")"
  77.         end
  78.  
  79.         ulx.doVote( msg, { "Yes", "No" }, voteslaynrDone, _, _, _, target_ply, time, calling_ply, reason )
  80.         ulx.fancyLogAdmin( calling_ply, "#A wants to have #T slain next round", target_ply )
  81. end
  82.  
  83. local voteslaynr = ulx.command( CATEGORY_NAME, "ulx votesnr", ulx.voteslaynr, "!votesnr" )
  84. voteslaynr:addParam{ type=ULib.cmds.PlayerArg }
  85. voteslaynr:addParam{ type=ULib.cmds.StringArg, hint="Reason", ULib.cmds.optional, ULib.cmds.takeRestOfLine}
  86. voteslaynr:defaultAccess( ULib.ACCESS_ADMIN )
  87. voteslaynr:help( "Starts a vote to have the target slain the next round." )
  88. if SERVER then ulx.convar( "voteslaynrSuccessratio", "0.6", _, ULib.ACCESS_ADMIN ) end -- The ratio needed for a voteslaynr to succeed
  89. if SERVER then ulx.convar( "voteslaynrMinvotes", "1", _, ULib.ACCESS_ADMIN ) end -- Minimum votes needed for voteslaynr
  90.  

Just for the record i did not code this I don't know who did I just have it on my server