Jump to content

Script don't working


Recommended Posts

Hello all i just looking around and learning lua and now i got problem with name check

i whant to create function if player name it's "Player5345" then kick player from the server but when player connecting to the server he only spawning in the spawn point and my "NameCheck" function doesn't working

Code :

function prisijungimas() 
     
    local x = 222.1 
    local y = 124.1 
    local z = 2.0 
     
    spawnPlayer(source, x, y, z) 
    fadeCamera(source, true) 
    setCameraTarget(source, source) 
    outputChatBox("Hello " ..getPlayerName(source).. " Welcome To test server",source) 
end 
  
function checkdefaultname() 
  
    local name = getPlayerName(source) 
     
    if (name == "Player5345") then 
        kickPlayer(source,"Bad Name") 
    end 
end 
  
  
addEventHandler("onPlayerJoin",getRootElement(), prisijungimas,checkdefaultname) 

Link to comment

This should work :

function checkname() 
  
    local x = 222.1 
    local y = 124.1 
    local z = 2.0 
    local name = getPlayerName(source) 
  
    if (name == "Player5345") then 
        kickPlayer(source,"Bad Name") 
    else 
    spawnPlayer(source, x, y, z) 
    fadeCamera(source, true) 
    setCameraTarget(source, source) 
    outputChatBox("Hello " ..getPlayerName(source).. " Welcome To test server",source) 
    end 
  
end 
  
  
addEventHandler("onPlayerJoin",getRootElement(), checkname) 
  

Link to comment

Logs:

[2011-06-04 11:01:25] JOIN: Player5345 joined the game (IP: 127.0.0.1)

[2011-06-04 11:01:25] WARNING: rpgg\rpg.lua:9: Access denied @ 'kickPlayer'

BTW i don't know what i need edit but maybe in the acl.xml \ \ and set

Or not?

Link to comment
BTW i don't know what i need edit but maybe in the acl.xml \ \ and set

that edit would give access to kickPlayer to everyone and everything.

you should add your rersource to some group (for example "Admin") that have the access to kickPlayer:

  
<group name="Admin"> 
  ... 
  <object name="resource.yourResourceName" /> 
</group> 
  

Link to comment

its just an example, you can add to any group that have access to kickPlayer.

just see which group has and add your resource to that group.

its just people tend to add resources in Admin group so they wont have any access restrictions. :S

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