Jump to content

onplayerban


Chaos

Recommended Posts

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
Link to comment
  
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) 
  

Link to comment

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.

Link to comment
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
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...