• Weapon Vendor Crash Issue
    0 replies, posted
I'm trying to create this weapon vending machine, and it works ( kinda ). I'm using it along-side Dark RP. It doesn't crash if I'm not using Dark RP, however obviously can't test if the rest of it works, as I need money :P I don't understand why Dark RP would make it crash when I spawn a weapon with the entity placed. The issue is, I can use the Q menu to spawn Half Life 2 weapons, however as soon as I place down my entity and try and spawn a HL2 weapon, the server crashes. I've attached my code and the error log from the moment I place it to the crash. EDIT: I've just checked this with other weapons such as FAS2.0 and the same happens. As soon as I spawn one it crashes. init.lua [CODE] //DUMPSTER ENTITY INIT.LUA AddCSLuaFile( "cl_init.lua" ) -- Make sure clientside AddCSLuaFile( "shared.lua" ) -- and shared scripts are sent. include('shared.lua') function ENT:Initialize() util.AddNetworkString( "sendPurchasedWeapon" ) util.AddNetworkString( "sendWeapons" ) sgn_vendor_weapons = { weapon_p2282 = 1000, weapon_pumpshotgun2 = 2000, weapon_mac102 = 3000} self:SetModel( "models/props_interiors/VendingMachineSoda01a.mdl" ) self:PhysicsInit( SOLID_VPHYSICS ) self:SetMoveType( MOVETYPE_VPHYSICS ) self:SetSolid( SOLIlD_VPHYSICS ) local phys = self:GetPhysicsObject() if (phys:IsValid()) then phys:Wake() end end function ENT:Use( activator, caller ) local menuOpen = false if activator:IsPlayer() && menuOpen == false then menuOpen = true print("Player has activated item") net.Start( "sendWeapons" ) net.WriteTable( sgn_vendor_weapons ) net.Send( activator ) menuOpen = false else end end net.Receive( "sendPurchasedWeapon", function( len, pl ) weapon = net.ReadString() price = net.ReadString() newPrice = 0 - tonumber(price) print( weapon ) print( newPrice ) print( tostring(pl) ) if pl:canAfford( tonumber(price) ) then pl:PrintMessage( HUD_PRINTTALK, "I'm new here." ) pl:addMoney( newPrice ) pl:Give( "weapon_p2282" ) else print("You can not afford this") end end ) [/CODE] cl_init.lua [CODE] // Title Font include('shared.lua') surface.CreateFont( "title", { font = "Arial", size = 20, weight = 500, blursize = 0, scanlines = 0, antialias = true, } ) net.Receive( "sendWeapons", function() print("received") local sgn_vendor_weapons = net.ReadTable() for k, v in pairs(sgn_vendor_weapons) do print(tostring(k) .. ", " .. tostring(v)) end DrawHomeScreen( sgn_vendor_weapons ) end ) function DrawHomeScreen( sgn_vendor_weapons ) // Background Colour local vendorScreen = vgui.Create( "DPanel" ); vendorScreen:SetSize( 400, 400); vendorScreen:SetPos( ( ScrW() / 2 ) - 150, ( ScrH() / 2 ) - 150 ); vendorScreen:MakePopup( ); vendorScreen:PostMessage( "SetTitle", "text", "This is the title" ); vendorScreen.Paint = function( self,width,height ) surface.SetDrawColor( Color( 30, 30, 30, homeScreenBackgroundAlpha ) ) surface.DrawRect( 0 , 0, ScrW(), ScrH() ) end // Variables that change for height local ListXPos = 25 local listYPos = 75 local title = vgui.Create( "DLabel", vendorScreen ) title:SetFont( "title" ) title:SetPos( 25, 25 ) title:SetText( "Weapon Vendor" ) title:SetColor(Color(236, 240, 241, 255)) title:SetSize( 300, 25 ) for k, v in pairs( sgn_vendor_weapons ) do local weaponName = vgui.Create( "DLabel", vendorScreen ) weaponName:SetPos( ListXPos, listYPos ) weaponName:SetText( k ) weaponName:SetColor(Color(236, 240, 241, 255)) weaponName:SetSize( 40, 25 ); local priceList = vgui.Create( "DLabel", vendorScreen ) priceList:SetPos( ListXPos + 100, listYPos ) priceList:SetText( v ) priceList:SetColor(Color(236, 240, 241, 255)) local purchaseButton = vgui.Create( "DButton", vendorScreen ) purchaseButton:SetPos( ListXPos + 150, listYPos ) purchaseButton:SetText( "Purchase" ) purchaseButton:SetColor(Color(236, 240, 241, 255)) purchaseButton.DoClick = function() vendorScreen:Remove() net.Start( "sendPurchasedWeapon" ) net.WriteString( tostring(k) ) net.WriteString( tostring(v) ) net.SendToServer() end listYPos = listYPos + 25 end end function ENT:Draw() self:DrawModel() end [/CODE] shared.lua [CODE] //DUMPSTER ENTITY SHARED.LUA ENT.Type = "anim" ENT.Base = "base_gmodentity" ENT.PrintName= "Weapon Vender" ENT.Author= "Semajnad" ENT.Contact= "" ENT.Purpose= "Spawns" ENT.Instructions= "Press 'E'" ENT.Spawnable = true ENT.AdminSpawnable = false ENT.RenderGroup = RENDERGROUP_BOTH [/CODE] error.log [CODE] SGN | Semajnad<STEAM_0:1:22686651> spawned sent weapon_vendor ServerLog: SGN | Semajnad (STEAM_0:1:22686651) Gave himself a weapon_357 Giving SGN | Semajnad a weapon_357 !Get!Get [/CODE] ^^ That's what the error.log says, but this is what happens in console when the server crashes: [CODE] SGN | Semajnad<STEAM_0:1:22686651> spawned sent weapon_vendor ServerLog: SGN | Semajnad (STEAM_0:1:22686651) Gave himself a weapon_357 Giving SGN | Semajnad a weapon_357 !Get!Get !Get dlopen failed trying to load: /opt/server-files/source/linux32/libsteam.so with error: /opt/server-files/source/linux32/libsteam.so: cannot open shared object file: No such file or directory dlopen failed trying to load: /opt/server-files/source/linux32/libsteam.so with error: /opt/server-files/source/linux32/libsteam.so: cannot open shared object file: No such file or directory dlopen failed trying to load: /opt/server-files/source/linux32/libsteam.so with error: /opt/server-files/source/linux32/libsteam.so: cannot open shared object file: No such file or directory Segmentation fault (core dumped) Add "-debug" to the ./srcds_run command line to generate a debug.log to help with solving this problem Sun Nov 2 12:51:47 GMT 2014: Server restart in 10 seconds [/CODE]
Sorry, you need to Log In to post a reply to this thread.