Sasu Posted March 14, 2013 Posted March 14, 2013 Sorry but How to ban a player with number that I writed on Edit(Minutes). and only ban If I write a reason. Server-side: function banear(text, adminBanner, timeBan, editText) thePlayer = getPlayerFromName(text) if not thePlayer then outputChatBox("Selecciona a un jugador de la lista", source,255,0,0,true) return end if tonumber(timeBan) then theTimeBan = math.floor(tonumber(timeBan)*60*1000) banPlayer(thePlayer, false, false, true, adminBanner, editText, theTimeBan) end end addEvent("banHim", true) addEventHandler("banHim", getRootElement(), banear) Client-Side: function banearButton (text, adminBanner, timeBan, editText) if source == banButton then local timeBan = guiGetText(timeEdit) local selected = guiGridListGetSelectedItem( playerLista ) local text = guiGridListGetItemText( playerLista, selected, 1 ) local editText = guiGetText( reasonEdit ) local adminBanner = getPlayerName(getLocalPlayer()) if timeBan then triggerServerEvent("banHim", root, text, adminBanner, timeBan, editText) else outputChatBox("Escribe el tiempo de duracion",255,0,0,false) end end end addEventHandler("onClientGUIClick", root, banearButton)
OGF Posted March 14, 2013 Posted March 14, 2013 Instead of triggering the serverside event if TimeBan you can try if editText and editText ~= "" then TriggerSeverEvent here.
PaiN^ Posted March 14, 2013 Posted March 14, 2013 function banearButton (text, adminBanner, timeBan, editText) if source == banButton then local timeBan = guiGetText(timeEdit) local selected = guiGridListGetSelectedItem( playerLista ) local text = guiGridListGetItemText( playerLista, selected, 1 ) local editText = guiGetText( reasonEdit ) local adminBanner = getPlayerName(getLocalPlayer()) if string.len ( timeBan ) > 0 and string.len ( editText ) > 0 then triggerServerEvent("banHim", root, text, adminBanner, timeBan, editText) else outputChatBox("Escribe el tiempo de duracion",255,0,0,false) end end end addEventHandler("onClientGUIClick", root, banearButton) function banear(text, adminBanner, timeBan, editText) thePlayer = getPlayerFromName(text) if not thePlayer then outputChatBox("Selecciona a un jugador de la lista", source,255,0,0,true) return end if (timeBan) then theTimeBan = math.floor(tonumber(timeBan)*60*1000) banPlayer(thePlayer, false, false, true, adminBanner, editText, theTimeBan) end end addEvent("banHim", true) addEventHandler("banHim", getRootElement(), banear)
Sasu Posted March 14, 2013 Author Posted March 14, 2013 No. The reason its work but when I put 1 on timeBan it ban me 1363299062 miliseconds = 22721,651 minutes .__.
iPrestege Posted March 14, 2013 Posted March 14, 2013 No. The reason its work but when I put 1 on timeBan it ban me 1363299062 miliseconds = 22721,651 minutes .__. Yes because it's seconds : seconds: The amount of seconds the player will be banned from the server for. This can be 0 for an infinite amount of time.
Sasu Posted March 14, 2013 Author Posted March 14, 2013 No. The reason its work but when I put 1 on timeBan it ban me 1363299062 miliseconds = 22721,651 minutes .__. Yes because it's seconds : seconds: The amount of seconds the player will be banned from the server for. This can be 0 for an infinite amount of time. theTimeBan = math.floor(tonumber(timeBan)*60*1000) I convert the miliseconds to minutes . I writed 1 minute why it ban me for 22721,651 minutes -.-'
OGF Posted March 14, 2013 Posted March 14, 2013 It's not milliseconds, the default is in SECONDS, so what YOU did is seconds * 60 * 1000 Take a look at the syntax https://wiki.multitheftauto.com/wiki/BanPlayer
PaiN^ Posted March 14, 2013 Posted March 14, 2013 theTimeBan = math.floor(tonumber(timeBan)*60) + 1*60*1000 = 60000 How could it become ' 22721,651 minutes ' ?
Sasu Posted March 14, 2013 Author Posted March 14, 2013 ._. only show banlist.xml ._. "6144C81929C21A254E0A4D087C9C9794" banner="Sasuke*" reason="Chau bitch puta" time="1363299062" unban="1363359062"> Sorry for the reason :3
Castillo Posted March 14, 2013 Posted March 14, 2013 To convert seconds to minutes, use this: theTimeBan = math.floor ( tonumber ( timeBan ) / 60 )
Sasu Posted March 14, 2013 Author Posted March 14, 2013 (edited) The same time :C EDIT: I use the reason to get minutes ban and... ._. banPlayer(thePlayer, false, false, true, adminBanner, editText.. "( "..theTimeBan.." Min )", theTimeBan) and said 0 min ._. Edited March 14, 2013 by Guest
PaiN^ Posted March 14, 2013 Posted March 14, 2013 Where do you get: "timeBan" from? function banearButton (text, adminBanner, timeBan, editText) if source == banButton then local timeBan = guiGetText(timeEdit) local selected = guiGridListGetSelectedItem( playerLista ) local text = guiGridListGetItemText( playerLista, selected, 1 ) local editText = guiGetText( reasonEdit ) local adminBanner = getPlayerName(getLocalPlayer()) if string.len ( timeBan ) > 0 and string.len ( editText ) > 0 then triggerServerEvent("banHim", root, text, adminBanner, timeBan, editText) else outputChatBox("Escribe el tiempo de duracion",255,0,0,false) end end end addEventHandler("onClientGUIClick", root, banearButton) function banear(text, adminBanner, timeBan, editText) thePlayer = getPlayerFromName(text) if not thePlayer then outputChatBox("Selecciona a un jugador de la lista", source,255,0,0,true) return end if (timeBan) then theTimeBan = math.floor(tonumber(timeBan)*60*1000) banPlayer(thePlayer, false, false, true, adminBanner, editText, theTimeBan) end end addEvent("banHim", true) addEventHandler("banHim", getRootElement(), banear)
Castillo Posted March 14, 2013 Posted March 14, 2013 But that is useless, because the banPlayer function uses seconds, not minutes.
iPrestege Posted March 14, 2013 Posted March 14, 2013 But that is useless, because the banPlayer function uses seconds, not minutes. But can be converted .
Castillo Posted March 14, 2013 Posted March 14, 2013 What do you mean by "it can be converted"? the function only accepts seconds as ban time. seconds: The amount of seconds the player will be banned from the server for. This can be 0 for an infinite amount of time. @Sasuke: Multiply your "timeToBan" by 60.
iPrestege Posted March 14, 2013 Posted March 14, 2013 What do you mean by "it can be converted"? the function only accepts seconds as ban time.seconds: The amount of seconds the player will be banned from the server for. This can be 0 for an infinite amount of time. @Sasuke: Multiply your "timeToBan" by 60. Lol? but in the admin panel u can use min .
Sasu Posted March 14, 2013 Author Posted March 14, 2013 theTimeBan = math.floor(tonumber(timeBan)*60) Is it correctly?
Castillo Posted March 14, 2013 Posted March 14, 2013 Because the script converts it. @Sasuke: Yes, it should work.
OGF Posted March 15, 2013 Posted March 15, 2013 Sasuke, I told you it was seconds and to look at the syntax.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now