【问题标题】:Disable function to enable another one禁用功能以启用另一个功能
【发布时间】:2022-01-06 12:58:40
【问题描述】:

您好,抱歉打扰了,我目前正在研究 Fivem 的反作弊功能

但是我在 Fivem/gta 中有一个小问题,你有默认的 Natives/Functions

举例

IsPedInAnyVehicle(ped, boolean) -- 当 ped 在车内时返回

我想做的是捕捉函数

喜欢这个

function IsPedInAnyVehicle(ped, boolean)
   -- i want to put my conditions here and when the conditions fit it accepts the real default 
   --   native/function
end

捕获该功能并阻止游戏的本机/默认功能,但现在的问题是何时适合我想执行真正的功能/本机

我想在条件合适时删除我创建的函数,但如果 thad 是可能的,我想删除 提前谢谢

【问题讨论】:

    标签: function lua fivem


    【解决方案1】:

    只需用新函数覆盖函数并保留对原始函数的引用,以便在满足条件时使用它。

    function someFunction()
      print("I'm the old function")
    end
    
    local backup = someFunction
    someFunction = function ()
      if condition then
        backup()
      else
        print("Hey I'm the new function!")
      end
    end
    
    
    someFunction()
    condition = true
    someFunction()
    condition = false
    someFunction()
    

    打印

    Hey I'm the new function
    I'm the old function
    Hey I'm the new function!
    

    【讨论】:

      猜你喜欢
      • 2010-10-04
      • 2020-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多