Jump to content

Help - Ban System


xXMADEXx

Recommended Posts

Posted

I have made this script, but when the player joins it will not check his serial to see if he is in bans.xml! I'm not sure how to fix this.

(Server)

addEventHandler('onPlayerJoin',root, 
    function () 
        local file = xmlLoadFile("bans.xml", "bans") 
        for k,v in ipairs(xmlNodeGetChildren(file)) do 
            local hisSerial = xmlNodeGetAttribute(v,"serial") 
            local hisIp = xmlNodeGetAttribute(v,"IP") 
            local banner = xmlNodeGetAttribute(v,"banner") 
            if (getPlayerSerial(v)==hisSerial) then 
                triggerClientEvent(v,'bans:heJoinedAndIsBanned',v,banner,hisIp,hisSerial) 
            end 
        end 
    end 
) 

(Client)

local url = "http://www.rog-mta.tk" 
  
function dx() 
    dxDrawRectangle(0, 0, 1800, 1000, tocolor(0, 0, 0, 255), false) 
    dxDrawText("Your Serial Is Banned!", 0, 0, 1279, 51, tocolor(255, 0, 0, 255), 4, "default-bold", "center", "center", false, false, false, false, false) 
    dxDrawText("( "..getPlayerSerial(localPlayer).." )", 0, 51, 1279, 102, tocolor(255, 25, 0, 255), 3, "default", "center", "center", false, false, false, false, false) 
    --dxDrawText("IP: "..getPlayerIp(localPlayer), 0, 847, 1279, 950, tocolor(0, 255, 0, 255), 3, "default-bold", "center", "center", false, false, false, false, false) 
    dxDrawImage(250, 102, 800, 800, "image.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end 
  
addEvent("bans:heJoinedAndIsBanned",true) 
addEventHandler("bans:heJoinedAndIsBanned",root, 
    function (banner,hisIp,hisSerial) 
        addEventHandler('onClientRender',root,dx) 
        showChat(false) 
        showCursor(true) 
    end 
) 
  

Posted

If the player is banned, it won't trigger onPlayerJoin, he will be disconnected automatically.

Btw. you're using your own ban system? Because you can't open bans.xml. use getBans.

Posted

It dosnt ban him. Its making XML of players, and if the player who joins Serial is in bans.xml, it should show the screen. So really the player never gets banned, he just cannot play.

Posted
addEventHandler('onPlayerJoin',root, 
function () 
local banList = getBans() 
    for banID, ban in ipairs ( banList ) do  
        local hisSerial = getBanSerial ( ban ) 
        local hisIP = getBanIP ( ban ) 
        local banner = getBanAdmin(ban) 
        if (getPlayerSerial(ban)==hisSerial) then 
            triggerClientEvent(ban,'bans:heJoinedAndIsBanned',ban,banner,hisIp,hisSerial) 
        end 
    end 
end 
) 

not tested. it can be wrong, im not sure.

Guest Guest4401
Posted

Server

addEvent('downloadOver',true) 
addEventHandler('downloadOver',root, 
    function() 
        local f = xmlLoadFile('bans.xml') 
        local s = getPlayerSerial(source) 
        if f then 
            for i,v in ipairs(xmlNodeGetChildren(f)) do 
                if xmlNodeGetAttribute(v,'serial') == s then 
                    triggerClientEvent(source,'bans:heJoinedAndIsBanned',source) 
                    break 
                end 
            end 
            xmlUnloadFile(f) 
        end 
    end 
) 

Client

addEventHandler('onClientResourceStart',resourceRoot, 
    function() 
        triggerServerEvent('downloadOver',localPlayer) 
    end 
) 
  
function dx() 
    dxDrawRectangle(0, 0, 1800, 1000, tocolor(0, 0, 0, 255), false) 
    dxDrawText("Your Serial Is Banned!", 0, 0, 1279, 51, tocolor(255, 0, 0, 255), 4, "default-bold", "center", "center", false, false, false, false, false) 
    dxDrawText("( "..getPlayerSerial(localPlayer).." )", 0, 51, 1279, 102, tocolor(255, 25, 0, 255), 3, "default", "center", "center", false, false, false, false, false) 
    --dxDrawText("IP: "..getPlayerIp(localPlayer), 0, 847, 1279, 950, tocolor(0, 255, 0, 255), 3, "default-bold", "center", "center", false, false, false, false, false) 
    dxDrawImage(250, 102, 800, 800, "image.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end 
  
addEvent("bans:heJoinedAndIsBanned",true) 
addEventHandler("bans:heJoinedAndIsBanned",root, 
    function() 
        addEventHandler('onClientRender',root,dx) 
        showChat(false) 
        showCursor(true) 
    end 
) 

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