Jump to content

warn system


golanu21

Recommended Posts

Posted
warns = 0 
function command (sourcePlayer, command, who) 
name = getPlayerFromName(who) 
    if name then 
        local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) -- get his account name 
        if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then  
        for index, name in ipairs(name) do  
            if warns == 0 then 
                warns = 1 
                outputChatBox("Jucatorul"..name.."a primit warn din partea administratorilor 1/3") 
            elseif warns == 1 then 
                warns = 2 
                outputChatBox("Jucatorul"..name.."a primit warn din partea administratorilor 2/3") 
            elseif warns == 2 then 
                warns = 3  
                outputChatBox("Jucatorul"..name.."a primit warn din partea administratorilor 3/3") 
                banPlayer(name) 
                end 
            end 
        end 
     else  
     outputChatBox("Invalid Syntax:/warn Player", source, 255, 0, 0 ) 
    end 
end 
addCommandHandler("warn", command) 

WARNING: gymScript\server.lua:3: Bad argument @ 'getPlayerFromName' 
[2013-08-22 12:31:25] WARNING: gymScript\server.lua:5: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] 
[2013-08-22 12:31:25] WARNING: gymScript\server.lua:5: Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean] 
[2013-08-22 12:31:25] ERROR: gymScript\server.lua:6: attempt to concatenate local 'accName' (a boolean value) 

XajVsWV.png

168_zps269f1907.gif[Dev]BloWnRPG - We BloW the World [1%]168_zps269f1907.gif

Posted (edited)
warns = 0 
function command (sourcePlayer, command, who) 
    if not who then 
        outputChatBox ( "No name was given." ) 
        return 
    end 
    name = getPlayerFromName(who) 
    if name then 
        local accName = getAccountName ( getPlayerAccount ( sourcePlayer ) ) -- get his account name 
        if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
            for index, name in ipairs(name) do  -- that makes no sense 
                if warns == 0 then 
                    warns = 1 
                    outputChatBox("Jucatorul"..name.."a primit warn din partea administratorilor 1/3") 
                elseif warns == 1 then 
                    warns = 2 
                    outputChatBox("Jucatorul"..name.."a primit warn din partea administratorilor 2/3") 
                elseif warns == 2 then 
                    warns = 3 
                    outputChatBox("Jucatorul"..name.."a primit warn din partea administratorilor 3/3") 
                    banPlayer(name) 
                end 
            end 
        end 
    else 
        outputChatBox("Invalid Syntax:/warn Player", source, 255, 0, 0 ) 
    end 
end 
addCommandHandler("warn", command) 

Edited by Guest

Owner of [HUN]Magyar Play Szerver 1.4, IP: 31.220.43.153:22003

Posted
& in line 7 ,you've tried to loop a variable not a table

Yes, Sora is right, I haven't noticed this. But it's now line 11 in my version.

Owner of [HUN]Magyar Play Szerver 1.4, IP: 31.220.43.153:22003

Posted (edited)

Then use a table, eg.:

local warn = {} 

And store there the warns of individual players:

  
if not warn[ name ] then  -- hasn't got a warning yet 
    warn[ name ] = 1 
else 
    warn[ name ] = warn[ name ] + 1 --alredy has waring(s), so give one more 
end 
  
if warn[ name ] >= 3 then -- 3 warnings = ban 
    banPlayer(...) 
end 
  

Edited by Guest

Owner of [HUN]Magyar Play Szerver 1.4, IP: 31.220.43.153:22003

Posted

SCRIPT ERROR: gymScript\server.lua:8: 'then' expected near '='

[2013-08-22 13:08:50] WARNING: Loading script failed: gymScript\server.lua:8: 'then' expected near '='

XajVsWV.png

168_zps269f1907.gif[Dev]BloWnRPG - We BloW the World [1%]168_zps269f1907.gif

Posted

Eh, I'm a bit silly today... Error fixed. I wrote => instead of >= ](*,).

But don't just copy-paste it into your script. It's an example of how you could do it, but you have to implement it to your needs.

Owner of [HUN]Magyar Play Szerver 1.4, IP: 31.220.43.153:22003

Posted

Then your script doesn't have the right to ban. Put resource.resourcename in an ACL group wich can ban.

Owner of [HUN]Magyar Play Szerver 1.4, IP: 31.220.43.153:22003

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