Problem showed on the video : [url]https://www.youtube.com/watch?v=K2zwzsRm8iU[/url]
[LUA]
TrailerList = {}
TrailerList[1] = {
Name = "Profiliner Trailer",
Colour = Color( 255, 255, 255 ),
Model = "models/lonewolfie/trailers/trailer_profiliner.mdl",
Scripts = "scripts/vehicles/lwcars/trailer_profiliner.txt",
Pos = Vector(-240.224350, 289.898895, -12000.968750),
Ang = Angle(8.472741, -113.077385, 0.000000),
Price = 8000,
AddTimePrice = 2400
SpawnVector = Vector(-928.450928, 670.532166,-139.968750)
}
TrailerList[2] = {
Name = "Single Axle Box Trailer",
Colour = Color( 255, 255, 255 ),
Model = "models/tdmcars/trailers/singleaxlebox.mdl",
Scripts = "scripts/vehicles/TDMCars/singleaxleboxtrailer.txt",
Pos = Vector(-240.224350, 289.898895, -12223.968750),
Ang = Angle(8.472741, -113.077385, 0.000000),
Price = 8000,
AddTimePrice = 2400
SpawnVector = Vector(-928.450928, 670.532166,-139.968750)
}
[/LUA]
[LUA]
function SpawnSpecifTrailer()
for _,v in pairs(TrailerList) do
util.AddNetworkString(v.Name)
net.Receive(v.Name, function( len, ply,cmd,args )
local trailer = ents.Create("prop_vehicle_jeep")
trailer:SetModel(v.Model)
trailer:SetKeyValue( "vehiclescript", v.Scripts )
trailer:SetPos(v.Pos)
trailer:SetOwner(ply)
trailer:keysOwn( ply )
trailer:Spawn()
trailer:Activate()
print (v.Name)
print (v.Model)
print (v.Scripts)
print (ply)
end)
end
end
[/LUA]
Because you're not using the net library the way it's meant to be used.
Please look at the wiki page again for how to use net.Receive
i dont get it, what is wrong with the trailer
Haven't figured a way out of the functions.
[editline]7th December 2016[/editline]
By the way, props can touch the trailers but not the players.
This is why im so confused.
You shouldn't be using net.Receive inside of a function. Also, post your sending code.
"weirded lua error"
Literally no Lua error.
[code]
trailer:SetOwner(ply)[/code]
This is the problem. Read the function description on the official Garry's Mod wiki.
Also your code for net.Receive ( it's place ) is bound to cause problems.
Not to mention, currently it does no checks and it will allow anyone to spam spawn the vehicle, etc.
Works now, ty.
Sorry, you need to Log In to post a reply to this thread.