尝试调用空值(字段“Draw3DText”)

我在cl_main.lua中有这个"函数":

Citizen.CreateThread(function()
   for i=1,#Config.SpecialStores do
      local Blip=AddBlipForCoord(Config.SpecialStores[i].Coords);
      SetBlipSprite(Blip,Config.SpecialStores[i].Blip[1]);
      SetBlipDisplay(Blip,4);
      SetBlipScale(Blip,Config.SpecialStores[i].Blip[3]);
      SetBlipColour(Blip,Config.SpecialStores[i].Blip[2]);
      SetBlipAsShortRange(Blip,true);
      BeginTextCommandSetBlipName('STRING');
      AddTextComponentString(Config.SpecialStores[i].Label);
      EndTextCommandSetBlipName(Blip)
   end
   while true do
      local sleepThread,Player=1500,PlayerPedId();
      while not Stores.Interiors do
         Citizen.Wait(100end
      if(GetInteriorFromEntity(Player)~=0then
         for _,Data in pairs(Stores.Interiors)do
            if(GetInteriorFromEntity(Player)==Data.InteriorId)then
               sleepThread=5local Dst=#(GetEntityCoords(Player)-Data.Checkout);
               if Dst<15.0 then
                  Utils.Draw3DText(Data.Checkout,'~g~E~w~');
                  if Dst<1.0 and IsControlJustReleased(038) then
                     Stores.OpenStore()
                  end
               end
               if IsPedArmed(Player,7and Data.Robbable then
                  if IsPlayerFreeAiming(PlayerId())then
                     local Retval,Entity=GetEntityPlayerIsFreeAimingAt(PlayerId());
                     if Retval and GetEntityModel(Entity)==GetHashKey('mp_m_shopkeep_01'then
                        Stores.StartRobbing({
                           InteriorId=Data.InteriorId,
                           Cashier=Entity
                        })
                     end
                  else
                     local Retval,Entity=GetPlayerTargetEntity(PlayerId());
                     if Retval and GetEntityModel(Entity)==GetHashKey('mp_m_shopkeep_01'then
                        Stores.StartRobbing({
                           InteriorId=Data.InteriorId,
                           Cashier=Entity
                        })
                     end
                  end
               end
            end
         end
      end

然后我在f8中得到了"尝试调用空值(字段“Draw3DText”)"。

我尝试在顶部添加“Utils = {}”,因为我大致了解它的"utils"返回为空值。有人知道如何解决吗?

原文链接 https://stackoverflow.com/questions/70531916

点赞