Ebben a fórumban bármit kérdezhetsz, itt nem fognak kinevetni.
Dupla üzenet összevonva ekkor: 2014. október 03. - 07:25:21
local localPlayer = getLocalPlayer()
local timer = false
local kills = 0
function checkDM(killer)
if (killer==localPlayer) then
kills = kills + 1
if (kills>=3) then
triggerServerEvent(\"alertAdminsOfDM\", localPlayer, kills)
end
if not (timer) then
timer = true
setTimer(resetDMCD, 120000, 1)
end
end
end
addEventHandler(\"onClientPlayerWasted\", getRootElement(), checkDM)
function resetDMCD()
kills = 0
timer = false
end
Ezután zárjuk és indítunk egy újat.
function showSpeedToAdmins(velocity)
kph = math.ceil(velocity * 1.609344)
exports.global:sendMessageToAdmins(\"[Possible Speedhack/HandlingHack] \" .. getPlayerName(client) .. \": \" .. velocity .. \"Mph/\".. kph ..\" Kph\")
end
addEvent(\"alertAdminsOfSpeedHacks\", true)
addEventHandler(\"alertAdminsOfSpeedHacks\", getRootElement(), showSpeedToAdmins)
function showDMToAdmins(kills)
exports.global:sendMessageToAdmins(\"[Possible DeathMatching] \" .. getPlayerName(client) .. \": \" .. kills .. \" kills in <=2 Minutes.\")
end
addEvent(\"alertAdminsOfDM\", true)
addEventHandler(\"alertAdminsOfDM\", getRootElement(), showDMToAdmins)
-- [MONEY HACKS]
function scanMoneyHacks()
local tick = getTickCount()
local hackers = { }
local hackersMoney = { }
local counter = 0
local players = exports.pool:getPoolElementsByType(\"player\")
for key, value in ipairs(players) do
local logged = getElementData(value, \"loggedin\")
if (logged==1) then
if not (exports.global:isPlayerAdmin(value)) then -- Only check if its not an admin...
local money = getPlayerMoney(value)
local truemoney = exports.global:getMoney(value)
if (money) then
if (money > truemoney) then
counter = counter + 1
hackers[counter] = value
hackersMoney[counter] = (money-truemoney)
end
end
end
end
end
local tickend = getTickCount()
local theConsole = getRootElement()
for key, value in ipairs(hackers) do
local money = hackersMoney[key]
local accountID = getElementData(value, \"account:id\")
local adminTitle = exports.global:getPlayerAdminTitle(thePlayer)
outputChatBox(\"AntiCheat: \" .. targetPlayerName .. \" was auto-banned for Money Hacks. (\" .. tostring(money) .. \"$)\", getRootElement(), 255, 0, 51)
end
end
setTimer(scanMoneyHacks, 3600000, 0) -- Every 60 minutes
Ugyan úgy mint az előbb.
local secretHandle = \'\'
addEventHandler(\"onElementDataChange\", getRootElement(),
function (index, oldValue)
if not client then
return
end
local theElement = source
if (index ~= \"interiormarker\") and (index ~= \"i:left\") and (index ~= \"i:right\") then
local isProtected = getElementData(theElement, secretHandle..\"p:\"..index)
if (isProtected) then
-- get real source here
-- it aint source!
local sourceClient = client
if (sourceClient) then
if (getElementType(sourceClient) == \"player\") then
local newData = getElementData(source, index)
local playername = getPlayerName(source) or \"Somethings\"
-- Get rid of the player
local msg = \"[AdmWarn] \" .. getPlayerName(sourceClient) .. \" sent illegal data. Player has been banned.\"
local msg2 = \" (victim: \"..playername..\" index: \"..index ..\" newvalue:\".. tostring(newData) .. \" oldvalue:\".. tostring(oldValue) ..\")\"
--outputConsole(msg)
--outputConsole(msg2)
--exports.global:sendMessageToAdmins(msg)
exports.global:sendMessageToAdmins(msg)
exports.global:sendMessageToAdmins(msg2)
--exports.logs:logMessage(msg..msg2, 29)
--exports.logs:dbLog(sourceClient, 5, sourceClient, msg..msg2 )
-- uncomment this when it works
--local ban = banPlayer(sourceClient, false, false, true, getRootElement(), \"Hacked Client.\", 0)
-- revert data
changeProtectedElementDataEx(source, index, oldValue, true)
end
end
end
end
end
);
addEventHandler ( \"onPlayerJoin\", getRootElement(),
function ()
protectElementData(source, \"adminlevel\")
protectElementData(source, \"account:id\")
protectElementData(source, \"account:username\")
protectElementData(source, \"legitnamechange\")
protectElementData(source, \"dbid\")
end
);
function allowElementData(thePlayer, index)
setElementData(thePlayer, secretHandle..\"p:\"..index, false, false)
end
function protectElementData(thePlayer, index)
setElementData(thePlayer, secretHandle..\"p:\"..index, true, false)
end
function changeProtectedElementData(thePlayer, index, newvalue)
allowElementData(thePlayer, index)
setElementData(thePlayer, index, newvalue)
protectElementData(thePlayer, index)
end
function changeProtectedElementDataEx(thePlayer, index, newvalue, sync, nosyncatall)
if (thePlayer) and (index) then
if not newvalue then
newvalue = nil
end
if not nosyncatall then
nosyncatall = false
end
allowElementData(thePlayer, index)
if not setElementData(thePlayer, index, newvalue, sync) then
-- if not thePlayer or not isElement(thePlayer) then
-- outputDebugString(\"changeProtectedElementDataEx\")
-- -- outputDebugString(tostring(thePlayer))
-- outputDebugString(\"index: \"..index)
-- outputDebugString(\"newvalue: \"..tostring(newvalue))
-- outputDebugString(\"sync: \"..tostring(sync))
-- end
end
if not sync then
if not nosyncatall then
if getElementType ( thePlayer ) == \"player\" then
triggerClientEvent(thePlayer, \"edu\", getRootElement(), thePlayer, index, newvalue)
end
end
end
protectElementData(thePlayer, index)
return true
end
return false
end
function genHandle()
local hash = \'\'
for Loop = 1, math.random(5,16) do
hash = hash .. string.char(math.random(65, 122))
end
return hash
end
function fetchH()
return secretHandle
end
secretHandle = genHandle()
Ezután a meta fájlt egy jegyzettömbe beillesztjük és kész is, a csalás elleni rendszerünk.
<meta>
<info author=\"vG MTA Scripting Team\" type=\"script\" description=\"Anticheat System\"/>
<script src=\"c_anticheat.lua\" type=\"client\"/>
<script src=\"s_anticheat.lua\" type=\"server\"/>
<script src=\"s_element.lua\" type=\"server\"/>
<export function=\"changeProtectedElementDataEx\" type=\"server\"/>
<export function=\"changeProtectedElementData\" type=\"server\"/>
<export function=\"protectElementData\" type=\"server\"/>
<export function=\"allowElementData\" type=\"server\"/>
<export function=\"fetchH\" type=\"server\"/>
</meta>
Remélem tudtam segíteni