Вопрос PhysicsInitBox

скачал сборочку на брокене))
решил по фулу зафиксить её ну и в итоге получил кучу говна связанную с физикой дропа бабок
ну зацените гуру луа кодинга как зафиксил хуйню
lua:
Развернуть Свернуть Копировать
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")

include("shared.lua")

function ENT:Initialize()
    self:SetModel("models/props/cs_assault/money.mdl")
    self:SetUseType(SIMPLE_USE)
    self.nodupe = true
    self.ShareGravgun = true
    self:PhysicsInit(SOLID_VPHYSICS)
    self:SetMoveType(MOVETYPE_VPHYSICS)
    self:SetSolid(SOLID_VPHYSICS)

    local phys = self:GetPhysicsObject()
    if not IsValid(phys) then
        print("[error] used PhysicsInitBox.")
        self:PhysicsInitBox(Vector(-4, -4, -1), Vector(4, 4, 1))
        self:SetCollisionBounds(Vector(-4, -4, -1), Vector(4, 4, 1))
        phys = self:GetPhysicsObject()
    end

    if IsValid(phys) then
        phys:Wake()
    else
        print("[BLAYT ERROR!] fizika ne work posle PhysicsInitBox!")
    end
end

function ENT:Use(activator, caller)
    if activator:IsBanned() then return end

    local amount = self:Getamount() or 0
    activator:AddMoney(amount)

    hook.Call("PlayerPickupRPMoney", GAMEMODE, activator, amount, activator:GetMoney())

    rp.Notify(activator, NOTIFY_SUCCESS, term.Get("MoneyFound"), amount)
    self:Remove()
end

function rp.SpawnMoney(pos, amount)
    local moneybag = ents.Create("spawned_money")
    moneybag:SetPos(pos)
    moneybag:Setamount(math.min(amount, 2147483647))
    moneybag:Spawn()
    moneybag:Activate()
    return moneybag
end

function ENT:Touch(ent)
    if ent:GetClass() ~= "spawned_money" or self.hasMerged or ent.hasMerged then return end

    ent.hasMerged = true
    ent:Remove()

    self:Setamount(self:Getamount() + ent:Getamount())
end
local ents = ents
timer.Create("rp_moneymerge", 5, 0, function()
    for _, money in ipairs(ents.FindByClass("spawned_money")) do
        for _, v in ipairs(ents.FindInSphere(money:GetPos(), 40)) do
            if IsValid(money) and IsValid(v) and (v ~= money) then
                local class = v:GetClass()

                if class == "spawned_money" and not money.Combining and not v.Combining then
                    v.Combining, money.Combining = true, true
                    money:Setamount(v:Getamount() + money:Getamount())
                    v:Remove()
                    money.Combining = false
                    break
                elseif class == "money_basket" and not money.Combining then
                    money.Combining = true
                    v:Setmoney(v:Getmoney() + money:Getamount())
                    money:Remove()
                    break
                end
            end
        end
    end
end)
 
  • 571
  • 9
  • 102
Если интересно, то у меня так

JavaScript:
Развернуть Свернуть Копировать
AddCSLuaFile()

ENT.Type = "anim"
ENT.PrintName = "Money"
ENT.Category = "Helix"
ENT.Spawnable = true
ENT.ShowPlayerInteraction = true
ENT.bNoPersist = true

function ENT:SetupDataTables()
    self:NetworkVar("Int", 0, "Amount")
end

if (SERVER) then
    local invalidBoundsMin = Vector(-8, -8, -8)
    local invalidBoundsMax = Vector(8, 8, 8)

    function ENT:Initialize()
        self:SetModel(ix.currency.model)
        self:SetSolid(SOLID_VPHYSICS)
        self:PhysicsInit(SOLID_VPHYSICS)
        self:SetCollisionGroup(COLLISION_GROUP_DEBRIS_TRIGGER)
        self:SetUseType(SIMPLE_USE)

        local physObj = self:GetPhysicsObject()

        if (IsValid(physObj)) then
            physObj:EnableMotion(true)
            physObj:Wake()
        else
            self:PhysicsInitBox(invalidBoundsMin, invalidBoundsMax)
            self:SetCollisionBounds(invalidBoundsMin, invalidBoundsMax)
        end
    end

    function ENT:Use(activator)
        if (self.ixSteamID and self.ixCharID) then
            local char = activator:GetCharacter()

            if (char and self.ixCharID != char:GetID() and self.ixSteamID == activator:SteamID()) then
                activator:NotifyLocalized("itemOwned")
                return false
            end
        end

        activator:PerformInteraction(ix.config.Get("itemPickupTime", 0.5), self, function(client)
            if (hook.Run("OnPickupMoney", client, self) != false) then
                self:Remove()
            end
        end)
    end

    function ENT:UpdateTransmitState()
        return TRANSMIT_PVS
    end
else
    ENT.PopulateEntityInfo = true

    function ENT:OnPopulateEntityInfo(container)
        local text = container:AddRow("name")
        text:SetImportant()
        text:SetText(ix.currency.Get(self:GetAmount()))
        text:SizeToContents()
    end
end
 
Оно у тебя физику не инитило потому что у тебя ксс контент к серверу не подключен, чекни тот же самый spawned_money у darkrp режима
 
Назад
Сверху Снизу