Script – die besten Beiträge

Trucker Skript geht nicht?

Das ist der Fehler in tx:

No such export GetCoreObject in resource ND_Core

Das hier ist die Server lua:

--[[
TruckJob - Created by Lama 
For support - https://discord.gg/etkAKTw3M7
Do not edit below if you don't know what you are doing
]] --

-- ND_Framework exports (edit with your framework's)

NDCore = exports["ND_Core"]:GetCoreObject()

-- variables, do not touch
local deliveries = {}
local playersOnJob = {}

-- function to check if the client is actually at the job ending location before giving them the money
function isClientTooFar(location)
  local distance = #(GetEntityCoords(GetPlayerPed(source)) - vector3(location.x, location.y, location.z))

  -- checking from a distance of 15 because it might not be 100% correct
  if distance > 25 then return true
  else return false
  end
end
RegisterNetEvent("lama_jobs:started", function()
  local src = source
  playersOnJob[src] = true
end)
RegisterNetEvent("lama_jobs:delivered", function(location)
  local src = source
  if playersOnJob[src] and not isClientTooFar(location) then
    -- keep track of amount of deliveries made
    if not deliveries[src] then
      deliveries[src] = 0
    end
    deliveries[src] = deliveries[src] + 1
  else
    print(string.format("^1Possible exploiter detected\nName: ^0%s\n^1Identifier: ^0%s\n^1Reason: ^0has delivered from a too big distance", GetPlayerName(source), GetPlayerIdentifier(source, 0)))
  end
end)
RegisterNetEvent("lama_jobs:finished", function()
  local src = source
  if not deliveries[src] or deliveries[src] == 0 then
    print(string.format("^1Possible exploiter detected\nName: ^0%s\n^1Identifier: ^0%s\n^1Reason: ^0has somehow requested to be paid without delivering anything", GetPlayerName(source), GetPlayerIdentifier(source, 0)))
  else
    -- calculate amount of money to give to the player
    local amount = Config.PayPerDelivery * deliveries[src]

      -- only give the money to the client if it is on the job and near the ending location
    if playersOnJob[src] and not isClientTooFar(Config.DepotLocation) then
      -- give the money to player
      -- if using another framework than ND, simply change the function below to your framework's
      deliveries[src] = 0
      playersOnJob[src] = false
      NDCore.Functions.AddMoney(amount, src, "bank")
    else
      print(string.format("^1Possible exploiter detected\nName: ^0%s\n^1Identifier: ^0%s\n^1Reason: ^0has somehow requested to be paid without being near the job ending location", GetPlayerName(source), GetPlayerIdentifier(source, 0)))
    end
  end
end)
RegisterNetEvent("lama_jobs:forcequit", function()
  local src = source
  local penalty = Config.Penalty
  NDCore.Functions.DeductMoney(penalty, src, "bank")
end)

-- version checker
Citizen.CreateThread(function()
  updatePath = "/lama-development/TruckJob"
  resourceName = "TruckJob by Lama"
  function checkVersion(err, responseText, headers)

    -- Returns the version set in the file
    local curVersion = GetResourceMetadata(GetCurrentResourceName(), "version")
    if responseText == nil or curVersion == nil then
      print("^1There was an error retrieving the version of " .. resourceName .. ": the version checker will be skipped.")
    else
      if tonumber(curVersion) == tonumber(responseText) then
        print("^2" .. resourceName .. " is up to date. Enjoy.")
      else
        print("^1" .. resourceName .. " is outdated.\nLatest version: " .. responseText .. "Current version: " .. curVersion .. "\nPlease update it from: https://github.com" .. updatePath)
      end
    end
  end
  PerformHttpRequest("https://raw.githubusercontent.com" .. updatePath .. "/main/version", checkVersion, "GET")
end)
lua, Script

Frage zu c# bzw. #script?

Kennt sich jemand mit #script aus?

Ich habe folgendes Skript:

 "Script/DeviceTemplate": {
        "Content": "{{var assignments = []}}
{{var nodeId = ServiceTask.DeviceInstallationServiceTask.Details.NodeId}}
{{#each groupName in Typicals.DeviceTypes.xxx.DeviceTypicals[ServiceTask.DeviceInstallationServiceTask.Details.Typical.Name].SignalGroups}}
{{var index = 0}}
{{#each signal in Typicals.DeviceTypes.xxx.SignalGroups[groupName].SignalList}}
{{var baseComponent = ServiceTask.DeviceInstallationServiceTask.Details.Typical.SignalAssignments[groupName].BaseComponent}}
{{var _ = assignments.push({
    "assignmentIndex": index,
	"deviceId": "" + nodeId,
    "sparkplugName": baseComponent + signal.MetricBaseName
})}}
{{index = index + 1}}
{{/each}}
{{/each}}
{{ {
  "system": {
    "deviceName": nodeId
  },
  "apps": [
    {
      "appName": "SPARKPLUG",
      "appId": 12345,
      "settings": {
                "clientId": nodeId,
                "keepAliveInterval": 120,
                "publishInterval": 120,
                "startupDelay": 50
      },	 
      "sparkplugSettings": {
            "mqttTopic": "spBv1.0",
            "sparkplugTopic": "NTN/{MessageType}/" + nodeId
      },
      "assignments": assignments
    }
  ]
} |> json}}"
      }

Dieses hat zwei Schleifen, in der inneren Schleife soll die Variable index um 1 erhöht werden. Alles funktioniert, nur bekomme ich in der Ausgabe für jeden Aufruf von

index = index + 1

ebenfalls eine Ausgabe:

     1
     2
     3
     4
     5
     6
     7
     8
     9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
   {"system":{"deviceName......

Wie kann ich die Ausgabe von 1 bis 23 unterdrücken?

Software, IT, programmieren, C Sharp, Code, Programmiersprache, Script, Softwareentwicklung

Meistgelesene Beiträge zum Thema Script