Advertisement
Guest User

Untitled

a guest
Jan 9th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.68 KB | None | 0 0
  1. local function voteGravDone(t)
  2.     --local results = t.results
  3.    
  4.     --if results[0] < results[1] then
  5.         --str = "Vote results: option 'Low' has won."
  6.         --ulx.rcon( _, "sv_gravity 250" )
  7.     --else
  8.         --str = "Vote results: option 'Default' has won."
  9.         --ulx.rcon( _, "sv_gravity 600" )
  10.     --end
  11.     local results = t.results
  12.     local winner
  13.     local winnernum = 0
  14.     for id, numvotes in pairs( results ) do
  15.         if numvotes > winnernum then
  16.             winner = id
  17.             winnernum = numvotes
  18.         end
  19.     end
  20.  
  21.     local str
  22.     if not winner then
  23.         str = "Vote results: No option won because no one voted!"
  24.     else
  25.         if winner == 0 then
  26.         str = "Option 'Low' has won!"
  27.         ulx.rcon( _, "sv_gravity 250" )
  28.         else
  29.         str = "Option 'Default' has won!"
  30.         ulx.rcon( _, "sv_gravity 600" )
  31.         end
  32.     end
  33.     ULib.tsay( _, str ) -- TODO, color?
  34.     ulx.logString( str )
  35.     Msg( str .. "\n" )
  36. end
  37.  
  38. function ulx.voteGrav( calling_ply )
  39.    
  40.     --if voteInProgress then
  41.        
  42.         --ULib.tsayError( calling_ply, "There is already a vote in progress. Please wait for the current one to end.", true)
  43.        
  44.         --return
  45.     --end
  46.    
  47.     --local msg = "Change the server gravity to:"
  48.    
  49.     --ulx.doVote( msg, { "Default", "Low" }, voteGravDone, _, _, _ )
  50.    
  51.     if ulx.voteInProgress then
  52.         ULib.tsayError( calling_ply, "There is already a vote in progress. Please wait for the current one to end.", true )
  53.         return
  54.     end
  55.  
  56.     ulx.doVote( "Change the server gravity to:", {"Low", "Default"}, voteGravDone )
  57.     ulx.fancyLogAdmin( calling_ply, "#A started a vote #s", "to change the gravity" )
  58. end
  59. local votegrav = ulx.command( "Voting", "ulx votegrav", ulx.voteGrav, "!votegrav" )
  60. votegrav:defaultAccess( ULib.ACCESS_ALL )
  61. votegrav:help( "Vote to change the server gravity." )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement