Jump to content

ban player


Sasu

Recommended Posts

Posted

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.

Posted

What do you mean? In admin panel you just select the player and hit Ban. What has this line to do with the admin panel?

Posted
Its says N/A instead name of the player who was banned.

Because you banned them using their serial/ip ?

Yes. Why...?

Posted

In admin panel, you can't ban someone from serial/ip and expect their name will be shown .. , you should do what 50p told you to show their name.

Posted

But I created an admin panel and Its ban from serial. And also I created a gridlist to make list ban. But I cant get the name.

Posted

Are you doing something like so .. ?

  
  
playerToBan = guiGridListGetItemText ( playerlist, guiGridListGetSelectedItem ( playerlist ), 1 ) 
  
triggerServerEvent ( "yourEventHere", root, playerToBan ) 
  
  

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

Yes. And In server I convert with getPlayerFromName.

Posted

There is probably an issue when you send it to the server since it returns false, try posting your code here at least the significant ones.

Posted

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) 

Posted

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) 
  
  

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...