Jump to content

Player kick


Guest Mulder

Recommended Posts

This script is based on AlienX anti cheat, i changed it to kicks players who have name "Player". Point is that everythin show is ok, but when player should be kicked, hes not kicked.

function checkNickname(thePlayer) 
    if ( getClientName(thePlayer) == "Player" ) then 
        outputChatBox ( "Player is being kicked for: Not changing nickname", getRootElement(), 255 ) 
        setTimer ( kickPlayer, 1500, 1, thePlayer )   
    end 
end 
  
function onPlayerJoin() 
    if ( getClientName(source) == "Player" ) then 
        outputChatBox ( "Player - you have 30 seconds to change your nickname before you are kicked /nick <newnick>" ) 
        setTimer ( checkNickname, 30000, 1, source ) 
        playerTable[source] = true 
    end 
end 
addEventHandler ( "onPlayerJoin", getRootElement(), onPlayerJoin ) 
  
function onResourceStart(thisResource) 
    outputChatBox ( getRootElement(), 255 ) 
    setTimer ( scanPlayers, 1000, 0 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), onResourceStart ) 

and the ACL

<group name="Playerkick"> 
      <acl name="Playerkick"/> 
      <object name="resource.playerkick"/> 
   </group> 
  
  
  
  <acl name="Playerkick"> 
      <right name="function.kickPlayer" access="true"/> 
      <right name="function.xmlLoadFile" access="true"/> 
   </acl> 

this works in 70% need to figure why he is not kicked. Thanks for help

Link to comment

I was thinking about doing somthing like this.. and i auctually did.....

i know this works, as i have tested it.....

local playerTable = {} 
function scanPlayers() 
    local allPlayers = getElementsByType("player") 
    for k,v in ipairs(allPlayers) do 
        if (playerTable[v] ~= true) then 
            checkNickname(v) 
        end 
    end 
end 
  
function kickNickname(thePlayer) 
    playerName = getClientName(thePlayer) 
    if (string.find(playerName, "Player", 1, plain)) then 
        --outputChatBox ( playerName.." is being kicked for: Not changing nickname", getRootElement(), 255 ) 
        setTimer ( kickPlayer, 1500, 1, thePlayer, "Change your name before returning") 
    else  
    playerTable[thePlayer] = false 
    end 
end 
  
function checkNickname(thePlayer) 
    playerName = getClientName(thePlayer) 
    if (string.find(playerName, "Player", 1, plain)) then 
        outputChatBox ( playerName..", you have 30 seconds to change your nickname before you are kicked - type /nick <nick>", thePlayer) 
        outputChatBox ( "The reason you will be kicked is: Using a Forbidden Nickname (Player)", thePlayer) 
        setTimer ( kickNickname, 30000, 1, thePlayer ) 
        playerTable[thePlayer] = true 
    end 
end 
  
function onPlayerJoin() 
    checkNickname(source) 
end 
addEventHandler ( "onPlayerJoin", getRootElement(), onPlayerJoin ) 
  
function onResourceStart(thisResource) 
    setTimer ( scanPlayers, 5000, 0 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), onResourceStart ) 
  
  

these are in the ACL

      <group name="ackick"> 
            <acl name="playerkick"/> 
            <object name="resource.playernamekick"/> 
      </group> 

   <acl name="playerkick"> 
      <right name="function.kickPlayer" access="true"/> 
   </acl> 

and this is in the mtaserver.conf

   <resource src="playernamekick" startup="1" protected="0"/> 

i think i got those ACL codes copied out correctly, as i have 3 different copys of this script, all modified to do different things running in there.

Link to comment

Step 1:

copy all of this following code, and put it into a New notepad file.....

MAKE SURE YOU TURN LINE NUMBERS OFF IN THIS PAGE BEFORE COPYING IT.

otherwise the moronic forum software will add numbers to the code and fuck it up.

local playerTable = {} 
function scanPlayers() 
    local allPlayers = getElementsByType("player") 
    for k,v in ipairs(allPlayers) do 
        if (playerTable[v] ~= true) then 
            checkNickname(v) 
        end 
    end 
end 
  
function kickNickname(thePlayer) 
    playerName = getClientName(thePlayer) 
    if (string.find(playerName, "Player", 1, plain)) then 
        --outputChatBox ( playerName.." is being kicked for: Not changing nickname", getRootElement(), 255 ) 
        setTimer ( kickPlayer, 1500, 1, thePlayer, "Change your name before returning") 
    else 
    playerTable[thePlayer] = false 
    end 
end 
  
function checkNickname(thePlayer) 
    playerName = getClientName(thePlayer) 
    if (string.find(playerName, "Player", 1, plain)) then 
        outputChatBox ( playerName..", you have 30 seconds to change your nickname before you are kicked - type /nick <nick>", thePlayer) 
        outputChatBox ( "The reason you will be kicked is: Using a Forbidden Nickname (Player)", thePlayer) 
        setTimer ( kickNickname, 30000, 1, thePlayer ) 
        playerTable[thePlayer] = true 
    end 
end 
  
function onPlayerJoin() 
    checkNickname(source) 
end 
addEventHandler ( "onPlayerJoin", getRootElement(), onPlayerJoin ) 
  
function onResourceStart(thisResource) 
    setTimer ( scanPlayers, 5000, 0 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), onResourceStart ) 
  
  

save the text document with that in it as playernamekick.lua

Step 2:

Copy this code into a new text document:

(with the same warning as before about line numbers)

<meta> 
    <info author="Modified by DazzaJay" description="Player Name Kicker" type="script" version="1.1.7" /> 
    <script src="playernamekick.lua" type="server" /> 
</meta> 

Save that file as meta.xml

now, put both the meta.xml and the playernamekicker.lua into a .zip file "playernamekick.zip"

they should be the only 2 files in there.

Place the "playernamekick.zip" file into your \Server\mods\deathmatch\resources\ folder.

Step 3:

open the ACL.xml file (found in \Server\mods\deathmatch\ folder)

copy this code into your servers ACL.xml (code goes near the top of the file)

      <group name="ackick"> 
            <acl name="playerkick"/> 
            <object name="resource.playernamekick"/> 
      </group> 

This following code also goes into your ACL.XML

   <acl name="playerkick"> 
      <right name="function.kickPlayer" access="true"/> 
   </acl> 

save the acl.xml

Step 4:

open the mtaserver.conf (found in \Server\mods\deathmatch\ )

and this following code goes in your mtaserver.conf

  <resource src="playernamekick" startup="1" protected="0"/> 

save the mtaserver.conf

Load the server, and if all is done right, it will work.

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