Jump to content

onplayerban


Chaos

Recommended Posts

Posted (edited)

hey,

im trying to ban account so if player got ban then login with another pc with same account will get ban again

but i'm looking for unban event because when i want unban player then he can return to server with out ban.

function outputBan ( banPointer, responsibleElement ) 
account = getPlayerAccount(source) 
if account then 
setAccountData(account,"AccountBanned",true) 
outputChatBox("The account has been banned",root,255,0,0) 
end 
  
end 
addEventHandler ( "onPlayerBan", getRootElement(), outputBan )  
  
addEventHandler("onPlayerLogin", root, 
  function() 
   
  account = getPlayerAccount(source) 
if account then 
if getAccountData(account,"AccountBanned") == true then 
banPlayer ( source, false, false, true, getRootElement ( ), 'You have been banned',0 ) 
end 
end 
end) 

Edited by Guest
Posted
  
function outputBan () 
    account = getPlayerAccount(source) 
    if account and not isGuestAccount(account) then 
        setAccountData(account,"AccountBanned",true) 
        outputChatBox("The account has been banned",root,255,0,0) 
    end 
end 
  
addEventHandler ( "onPlayerBan", getRootElement(), outputBan )  
  
addEventHandler("onPlayerLogin", root, 
    function(_,account) 
        if getAccountData(account,"AccountBanned") == true then 
            banPlayer ( source, false, false, true, getRootElement ( ), 'You have been banned',0 ) 
        end 
    end) 
  

Posted

it's worked but i'm looking for unban event because when i want unban player then he can return to server with out ban.

Posted (edited)

You edited the post 1 minute after i posted my code, first you said that it didn't work.

Edited by Guest
Posted

Well, i won't make this one for you (I don't have time atm, sorry), but if you are using 1.4, you can use

setBanReason 

to set the ban reason to the account name of the banned player, and use the

onUnban 

event, get the reason with

getBanReason 

and set the accountdata to false.

There might be a much easier solution, but i can't think about it atm.

Posted (edited)
function announceUnban( theBan, responsibleElement ) 
    account = getPlayerAccount(theBan) 
    if account then 
    if getAccountData(account,"AccountBanned") == true then 
    setAccountData(account,"AccountBanned",false) 
    end 
    end 
    end 
  
  
addEventHandler( "onUnban", root, announceUnban ) --Adds the event handler for 'onUnban' 

thanks a lot but anything wrong here ?

Edited by Guest
Posted

You can't get the account of a ban element, only of a player element.

To do it, you have to find a way. (Like i said, set the reason to the account name.)

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