Alright, so when I host a listen server the following code works fine, but when I host it on my rented server the menu doesn't pop up. There are no errors and no sign of trouble, what could be causing this?
[lua]
ENT.Base = "base_ai"
ENT.Type = "ai"
ENT.PrintName = "Vehicle Dealer"
ENT.Author = "Lyeol"
ENT.Contact = ""
ENT.Purpose = "Sells vehicles."
ENT.Instructions = "A Vendor!"
ENT.AutomaticFrameAdvance = true
ENT.Spawnable = false
ENT.AdminSpawnable = false
function ENT:Use( ply, caller )
self:EmitSound(table.Random(VoiceListM))
SendUserMessage("RP_OpenVehicleMenu", ply)
end
function ENT:AcceptInput(input, entActivator, entCaller, data)
if string.lower(input) == "use" then
self:Use(entActivator,entCaller)
return
end
end
[/lua]
[lua]
require('datastream')
w = ScrW()
h = ScrH()
function RP_OpenVehicleMenu()
local client = LocalPlayer()
local frame = vgui.Create("DFrame")
frame:SetSize(w / 2 + 140, h / 2 + 100)
frame:SetTitle("Vehicle Dealership")
frame:MakePopup()
frame:SetBackgroundBlur( true )
frame:Center()
local VehMenu = vgui.Create( "DPanelList", frame )
VehMenu:SetPos( 10, 30 )
VehMenu:SetSize( frame:GetWide() - 20, frame:GetTall() - 40 )
VehMenu:SetSpacing(5)
VehMenu:EnableVerticalScrollbar( true )
VehMenu:EnableHorizontal( false )
VehMenu:SetPadding(5)
VehMenu.Paint = function()
end
for k,v in pairs(RP_Vehicle) do
if(v.Team == nil) then
local Pan = vgui.Create( "DPanel" )
Pan:SetSize( VehMenu:GetWide() - 10, 100 )
Pan.Paint = function()
surface.SetDrawColor( 50, 50, 50, 255 )
surface.DrawRect( 0, 0, Pan:GetWide(), Pan:GetTall() )
draw.SimpleText("Name: "..v.Name, "ScoreboardText", 5, 5, Color(255,255,255,255))
draw.SimpleText("MaxSpeed: "..v.MaxSpeed, "ScoreboardText", 5, 20, Color(255,255,255,255))
draw.SimpleText("Steering: "..v.Steering, "ScoreboardText", 5, 35, Color(255,255,255,255))
draw.SimpleText("Cost: $"..v.Cost, "ScoreboardText", 5, 50, Color(255,255,255,255))
end
local Icon = vgui.Create( "SpawnIcon",Pan)
Icon:SetPos( Pan:GetWide() - 80, 5 )
Icon:SetModel( v.Mdl )
Icon:SetToolTip(nil)
local button = vgui.Create( "DButton", Pan )
button:SetSize( Pan:GetWide() - 20, 20 )
button:SetPos( 5, Pan:GetTall() - 25 )
button:SetText( "Purchase "..v.Name.."!" )
button.DoClick = function( button )
v.Name = string.Replace(v.Name," ","")
datastream.StreamToServer( "RP_BuyCarVehicle", { v.Name, v.Cost, v.Mdl, v.Script } )
frame:Close()
end
VehMenu:AddItem(Pan)
end
end
end
usermessage.Hook("RP_OpenVehicleMenu", RP_OpenVehicleMenu)
[/lua]
AddCSLuaFile() the clientside file
That does not appear to work.
[QUOTE=Lyeol;24065681]That does not appear to work.[/QUOTE]
The information about lua files here might be helpful!
[url]http://wiki.garrysmod.com/?title=Chair_Throwing_SWEP#init.lua[/url]
Sadly, nothing in there worked either. I'm not sure what's going on but I've never run into this with my previous scripts.
Add the code AddCSLuaFile('cl_init.lua') to the very top of the SERVER SIDE lua file (init.lua). The problem is that that on a listen server the client technically is the server too, so all of these files are automatically loaded into the game. On a dedicated server, if there is no AddCSLuaFile then only the server-side code will be run, and when the client connects, they will not end up downloading the clientside file, so when the server part of the entity sends the command to the client to open the derma panel, it is trying to run a non existant piece of code. Also, the frame:MakePopup() should be AFTER all the derma stuff like declaring the buttons, labels, etc because that will make tue frame show before the derma controls are added to it if you leave that command at the top.
Sorry, you need to Log In to post a reply to this thread.