So GLON doesn't want to work for me. I'm using a NWString on players to store tables via glon, but something isn't working. Here's the table I"m using:
[lua]datastream.Hook("buyCar",function(pl,handler,id,enc,dec)
pl:ChatPrint("You bought a "..dec.Name.."!")
GiveMoney(pl,-dec.Cost)
local cartab = glon.decode(pl:GetNWString("shop_cars")) or {}
table.insert(cartab,dec)
pl:SetNWString("shop_cars",glon.encode(cartab))
end)
concommand.Add("shop_printcars",function(ply,cmd,args)
ply:ChatPrint(ply:GetNWString("shop_cars"))
ply:ChatPrint("You have the following cars:")
for _,v in ipairs(glon.decode(ply:GetNWString("shop_cars"))) do
ply:ChatPrint(v.Name)
end
end)[/lua]
[code]local cars = {
{
Name = "Corvette C6",
Cost = 25000,
Class = "prop_vehicle_jeep",
Author = "Athos",
Information = "A sweet car",
Model = "models/corvette/corvette.mdl",
KeyValues = {
vehiclescript = "scripts/vehicles/corvette.txt"
}
},
{
Name = "Golf GTI",
Cost = 17500,
Class = "prop_vehicle_jeep",
Author = "Athos",
Information = "It's a golf cart!",
Model = "models/golf/golf.mdl",
KeyValues = {
vehiclescript = "scripts/vehicles/golf.txt"
}
},
{
Name = "Supra",
Cost = 22500,
Class = "prop_vehicle_jeep",
Information = "A sweet ride",
Model = "models/supra.mdl",
KeyValues = {
vehiclescript= "scripts/vehicles/supra.txt"
}
},
{
Name = "Cabbie",
Cost = 20000,
Class = "prop_vehicle_jeep",
Author = "Rockstar Games",
Information = "Holy shit a cab!",
Model = "models/Cabbie.mdl",
KeyValues = {
vehiclescript = "scripts/vehicles/cabbie.txt"
}
},
{
Name = "Murcielago",
Cost = 55000,
Class = "prop_vehicle_jeep",
Author = "SgtSgt",
Information = "Another sweet ride",
Model = "models/sickness/murcielago.mdl",
KeyValues = {
vehiclescript = "scripts/vehicles/murcielago.txt"
}
},
}[/code]
The curious thing is, when I do shop_printcars after only buying one car it works fine and buying the car itself works fine, but when buying the second one I get this error:
"includes/modules/glon.lua:245: Expected unescaped to end string at position 196! (Got EOF)"
The unescaped thing is a little box.
So I tried debugging a little like this:
[lua]concommand.Add("shop_printcars",function(ply,cmd,args)
ply:ChatPrint(ply:GetNWString("shop_cars"))
ply:ChatPrint("You have the following cars:")
local tab = glon.decode(ply:GetNWString("shop_cars"))
table.insert(tab,cars[3])
for _,v in ipairs(glon.decode(glon.encode(tab))) do
ply:ChatPrint(v.Name)
end
ply:SetNWString("shop_cars",glon.encode(tab))
end)[/lua]
So it inserted the table right and it printed two different cars right -- the first time. If I tried a second time, it gave me this error: "includes/modules/glon.lua:322: Expected type ID at 200! (Got EOF)"
I have absolutely no clue. Does anyone know what's wrong?
Sorry, you need to Log In to post a reply to this thread.