Anti crackloot system

ice cold

Active Member
Trusted Member
Member
Oct 24, 2016
606
876
43
Canada
as you know there is a bug foating around since rust came out called cracklooting AKA walloot
fougerite is the only mod framework without having something against it i found a lua code antiwalloot

as fougerite also supports lua plugins but only the hooks are a a little diffrent

here is the anti wallooting system for oxide 1.1.8 becaus its lua
Java:
PLUGIN.Title = "Anti WallLoot"
PLUGIN.Description = "Anti WallLoot hacks"
PLUGIN.Version = "1.3"
PLUGIN.Author = "Reneb"

function util.FindOverloadedMethodByRef( typ, method, bindingFlags, typeList )
typ = typesystem.TypeFromMetatype( typ )
    local methods = typ:GetMethods( bindingFlags )
    if (methods.Length == 0) then
        error( "Tried to find overloaded method '" .. name .. "' on type '" .. typ.Name .. "', no candidates found!" )
        return
    end
    for i=1, methods.Length do
        local methodinfo = methods[i - 1]
        if (method and methodinfo.Name == method) then
            local plist = methodinfo:GetParameters()
            if (plist.Length == #typeList) then
                local found = true
                for j=1, plist.Length do
                    local paraminfo = plist[j - 1]
                    local othertype = typesystem.TypeFromMetatype( typeList[j] )
                    if (paraminfo.ParameterType ~= othertype) then
                        if (paraminfo.Name ~= "hit" and paraminfo.Name ~= "hitMergedMeshBatchInstance" and paraminfo.Name ~= "hitInstance" ) then
                            found = false
                            break
                        end
                    end
                end
                if (found) then return methodinfo end
            end
        end
    end
end

function PLUGIN:Init()
    self.Inv = {}
    local b, res = config.Read( "r-AntiWallLoot" )
    self.Config = res or {}
    if (not b or (not self.Config.Version or (self.Config.Version and self.Config.Version ~= "1.3"))) then
        self:LoadDefaultCFG()
        if (res) then config.Save( "r-AntiWallLoot" ) end
    end
    self:AddChatCommand("wl",self.cmdWallloot)
    self:AddChatCommand("wallloot",self.cmdWallloot)
    self:AddChatCommand("wltp",self.cmdWallloottp)
    self:AddChatCommand("wlreset",self.cmdWalllootreset)
    self:AddChatCommand("walllootreset",self.cmdWalllootreset)
    self:AddChatCommand("wallloottp",self.cmdWallloottp)
    self.DataFile = util.GetDatafile( "WallLoots" )
    local txt = self.DataFile:GetText()
    if (txt ~= "") then
        self.WallLoots = json.decode( txt )
    else
        print("Anti Wallloot: Couldnt load Wall Loots database, creating a new one.")
        self.WallLoots = {}
    end
    self.WallLoot = {}
    self.WallLooters = {}
end
function PLUGIN:LoadDefaultCFG()
    self.Config.BroadCastKick = true
    self.Config.BroadCastBan = true
    self.Config.IgnoreAdmins = false
    self.Config.chatName = "Anti Wall-Loot"
    self.Config.Version = "1.3"
    self.Config.Kick = true
    self.Config.Ban = true
    self.Config.DetectionsNeededForBan = 3
end
function PLUGIN:cmdWalllootreset(netuser,cmd,args)
    if(not netuser:CanAdmin()) then return end
    self.WallLoots = {}
    self:Save()
    rust.SendChatToUser(netuser, "Anti Wall Loot", "Anti WallLoot database has been resetted")
end
function PLUGIN:cmdWallloottp(netuser,cmd,args)
    if(not netuser:CanAdmin()) then return end
    if(not args[1]) then return end
  
    local start = tonumber(args[1])
    if(self.WallLoots[start]) then
        local data = self.WallLoots[start]
        local coords = netuser.playerClient.lastKnownPosition
        coords.x = data.x
        coords.y = data.y
        coords.z = data.z
        rust.ServerManagement():TeleportPlayer( netuser.playerClient.netPlayer, coords )
        rust.SendChatToUser(netuser, "Anti Wall Loot", start .. " - " .. data.name .. " - " .. data.steamid)
    end
end
function PLUGIN:cmdWallloot(netuser,cmd,args)
    if(not netuser:CanAdmin()) then return end
    if(not args[1]) then
        local count = self:CountWL()
        for o=0, 19 do
            local data = self.WallLoots[count-o]
            if(not data) then break end
            rust.SendChatToUser(netuser, "Anti Wall Loot", (count-o) .. " - " .. data.name .. " - " .. data.steamid)
        end
    else
        local start = tonumber(args[1])
        for o=0, 19 do
            local data = self.WallLoots[start-o]
            if(not data) then break end
            rust.SendChatToUser(netuser, "Anti Wall Loot", (start-o) .. " - " .. data.name .. " - " .. data.steamid)
        end
    end
end
function PLUGIN:CountWL()
    local count = 0
    for i=1, #self.WallLoots do
        count = count + 1
    end
    return count
end
function PLUGIN:Save()
    self.DataFile:SetText( json.encode( self.WallLoots ) )
    self.DataFile:Save()
end
local Raycastl = util.FindOverloadedMethod( UnityEngine.Physics, "RaycastAll", bf.public_static, { UnityEngine.Vector3, UnityEngine.Vector3 } )
local GetPlayersLooting, SetPlayersLooting = typesystem.GetField( Rust.Inventory, "_netListeners", bf.private_instance )

local typ1 = cs.gettype( "Facepunch.MeshBatch.MeshBatchPhysics, Facepunch.MeshBatch" )
local RefParam2 = cs.gettype("UnityEngine.RaycastHit&, UnityEngine" )
local RefParam3 = cs.gettype("System.Boolean&, System" )
local RefParam4 = cs.gettype("Facepunch.MeshBatch.MeshBatchInstance&, Facepunch.MeshBatch" )
local _MeshBatchPhysicsWallLoot = util.FindOverloadedMethodByRef( typ1, "Raycast", bf.public_static, { UnityEngine.Vector3, UnityEngine.Vector3, RefParam2, RefParam3, RefParam4 } )
cs.registerstaticmethod( "tmp", _MeshBatchPhysicsWallLoot )
local MeshBatchPhysics = tmp
tmp = nil




function TraceEyes( direction, netuser, num )
    local npos = netuser.playerClient.lastKnownPosition
    npos.x = direction.x
    npos.y = direction.y
    npos.z = direction.z
    if(num == 2) then
        npos.x = npos.x-0.03
        npos.z = npos.z-0.03
    elseif(num == 3) then
        npos.x = npos.x+0.03
        npos.z = npos.z+0.03
    end
    local rep,hits,boolrep,meshbatch = MeshBatchPhysics(rust.GetCharacter( netuser ).eyesOrigin, npos)  
    local model = false
    if(meshbatch) then
        model = tostring(meshbatch.graphicalModel)
    end
  
    return tostring(hits.collider.gameObject.Name), model, hits.distance
end

function PLUGIN:RegisterLoot(netuser,iid2,register)
    local ray = rust.GetCharacter( netuser ).eyesRay
    local rayobj = {}
    local model = {}
    local distance = {}
    rayobj[1], model[1], distance[1] = self:StartRayCast(ray.direction, netuser,1)
    rayobj[2], model[2], distance[2] = self:StartRayCast(ray.direction, netuser,2)
    rayobj[3], model[3], distance[3] = self:StartRayCast(ray.direction, netuser,3)
    local bad = 0
    if(rayobj[1] == iid2) then
        for i=2,3 do
            if(distance[i]<distance[1]) then
                if(model[i]) then
                    if(string.find(model[i],"pillar") or string.find(model[i],"doorframe") or string.find(model[i],"wall")) then
                        bad = bad + 1
                    end
                end
            end
        end
    end
    if(bad >= 1) then
        self:SendToAdmins("[color red]" .. netuser.displayName .. " used walloot")
        if(register) then
            self.WallLoot[iid2] = netuser
            local tbl = {}
            tbl.name = netuser.displayName
            tbl.steamid = tostring(rust.GetLongUserID(netuser))
            local pos = netuser.playerClient.lastKnownPosition
            tbl.x = pos.x
            tbl.y = pos.y
            tbl.z = pos.z
            table.insert(self.WallLoots,tbl)
            self:Save()
        end
        return true
    end
    return false
end
function PLUGIN:OnItemRemoved(inventory, slot, item)
    local iid2 = inventory.name
    if (iid2 == "WoodBoxLarge(Clone)" or iid2 == "WoodBox(Clone)" or iid2 == "Furnace(Clone)") then
        local hashset = GetPlayersLooting( inventory )
        if(hashset) then
            local it = hashset:GetEnumerator()
            local netuser = false
            while (it:MoveNext()) do
                local networkplayer = it.Current
                netuser = networkplayer:GetLocalData()
            end
            if(netuser and netuser.playerClient) then
                if(self.Inv[inventory] ~= netuser) then
                    self.Inv[inventory] = netuser
                    if(self:RegisterLoot(netuser,iid2,true)) then
                        self:DoStuff(netuser,inventory,item)
                    end
                else
                    if(self.WallLoot[iid2] == netuser) then
                        self:DoStuff(netuser,inventory,item)
                    end
                end
            end
        end
    end
end
function PLUGIN:DoStuff(netuser,inventory,item)
    if(self.Config.Ban) then
        local nsteamid = tostring(rust.GetLongUserID(netuser))
        local detections = 0
        for k,v in pairs(self.WallLoots) do
            if(v.steamid == nsteamid) then
                detections = detections + 1
            end
        end
        if(detections >= self.Config.DetectionsNeededForBan) then
            if(self.Config.BroadCastBan) then
                rust.BroadcastChat(self.Config.chatName, "[color red]" .. netuser.displayName .." was banned for wallooting " .. tostring(detections) .. " times")
            end
            netuser:Ban()
            netuser:Kick(NetError.Facepunch_Kick_Violation,true)
            return
        end
    end
    if(self.Config.Kick) then
        rust.SendChatToUser(netuser, "Anti Wall Loot", "wallooting is forbidden")
        self.WallLooters[netuser] = true
        if(self.Config.BroadCastKick) then
            rust.BroadcastChat(self.Config.chatName, "[color red]" .. netuser.displayName .." was kicked for wallooting.")
        end
        netuser:Kick(NetError.Facepunch_Kick_Violation,true)
    end
  
end
function PLUGIN:Unload()
    if(self.timer) then self.timer:Destroy() end
end

function PLUGIN:StartRayCast(direction, netuser, num)
    local trace, model, distance = TraceEyes(direction, netuser, num)
    if(trace) then
        return trace, model, distance
    end
end
function PLUGIN:SendToAdmins(msg)
    for _, targetuser in pairs( rust.GetAllNetUsers() ) do
        if(targetuser:CanAdmin()) then
            rust.SendChatToUser(targetuser, "Anti Wall Loot", msg)
        end
    end
end
@DreTaX it didnt let me choose lua script so i did it in java
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
I have never used this plugin, I dont even think I have tested it.
But I might as well paste it here
Python:
#PLUGIN CONTAINS SOME DEBUG MESSAGES, YOU CAN REMOVE THEM

__title__ = 'AntiWallLoot'
__author__ = 'Jakkee'
__version__ = '1.0.1'

import clr
clr.AddReferenceByPartialName("Fougerite", "UnityEngine")
import Fougerite
import UnityEngine


class AntiWallLoot:
    def On_PluginInit(self):
        Util.ConsoleLog(__title__ + " by " + __author__ + " Version: " + __version__ + " loaded.", False)

    def On_LootUse(self, LootStartEvent):
        if LootStartEvent.IsObject:
            ray = Util.GetEyesRay(LootStartEvent.Player)
            ray.direction.x - 0.03
            ray.direction.z - 0.03
            cast = UnityEngine.Physics.RaycastAll(ray, 20)
            hits = 0
            lookingatbox = False
            for hit in cast:
                name = hit.collider.gameObject.Name.ToLower()
                #DEBUG LINE BELOW
                Util.log("Found gameObject: " + name)
                #END OF DEBUG
                if name.Contains("woodbox"):
                    lookingatbox = True
                    continue
                if name.Contains("pillar") or name.Contains("doorframe") or name.Contains("wall"):
                    hits =+ 1
            if not lookingatbox:
                LootStartEvent.Cancel()
                LootStartEvent.Player.Message("You are not looking at a chest!")
                return
            elif hits >= 1 and lookingatbox:
                #DEBUG LINE BELOW
                Util.Log("Found " + str(hits) + " objects in the way of chest, Kicking player...")
                #END OF DEBUG
                LootStartEvent.Cancel()
                Util.Log("AntiCrackLoot: " + LootStartEvent.Player.Name + " has been kicked for crack looting!")
                LootStartEvent.Player.Character.netUser.Kick(NetError.Facepunch_Kick_Violation, True)
 
Last edited:

ice cold

Active Member
Trusted Member
Member
Oct 24, 2016
606
876
43
Canada
I have never used this plugin, I dont even think I have tested it.
But I might as well paste it here
Python:
__title__ = 'AntiWallLoot'
__author__ = 'Jakkee'
__version__ = '1.0'

import clr
clr.AddReferenceByPartialName("Fougerite")
import Fougerite
import UnityEngine


class AntiWallLoot:
    def On_PluginInit(self):
        Util.ConsoleLog(__title__ + " by " + __author__ + " Version: " + __version__ + " loaded.", False)

    def On_LootUse(self, LootStartEvent):
        if LootStartEvent.IsObject:
            ray = Util.GetEyesRay(LootStartEvent.Player)
            ray.direction.x - 0.03
            ray.direction.z - 0.03
            cast = Physics.RaycastAll(ray, 20)
            hits = 0
            for hit in cast:
                if hit.collider.gameObject.Name is "pillar" or "doorframe" or "wall":
                    hits =+ 1
            if hits >= 1:
                LootStartEvent.Cancel()
                Util.Log("AntiCrackLoot: " + LootStartEvent.Player.Name + " has been kicked for crack looting!")
                LootStartEvent.Player.Character.netUser.Kick(NetError.Facepunch_Kick_Violation, True)
failed to load UnityEngine becaus its not a module
 

salva

Friendly self-taught developer
Administrator
Jan 31, 2016
577
612
63
import UnityEngine
from UnityEngine import *

???????????