local warn = { }
function command ( sourcePlayer, command, who )
if ( not who ) then
outputChatBox ( "Syntaxa Invalida:/warn NUMEJUCATOR.", sourcePlayer )
return
end
local name = getPlayerFromName ( who )
if ( name ) then
local acc = getPlayerAccount ( sourcePlayer )
local accName = getAccountName ( getPlayerAccount ( sourcePlayer ) ) -- get his account name
if isObjectInACLGroup ( "user.".. accName, aclGetGroup ( "Admin" ) ) then
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
carne = setAccountData ( acc, "warns", warn [ name ] )
outputChatBox ( "Administratorul ".. accName .." la avertizat pe : ".. who ..", si acum are ".. warn [ name ] .." avertisment(e)", getRootElement(), 255, 0, 0 )
end
if ( carne ) then
outputChatBox ( "asdadad" )
end
if ( warn [ name ] >= 3 ) then -- 3 warnings = ban
banPlayer ( name, true, who, false, sourcePlayer, "Avertismente.", 0 )
outputChatBox ( "Jucatorul ".. who .." a fost banat permanent din cauza avertisementelor.", getRootElement(), 255, 0, 0 )
end
end
end
end
addCommandHandler ( "warn", command )
addEventHandler ( "onPlayerLogin", getRootElement(),
function ( _, acc )
local warns = tonumber ( getAccountData ( acc, "warns" ) ) or 0
warn [ name ] = warns
end
)