Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.18 KB | None | 0 0
  1. -- ****************************************************************************
  2. --
  3. -- RECURSO: Bigeye
  4. -- ARCHIVO: comandos.lua
  5. -- PROPOSITO: Comandos de servidor.
  6. -- CREADORES: Stefano Aguilera Humeney < Gothem >
  7. --
  8. -- ****************************************************************************
  9.  
  10. function f_agregarBan ( admin, jugador, razon, tiempo, ip, cuenta, serial )
  11.  
  12. -- Revisa que efectivamente se posean los permisos para expulsar al jugador.
  13. if not Permiso ( admin, 'command.ban' ) then return false end
  14.  
  15. -- Revisa si es que el jugador esta en juego
  16. if type( jugador ) == 'string' then
  17.  
  18. jugador = ( t_jugadores[ tonumber(jugador) ] ) and t_jugadores[tonumber(jugador)][1] or getPlayerFromName( jugador ) or jugador
  19.  
  20. end
  21.  
  22. -- Si es que es un jugador en juego, lo expulsa.
  23. if isElement( jugador ) then
  24.  
  25. -- Previene que se expulse a si mismo.
  26. if admin == jugador then
  27.  
  28. outputChatBox ( '[BIGEYE] Por qué te intentas expulsar a ti mismo?', admin, 255, 0, 0 )
  29. return false
  30.  
  31. end
  32.  
  33. if not ip and not cuenta and not serial then
  34. outputChatBox ( '[BIGEYE] No hay metodo para expulsar...', admin, 255, 0, 0 )
  35. return false
  36. end
  37.  
  38. local nadm = admin.name
  39. local incg = admin:getData("mincogn")
  40. if incg and incg == 1 then
  41. nadm = "Un staff"
  42. else
  43. nadm = tostring(admin.name)
  44. end
  45.  
  46. outputServerLog("BIGEYE: BAN | ".. jugador.name .." | ".. admin.name .." | "..tiempo )
  47. if tonumber(tiempo) == 0 then
  48. outputChatBox ( '[BIGEYE] ' .. nadm .. ' ha baneado perma a ' .. jugador.name..' #ffffff(Razón: '..tostring(razon)..')', root, 255, 0, 0, true )
  49. elseif (tonumber(tiempo) > 0 and tonumber(tiempo) < 3600) then
  50. outputChatBox ( '[BIGEYE] ' .. nadm .. ' ha baneado a ' .. jugador.name..' por '..tonumber(tiempo/60)..' minutos #ffffff(Razón: '..tostring(razon)..')', root, 255, 0, 0, true )
  51. elseif (tonumber(tiempo) >= 3600 and tonumber(tiempo) < 86400) then
  52. outputChatBox ( '[BIGEYE] ' .. nadm .. ' ha baneado a ' .. jugador.name..' por '..tonumber(math.ceil(tiempo/3600))..' horas #ffffff(Razón: '..tostring(razon)..')', root, 255, 0, 0, true )
  53. elseif (tonumber(tiempo) >= 86400) then
  54. outputChatBox ( '[BIGEYE] ' .. nadm .. ' ha baneado a ' .. jugador.name..' por '..tonumber(math.ceil(tiempo/86400))..' días #ffffff(Razón: '..tostring(razon)..')', root, 255, 0, 0, true )
  55. end
  56.  
  57. if cuenta then
  58. setAccountData(cuenta,"be_ban_cuenta",getRealTime().timestamp+tiempo)
  59. end
  60. return banPlayer ( jugador, ip and true or false, true, serial and true or false , admin, razon, tiempo )
  61. --return addBan()
  62.  
  63. end
  64.  
  65. -- Previene expulsión a si mismo.
  66. if ip == admin.ip or cuenta == admin.getAccount(admin) or serial == admin.serial then
  67.  
  68. outputChatBox ( '[BIGEYE] Por qué te intentas expulsar a ti mismo?', admin, 255, 0, 0 )
  69. return false
  70.  
  71. end
  72.  
  73. return addBan ( ip, getAccountName(cuenta) or cuenta, serial, admin, razon, tiempo )
  74.  
  75. end
  76.  
  77. function f_ban_handler ( admin, _, jugador, tiempo, ip, serial, ... )
  78.  
  79. local razon = table.concat( {...}, " " )
  80. ip = ( ip and ip:find("%w+%.%w+%.%w+%.%w+") ) and ip or nil
  81. serial = ( serial and serial:len() == 32 ) and serial or nil
  82.  
  83. if not jugador or not tiempo then
  84.  
  85. outputChatBox ( '[BIGEYE] /ban ( nombre_jugador | ID ) ( tiempo[s] ) [ (ip) (serial) ( razón ) ]', admin, 255, 255, 0 )
  86. return false
  87.  
  88. end
  89.  
  90. if not f_agregarBan ( admin, jugador, razon, tiempo, ip, serial ) then
  91.  
  92. outputChatBox ( '[BIGEYE] No se pudo agregar la expulsión!', admin, 255, 0, 0 )
  93. return false
  94.  
  95. end
  96.  
  97. return true
  98.  
  99. end
  100. addCommandHandler ( 'ban', f_ban_handler, true )
  101.  
  102. function f_be_ban_handler ( jugador, razon, tiempo, ip, cuenta, serial )
  103. if not jugador or not razon or not tiempo then
  104. outputDebugString ( 'Faltan argumentos @ f_be_ban_handler', 2 )
  105. return false
  106. end
  107.  
  108. if not ip and not cuenta and not serial then
  109. outputChatBox("[ERROR] No hay metodo de sanción.", source, 255, 0, 0)
  110. return
  111. end
  112.  
  113. if tiempo == '' then
  114. tiempo = 0
  115. end
  116. if cuenta then
  117. cuenta = getPlayerAccount(jugador)
  118. end
  119.  
  120. local nombre = ( type(jugador) == 'string' ) and jugador or getPlayerName(jugador)
  121. f_agregarBan ( client, jugador, razon, tiempo * 60, ip, cuenta, serial )
  122. end
  123. addEvent('be_ban', true)
  124. addEventHandler('be_ban', root, f_be_ban_handler)
  125.  
  126. addEvent("be_unban",true)
  127. addEventHandler("be_unban",root,function(Jugador, IP, Serial)
  128. local nombreadm = getAccountName(getPlayerAccount(source))
  129. if Permiso(source,"command.unban") then
  130. for k,v in ipairs(getBans()) do
  131. if getBanIP(v) == IP or getBanSerial(v) == Serial then
  132. outputServerLog("BIGEYE: UNBAN | "..nombreadm.." | "..tostring(getBanUsername(v)).." | "..tostring(getBanIP(v)))
  133. removeBan(v,source)
  134. end
  135. end
  136. local accusr = getAccount(tostring(Jugador))
  137. if accusr then
  138. setAccountData(accusr,"be_ban_cuenta",false)
  139. end
  140. end
  141. end)
  142.  
  143. function secoundsToDays(secound)
  144. if secound then
  145. local value,state
  146. if secound >= 86400 then
  147. value = math.floor(secound/86400)
  148. if secound - (value*86400) > (60*60) then
  149. value = value.." dias y "..math.floor((secound - (value*86400))/(60*60)).." horas"
  150. else
  151. value = value.." dias"
  152. end
  153. state = 1
  154. else
  155. value = 0 .." dias y "..math.floor(secound/(60*60)).." horas"
  156. state = 2
  157. end
  158. return value
  159. else
  160. return false
  161. end
  162. end
  163.  
  164. function antilogincuentaban(accpr,accact)
  165. local trban = getAccountData(accact,"be_ban_cuenta")
  166. local tiempo = getRealTime().timestamp
  167. if trban and tonumber(trban) > tonumber(tiempo) then
  168. kickPlayer(source,"Console","La cuenta a la que quieres acceder está baneada. Tiempo restante: "..secoundsToDays(tiempo-trban))
  169. elseif trban and tonumber(trban) < tonumber(tiempo) then
  170. setAccountData(accact,"be_ban_cuenta",false)
  171. end
  172. end
  173. addEventHandler("onPlayerLogin",root,antilogincuentaban)
  174.  
  175.  
  176. function f_kill_handler ( admin, _, jugador )
  177.  
  178. if not hasObjectPermissionTo(admin,"command.akill",false) then
  179. outputChatBox ( '[BIGEYE] No tienes acceso a este comando', admin, 255, 0, 0 )
  180. return
  181. end
  182.  
  183. if type(jugador) ~= 'string' then
  184. outputChatBox ( '[BIGEYE] No se a ingresado el jugador', admin, 255, 0, 0 )
  185. return
  186. end
  187.  
  188. local playerid = tonumber(jugador)
  189. jugador = getPlayerFromName( jugador )
  190. if playerid and t_jugadores[playerid] then
  191. outputChatBox ( '[BIGEYE] Asesinado ' .. t_jugadores[playerid][1].name, admin, 200, 200, 0 )
  192. killPed(t_jugadores[playerid][1])
  193. elseif isElement(jugador) then
  194. outputChatBox ( '[BIGEYE] Asesinado ' .. jugador.name, admin, 200, 200, 0 )
  195. killPed(jugador)
  196. else
  197. outputChatBox ( '[BIGEYE] No se encontro un jugador con ese nombre u id.', admin, 255, 0, 0 )
  198. end
  199.  
  200. end
  201. addCommandHandler('akill', f_kill_handler, true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement