OnPlayerACInfo: Difference between revisions
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
		
	
 (Created page with "__NOTOC__  {{Server event}} This event is triggered when a player trips anti-cheat detections. {{Note|Any resource using this event should call resendPlayerACInfo for each...")  | 
				Dutchman101 (talk | contribs)  mNo edit summary  | 
				||
| (7 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
__NOTOC__    | __NOTOC__    | ||
{{Server event}}  | {{Server event}}  | ||
This event is triggered when a player trips anti-cheat detections.  | {{New items|3.0152|1.5.1-7633|  | ||
This event is triggered when a player trips anti-cheat detections. It can be used to script a white/blacklist of custom d3d9.dll files, or a white/blacklist of players with certain anti-cheat codes. The relevant anti-cheat code has to be disabled (or not enabled) in the server [[Mtaserver.conf#disableac|mtaserver.conf]] to be of use here.  | |||
}}  | |||
{{Note|Any resource using this event should call [[resendPlayerACInfo]] for each player in [[onResourceStart]]}}  | {{Note|Any resource using this event should call [[resendPlayerACInfo]] for each player in [[onResourceStart]]}}  | ||
==Parameters==  | ==Parameters==  | ||
<syntaxhighlight lang="lua">  | <syntaxhighlight lang="lua">  | ||
table   | table detectedACList, int d3d9Size, string d3d9MD5, string d3d9SHA256  | ||
</syntaxhighlight>    | </syntaxhighlight>    | ||
*'''  | *'''detectedACList''': A table of [[Anti-cheat_guide|anti-cheat]] codes the player has triggered.  | ||
*'''  | *'''d3d9Size''': A number representing the file size of any custom d3d9.dll the player may have installed.   | ||
*'''  | *'''d3d9MD5''': A string containing the MD5 of any custom d3d9.dll the player may have installed.  | ||
*'''  | *'''d3d9SHA256''': A string containing the SHA256 of any custom d3d9.dll the player may have installed.  | ||
==Source==  | ==Source==  | ||
| Line 20: | Line 22: | ||
<syntaxhighlight lang="lua">  | <syntaxhighlight lang="lua">  | ||
function handleOnPlayerACInfo(   | function handleOnPlayerACInfo( detectedACList, d3d9Size, d3d9MD5, d3d9SHA256 )  | ||
     outputChatBox( "ACInfo for " .. getPlayerName(source)  |      outputChatBox( "ACInfo for " .. getPlayerName(source)  | ||
                 .. "   |                  .. " detectedACList:" .. table.concat(detectedACList,",")  | ||
                 .. "   |                  .. " d3d9Size:" .. d3d9Size  | ||
                 .. "   |                  .. " d3d9SHA256:" .. d3d9SHA256  | ||
                 )  |                  )  | ||
end  | end  | ||
addEventHandler( "onPlayerACInfo", root, handleOnPlayerACInfo )  | |||
-- Ensure no one gets missed when the resource is (re)started  | |||
addEventHandler( "onResourceStart", resourceRoot,  | |||
    function()  | |||
        for _,plr in ipairs( getElementsByType("player") ) do  | |||
            resendPlayerACInfo( plr )  | |||
        end  | |||
    end  | |||
)  | |||
</syntaxhighlight>  | |||
This example will notify all online admins when someone triggers a (suspicious) detection  | |||
<syntaxhighlight lang="lua">  | |||
function handleAC(detectedACList)  | |||
	for _, acCode in ipairs(detectedACList) do  | |||
		if acCode == 33 then -- SD #33 in this code example = NetLimiter software (possible lagswitch)  | |||
			local playerName = getPlayerName(source)  | |||
			warnAdmins(playerName, acCode)  | |||
		end  | |||
	end  | |||
end  | |||
addEventHandler("onPlayerACInfo", root, handleAC)  | |||
local staffACL = {  | |||
	[aclGetGroup("Admin")] = true,  | |||
	[aclGetGroup("Moderator")] = true  | |||
}  | |||
function warnAdmins(playerName, acCode)  | |||
	for _, p in ipairs(getElementsByType("player")) do  | |||
		local account = getPlayerAccount(p)  | |||
		if p and account then  | |||
			for group, _ in pairs(staffACL) do  | |||
				local name = getAccountName(account)  | |||
				if isObjectInACLGroup("user." .. name, group) then  | |||
					outputChatBox("The player " .. playerName .. " has triggered SD/AC #" .. acCode .. "! Keep an eye out!", p)  | |||
				end  | |||
			end  | |||
		end  | |||
	end  | |||
end  | |||
-- Ensure no one gets missed when the resource is (re)started  | |||
function onRestart()  | |||
	for _,p in ipairs (getElementsByType("player")) do  | |||
		resendPlayerACInfo(p)  | |||
	end  | |||
end  | |||
addEventHandler("onResourceStart", resourceRoot, onRestart)  | |||
</syntaxhighlight>  | |||
This example allows player serial exceptions for SD #14 (virtual machines). In order for this to work, it's important that you '''don't''' add SD #14 detection into mtaserver.conf, as this is a custom re-implementation.  | |||
<syntaxhighlight lang="lua">  | |||
-- List of serials which are allowed to use virtual machines  | |||
allowVM = { ["0123456789012345601234567890123456"] = true,  | |||
            ["A123637892167367281632896790123456"] = true,  | |||
            ["E123456789012347839207878392123456"] = true }  | |||
function handleOnPlayerACInfo( detectedACList, d3d9Size, d3d9MD5, d3d9SHA256 )  | |||
    for _,acCode in ipairs( detectedACList ) do  | |||
        if acCode == 14 then  | |||
            local serial = getPlayerSerial(source)  | |||
            if not allowVM[serial] then  | |||
                kickPlayer( source, "This server does not allow virtual machines." )  | |||
            end  | |||
        end  | |||
    end  | |||
end  | |||
addEventHandler( "onPlayerACInfo", root, handleOnPlayerACInfo )  | addEventHandler( "onPlayerACInfo", root, handleOnPlayerACInfo )  | ||
Latest revision as of 23:43, 10 May 2019
This event is triggered when a player trips anti-cheat detections. It can be used to script a white/blacklist of custom d3d9.dll files, or a white/blacklist of players with certain anti-cheat codes. The relevant anti-cheat code has to be disabled (or not enabled) in the server mtaserver.conf to be of use here.
Parameters
table detectedACList, int d3d9Size, string d3d9MD5, string d3d9SHA256
- detectedACList: A table of anti-cheat codes the player has triggered.
 - d3d9Size: A number representing the file size of any custom d3d9.dll the player may have installed.
 - d3d9MD5: A string containing the MD5 of any custom d3d9.dll the player may have installed.
 - d3d9SHA256: A string containing the SHA256 of any custom d3d9.dll the player may have installed.
 
Source
The source of this event is the player
Example
This example prints all information into the chatbox
function handleOnPlayerACInfo( detectedACList, d3d9Size, d3d9MD5, d3d9SHA256 )
    outputChatBox( "ACInfo for " .. getPlayerName(source)
                .. " detectedACList:" .. table.concat(detectedACList,",")
                .. " d3d9Size:" .. d3d9Size
                .. " d3d9SHA256:" .. d3d9SHA256
                )
end
	
addEventHandler( "onPlayerACInfo", root, handleOnPlayerACInfo )
-- Ensure no one gets missed when the resource is (re)started
addEventHandler( "onResourceStart", resourceRoot,
    function()
        for _,plr in ipairs( getElementsByType("player") ) do
            resendPlayerACInfo( plr )
        end
    end
)
This example will notify all online admins when someone triggers a (suspicious) detection
function handleAC(detectedACList)
	for _, acCode in ipairs(detectedACList) do
		if acCode == 33 then -- SD #33 in this code example = NetLimiter software (possible lagswitch)
			local playerName = getPlayerName(source)
			warnAdmins(playerName, acCode)
		end
	end
end
addEventHandler("onPlayerACInfo", root, handleAC)
local staffACL = {
	[aclGetGroup("Admin")] = true,
	[aclGetGroup("Moderator")] = true
}
function warnAdmins(playerName, acCode)
	for _, p in ipairs(getElementsByType("player")) do
		local account = getPlayerAccount(p)
		if p and account then
			for group, _ in pairs(staffACL) do
				local name = getAccountName(account)
				if isObjectInACLGroup("user." .. name, group) then
					outputChatBox("The player " .. playerName .. " has triggered SD/AC #" .. acCode .. "! Keep an eye out!", p)
				end
			end
		end
	end
end
-- Ensure no one gets missed when the resource is (re)started
function onRestart()
	for _,p in ipairs (getElementsByType("player")) do
		resendPlayerACInfo(p)
	end
end
addEventHandler("onResourceStart", resourceRoot, onRestart)
This example allows player serial exceptions for SD #14 (virtual machines). In order for this to work, it's important that you don't add SD #14 detection into mtaserver.conf, as this is a custom re-implementation.
-- List of serials which are allowed to use virtual machines
allowVM = { ["0123456789012345601234567890123456"] = true,
            ["A123637892167367281632896790123456"] = true,
            ["E123456789012347839207878392123456"] = true }
function handleOnPlayerACInfo( detectedACList, d3d9Size, d3d9MD5, d3d9SHA256 )
    for _,acCode in ipairs( detectedACList ) do
        if acCode == 14 then
            local serial = getPlayerSerial(source)
            if not allowVM[serial] then
                kickPlayer( source, "This server does not allow virtual machines." )
            end
        end
    end
end
addEventHandler( "onPlayerACInfo", root, handleOnPlayerACInfo )
-- Ensure no one gets missed when the resource is (re)started
addEventHandler( "onResourceStart", resourceRoot,
    function()
        for _,plr in ipairs( getElementsByType("player") ) do
            resendPlayerACInfo( plr )
        end
    end
)
See Also
Player events
- onPlayerACInfo
 - onPlayerBan
 - onPlayerChangeNick
 - onPlayerChat
 - onPlayerClick
 - onPlayerCommand
 - onPlayerConnect
 - onPlayerContact
 - onPlayerDamage
 - onPlayerJoin
 - onPlayerLogin
 - onPlayerLogout
 - onPlayerMarkerHit
 - onPlayerMarkerLeave
 - onPlayerModInfo
 - onPlayerMute
 - onPlayerNetworkStatus
 - onPlayerPickupHit
 - onPlayerPickupLeave
 - onPlayerPickupUse
 - onPlayerPrivateMessage
 - onPlayerQuit
 - onPlayerScreenShot
 - onPlayerSpawn
 - onPlayerStealthKill
 - onPlayerTarget
 - onPlayerUnmute
 - onPlayerVehicleEnter
 - onPlayerVehicleExit
 - onPlayerVoiceStart
 - onPlayerVoiceStop
 - onPlayerWasted
 - onPlayerWeaponFire
 - onPlayerWeaponSwitch
 
Event functions
- addEvent
 - addEventHandler
 - cancelEvent
 - cancelLatentEvent
 - getEventHandlers
 - getLatentEventHandles
 - getLatentEventStatus
 - removeEventHandler
 - triggerEvent
 - wasEventCancelled