Jump to content

ban player


Sasu

Recommended Posts

When I use

  
banPlayer(thePlayer, false, false, true, adminBanner, "Razon: "..editText.." [ "..timeBan.." Min ] ", theTimeBan) 

on the admin panel in column 'nick' ( first column ) returns me N/A, so return false. Why?

All arguments are defined.

Link to comment
Are you doing something like so .. ?
  
  
playerToBan = guiGridListGetItemText ( playerlist, guiGridListGetSelectedItem ( playerlist ), 1 ) 
  
triggerServerEvent ( "yourEventHere", root, playerToBan ) 
  
  

Yes. And In server I convert with getPlayerFromName.

Link to comment

Client:

function banearButton (text, adminBanner, timeBan, editText) 
    if source == banButton then 
local timeBan = guiGetText(timeEdit) 
    local selected = guiGridListGetSelectedItem( listaPlayers ) 
        local text = guiGridListGetItemText( listaPlayers, selected, 1 ) 
            local editText = guiGetText( reasonEdit ) 
                local adminBanner = getPlayerName(getLocalPlayer()) 
    if string.len ( editText ) > 0 then 
        if string.len ( timeBan ) > 0 then 
            triggerServerEvent("banHim", root, text, adminBanner, timeBan, editText) 
        else 
            outputChatBox("Escribe el tiempo de duracion",255,0,0,false) 
            end 
        else 
            outputChatBox("Escribe la razon para banearlo.",255,0,0,false) 
        end 
    end 
end 
addEventHandler("onClientGUIClick", root, banearButton) 

Server:

function banear(text, adminBanner, timeBan, editText) 
    local thePlayer = getPlayerFromName(text) 
    if not thePlayer then 
        outputChatBox("Selecciona a un jugador de la lista", source,255,0,0,true) return end 
        local adminPermisos = getPlayerFromName(adminBanner) 
        if ( hasObjectPermissionTo ( adminPermisos, "function.banPlayer", true ) ) then 
    if (timeBan) then 
        theTimeBan = math.floor ( tonumber ( timeBan )*60 ) 
        banPlayer(thePlayer, false, false, true, adminBanner, "Razon: "..editText.." [ "..timeBan.." Min ] ", theTimeBan) 
        outputChatBox(text.." ha sido baneado por "..adminBanner..". Razon: "..editText.." ( "..timeBan.." Min )", getRootElement(), 255, 0, 0, false) 
    end 
    else 
    outputChatBox("No tienes los permisos suficientes para banearlo", adminPermisos, 255, 0, 0, false) 
    end 
end 
addEvent("banHim", true) 
addEventHandler("banHim", getRootElement(), banear) 

Link to comment

Try this, it should work. Tested.

--client

  
function banearButton (text, adminBanner, timeBan, editText) 
    if source == banButton then 
        local timeBan = guiGetText( timeEdit ) 
        local text = guiGridListGetItemText ( listaPlayers, guiGridListGetSelectedItem ( listaPlayers ), 1 ) 
        local editText = guiGetText( reasonEdit ) 
        local adminBanner = getPlayerName( localPlayer ) 
        if string.len ( editText ) > 0 then 
            if string.len ( timeBan ) > 0 then 
                triggerServerEvent("banHim", root, text, adminBanner, timeBan, editText) 
            else 
                outputChatBox("Escribe el tiempo de duracion",255,0,0,false) 
            end 
        else 
            outputChatBox("Escribe la razon para banearlo.",255,0,0,false) 
        end 
    end 
end 
addEventHandler("onClientGUIClick", root, banearButton) 
  
  

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...