Hey,
ich habe ein bereits vorhandes script versucht umzuschreiben, das halt nur Admin,Owners, und Superadmin das log window öffnen können.
Nur leider kriege ich den fehler der oben als überschrift genannt ist.
Script (client):
Lua
--[[function out( string )
outputDebugString( string )
end]]
function centerWindow(center_window)
local screenW,screenH=guiGetScreenSize()
local windowW,windowH=guiGetSize(center_window,false)
local x,y = (screenW-windowW)/2,(screenH-windowH)/2
guiSetPosition(center_window,x,y,false)
end
addEventHandler( 'onClientResourceStart', resourceRoot,
function( )
aWindow = guiCreateWindow(0.23, 0.14, 0.56, 0.63, 'Last Login', true)
guiSetVisible( aWindow, false )
centerWindow( aWindow )
guiWindowSetSizable( aWindow, true )
aGridlist = guiCreateGridList( 12, 25, 425, 319, false, aWindow )
guiGridListSetSortingEnabled( aGridlist, false )
guiGridListAddColumn( aGridlist, 'Account name', 0.4)
guiGridListAddColumn( aGridlist, 'Data', 0.5)
guiSetAlpha( aGridlist, .8 )
aButton = guiCreateButton(10, 349, 114, 20, 'Refresh list', false, aWindow )
setElementData( aButton, 'aButton', aButton )
addEventHandler( 'onClientGUIClick', aButton, aRefreshList, false )
guiSetFont( aButton, 'default-bold-small' )
guiSetProperty( aButton, 'NormalTextColour', 'FFAAAAAA')
aLabel = guiCreateLabel(243, 349, 197, 15, 'Time now is: 0-0-0 00:00', false, aWindow)
guiSetFont( aLabel, 'default-bold-small' )
guiSetFont( aGridlist, 'default-bold-small' )
end
)
function setTimeNow( )
local time = getRealTime( )
guiSetText( aLabel,
string.format(
'%04d-%02d-%02d %02d:%02d:%02d',
time.year + 1900,
time.month + 1,
time.monthday,
time.hour,
time.minute,
time.second
)
)
end
setTimer ( setTimeNow, 1000, 0 )
--addEventHandler( 'onClientRender', getRootElement( ), setTimeNow )
function getTimeNow( )
local time = getRealTime( )
return string.format(
'%04d-%02d-%02d %02d:%02d',
time.year + 1900,
time.month + 1,
time.monthday,
time.hour,
time.minute
)
end
function aRefreshList( )
guiSetEnabled( getElementData( aButton, 'aButton' ) , false )
guiGridListClear( aGridlist )
triggerServerEvent( 'aButtonRefresh', getLocalPlayer( ) )
setTimer( guiSetEnabled, 4000, 1, getElementData( aButton, 'aButton'), true )
end
aSerials =
{
[ '3460396978F17FE72B94034FBBA02542' ] = true ;
}
function aOpenWin(player)
for _, group in ipairs ({"Admin", "Owner","Superadmin"}) do
local accountName = getAccountName(getPlayerAccount(player)) --hier ist der error
if isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( group ) ) then
guiSetVisible( aWindow, not guiGetVisible( aWindow ) )
showCursor( not isCursorShowing( ) )
aRefreshList( )
end
end
end
addCommandHandler("adminlogs", aOpenWin)
function getDataTime( aTime )
if ( aTime ~= 'online' ) then
local aYear, aMonth, aDay, _, _ = string.match( aTime, '^(.-)-(.-)-(.-) (.-):(.-)$' )
local aYear1, aMonth1, aDay1, _, _ = string.match( getTimeNow( ), '^(.-)-(.-)-(.-) (.-):(.-)$' )
if ( aYear1 == aYear ) then
if ( aMonth == aMonth1 ) and ( aDay == aDay1 ) then
return 'Today'
elseif ( aMonth == aMonth1 ) and ( aDay ~= aDay1 ) then
local fDay = string.format( '%02d', ( aDay + 1 ) )
if ( fDay == aDay1 ) then
return 'Yesterday'
elseif ( aMonth == aMonth1 ) and ( aDay ~= aDay1 ) then
local gDay = ( aDay1 - aDay )
return math.abs( gDay ).. ' Days ago'
end
elseif ( aMonth ~= aMonth1 ) then
return 'months ago'
end
end
return 'Years ago'
end
return ' '
end
function onGetAllData( gName, gData, nOnline, nOfline, iR, iG, iB )
local aRow = guiGridListAddRow( aGridlist )
guiGridListSetItemText( aGridlist, aRow, 1, gName, false, false )
guiGridListSetItemText( aGridlist, aRow, 2, gData .. ' (' .. getDataTime( gData ) .. ') ', false, false )
guiGridListSetItemColor( aGridlist, aRow, 2, iR, iG, iB )
guiSetText( aWindow, ' Online ' .. nOnline .. ' / ' .. nOfline .. ' Otherwise ' )
end
addEvent( 'onGetAllData', true )
addEventHandler( 'onGetAllData', getLocalPlayer( ), onGetAllData )
Alles anzeigen