I was moving some map files, and I rebooted my server (FiveM) and when I called it again it started to give this problem, I undo everything I did, I put the old files again, but the error kept happening. And I do not know what to do to solve it.
I threw all the changed files back to normal, but it did not solve anything.
local cfg = module("cfg/blips_markers")
-- add additional static blips/markers
AddEventHandler("vRP:playerSpawn",function(user_id, source, first_spawn)
if first_spawn then
for k,v in pairs(cfg.blips) do
vRPclient.addBlip(source,{v[1],v[2],v[3],v[4],v[5],v[6]})
end
for k,v in pairs(cfg.markers) do
vRPclient.addMarker(source,{v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11]})
end
end
end)
Inside the server the blip_markes are gone and some player data too, because of that.
A quick debug would be to assign cfg the value of an integer, if your problem solves, you know that something is wrong with module("cfg/blips_markers"). However, please provide the code associated with module("cfg/blips_markers").
Related
I'm attempting to constantly read and parse a log file (Minecraft log file) by using io.popen in tandem with Ubuntu's tail command so that I can send some messages upon certain events.
Now, I have mostly everything working here, except one small issue. After a while of reading, the entire program just freezes.
Here is the relevant code:
-- Open the tail command, return a file handle for it.
local pop = io.popen(config.listen_command)
-- Simply read a single line, I've pulled this into its own
-- function so that if this ever needs changing I can do so
-- easily.
local function get_line()
logger:log(4, "READ LINE")
return pop:read("*l")
end
-- For each line in the log file, check if it matches any
-- of a list of patterns, return the matches and the
-- pattern information if so.
local function match_line()
local line = get_line()
logger:log(4, "Line: %s", line)
-- This all works, and I've tested that it's not freezing
-- here. I've just included it for completion of the call
-- -stack.
for event_type, data in pairs(config.message_patterns) do
for event_name, pattern in pairs(data) do
local matches = {line:match(pattern)}
if matches[1] then
return event_type, event_name, matches
end
end
end
end
-- The main loop, simply read a line and send a message
-- if there was a match.
logger:log(4, "Main loop begin.")
while true do
local event_type, event_name, matches = match_line()
-- ...
-- The rest of the code here is not relevant.
config.listen_command = "tail -F --lines=1 latest.log"
The issue is in the get_line function. After a while of reading the log file, it completely freezes on the pop:read("*l"). It prints the READ LINE message, but never prints the Line: <whatever data here> line.
This is a really strange issue that I've been getting really confused about. I've tried swapping to different distributions of Lua (Luvit, LuaJIT, Lua) and a very large amount of debugging, changing small things, rerunning, ... But I cannot think of anything that'd be causing this.
Perhaps there's something small I've missed.
So my question here is this: Why is pop:read("*l") freezing, even though more data is being outputted to the logfile? Is there a way to fix this? Perhaps to detect if the next read will freeze indefinitely, so I can try closing the popen'ed file and re-open it (or to preferably stop it happening altogether?)
I'm following your roguelike tutorial and have encountered a problem I do not know how to solve. This is my first-time coding with Lua
If r.nospawn then return 0
--Attempt to index local "R" (a nil value)
I asked the PICO-8 discord server, they tried to help me, but I still don't fully understand, and I did not want to pester them further with the issue. The name of my file on PICO-8 is called Rogue - if that has anything to do with the issue.
Here's a picture of the error, the discord comment I received, and a link to the full list of code on GitHub.
Error in PICO-8
Discord Comment
Github Code
I think you are missing a simple failure case. i.e. what happens when all the entries in rpot have been removed. Then local r=getrnd(rpot) should return null. That might be an error in it's own right i.e. there should always be something to allocate from there.
However getrnd will fail.
function getrnd(arr)
return arr[1+flr(rnd(#arr))]
end
In the case when arr is empty you will try and return element 1, which will be out of bounds. I don't know lua but it might return null for you which leads to the next problem. But that has a simple fix:
repeat
local r=getrnd(rpot)
if r
placed+=infestroom(r)
del(rpot,r)
end
until #rpot==0 or placed>maxmons[floor]
local place = game.Players.LocalPlayer.PlayerGui
function inventrans(amount)
if place.inven.InvenSee:FindFirstChild("Lava")then
place.Lava.Amount.value = place.Amount.value+amount
script.Parent.Amount = script.Parentarent.Amount-amount
else
game.ReplicatedStorage.StorageIco.Lava:clone(1).Parent =
game.Players.LocalPlayer.PlayerGui.inven.InvenSee.Lava
place.Lava.Amount.value = place.Amount.value+amount
script.Parent.Amount = script.Parentarent.Amount-amount
end
end
inventrans(23)
I get the error Lava is not a valid member of Frame.
I am trying to make an inventory system for my game but there is an error that I do not know how to fix. please help
Make sure your script is a local script and located inside a tool or the player gui.
game.Players.LocalPlayer.PlayerGui will be nil if it's not the case.
Make sure you located the object correctly.
You should use :WaitForChild
Example: game.Workspace:WaitForChild("Part")
Which will wait for the part to be added in the Workspace. The reason why you should use it is because your code is ran so fast, the object doesn't have enough time to create the part, so it returns an error. But if you use WaitForChild, it'll wait for the object to load in and then it runs the code.
I've got an addon on my server that basically allows you to create territories. On top of that, I have one which allows you to make permanent properties, which players own even when they aren't online. Additionally, you are able to save the props inside these permanent buildings so that when you next get on, the props are all still there.
It was working fine, but I now seem to be encountering the following error whenever I save the props inside my house and restart the server. Also, a lot of the houses don't seem to work. But, when I unsave the props inside a house and restart, everything is back to normal.
The error
[ERROR] addons/darkrpmodification-master/lua/darkrp_modules/territory/sh_init.lua:514: bad argument #1 to 'pairs' (table expected, got nil)
1. pairs - [C]:-1
2. LoadProps - addons/darkrpmodification-master/lua/darkrp_modules/territory/sh_init.lua:514
3. tsetUpDoors - addons/darkrpmodification-master/lua/darkrp_modules/territory/sv_init.lua:273
4. unknown - addons/darkrpmodification-master/lua/darkrp_modules/territory/sv_init.lua:290
Code
function BuyableTerritory:LoadProps(steamid, t)
for k, v in pairs(t) do
local e = ents.Create("prop_physics")
e:SetPos(v.pos)
e:SetAngles(v.ang)
e:SetModel(v.model)
if v.color then
e:SetColor(v.color)
end
if v.material then
e:SetMaterial(v.material)
end
e:Spawn()
e.permaOwner = steamid
e:GetPhysicsObject():EnableMotion(false)
end
local ply = DarkRP.findPlayer(steamid)
if IsValid(ply) then
self:SetPropsOwner(ply, ply:SteamID())
end
The code starts at line 513, so the second line in is the one having problems. Thank you.
Just read the error message. It tells you that the input to pairs() is nil instead of the expected table. pairs is a so called iterator. It only works with a Lua table as input.
Your input t to BuyableTerritory:LoadProps(steamid, t) is not valid.
You either have to change that or check if t is a table befor you call pairs(t) to prevent the error from happening.
Go to line 273 of sv_init.lua to find out whats going on.
I don't have a lot of coding experience, did some C a few years ago, so that helps, but Lua handles things a bit differently, so I can't keep track.
I sometimes (not always) get this error when a friend or guildy logs into the game:
Date: 2013-06-14 16:57:57
ID: -1
Error occured in: Global
Count: 4
Message: ..\AddOns\Tukui\scripts\chat.lua line 335:
attempt to concatenate upvalue 'classColor' (a nil value)
Debug:
[C]: ?
Tukui\scripts\chat.lua:335: AddMessage()
..\FrameXML\ChatFrame.lua:2755: ChatFrame_MessageEventHandler()
..\FrameXML\ChatFrame.lua:2491: ChatFrame_OnEvent()
...s\WIM\Libs\LibChatHandler-1.0\LibChatHandler-1.0.lua:281:
...s\WIM\Libs\LibChatHandler-1.0\LibChatHandler-1.0.lua:252
...s\WIM\Libs\LibChatHandler-1.0\LibChatHandler-1.0.lua:308:
...s\WIM\Libs\LibChatHandler-1.0\LibChatHandler-1.0.lua:296
I have to do a reload of the ui after this happens to be able to see chat text again for that person.
Line 335 in that .lua file is this:
text = replace(text, "^|Hplayer:(.+)|h%[(.+)%]|h", "|Hplayer:%1|h|cff"..classColor.."%2|r|h")
Now I've learned that the .. indicates the concatenate function, but that isn't really helping me.
I don't know if this is enough information, but if you need it I can post the whole local function or whatever else is required.
If it makes any difference, I'm running the 3.3.5a WoW client.
You are probably using a global that gets defined from some other addon in a now deterministic way
While the (classColor or "") will get you rid of the error, you should try and find why that variable (classColor) is sometimes defined and sometimes not. Maybe it happens only for certain classes?
A simple hack would be to just replace
..classColor..
with
..(classColor or "")..
where it will select a blank string when classColor has no value assigned to it.