• Adding Custom weapon to the Gamemode loadout.
    8 replies, posted
Well, I am wanting to make a gamemode and but I am having trouble adding a custom weapon that I coded with this tutorial: [url]http://wiki.garrysmod.com/?title=Your_First_Scripted_Weapon[/url] It is exact(at least I think it is - I have compared them) and I typed it all by hand no c/p. I saved as shared.lua - Here is pastebin: [url]http://pastebin.com/ervKNcH9[/url] But when I add it to the layout with ply:Give( "custom_weapon" ) .... it doesn't show up. I have downloaded the Skeleton gamemod from garrysmod.org and put it into the entities/weapons folder. So my shared.lua file is in "custom_weapon" folder in the location. The empty_weapon included which was a sample weapon in the skeleton gamemode does work when I add it to the loadout and I noticed it was coded a little differently. So basically what I am asking is how do i get my custom weapon to show on the loadout.
Ok Say like your Gamemode is in the gamemodes folder in Garrsymod/garrysmod Well go into your gamemode folder Goto gamemodes/(yourgamemode)/entities/weapons Then if u have stuff like Gmdm_pistol then Shared.lua then replace the code with whatever I did that with GMDM
I have that. I have a folder in the gamemodes/(yourgamemode)/entities/weapons called custom_weapon and then in the function GM:PlayerLoadout( ply ) i have ply:Give( "custom_weapon" ) but nothing is showing for it in game. [editline]5th July 2011[/editline] I just noticed that the tut puts ";" on the end of lines and most all other code and other examples do not. After removing, It still hasnt worked but just my observation.
the ';' is a C habit for some people. And are you getting any errors from the weapon in your console?
[QUOTE=jrj996;30939312]the ';' is a C habit for some people. And are you getting any errors from the weapon in your console?[/QUOTE] Aww yes, here it is: [QUOTE] --- Missing Vgui material texturemissing [gamemodes\bizrp\entities\weapons\custom_weapon\shared.lua:59] '=' expected near 'end' Sending 1014 'User Info' ConVars to server (cl_spewuserinfoconvars to see) Scanning for downloaded fonts.. Reloading Particles.. Attempted to create unknown entity type custom_weapon! NULL Ent in GiveNamedItem! [/QUOTE]
Line 56 in pastebin: [lua] if (!SERVER) then retrun end;[/lua] Change 'retrun' to 'return' :v:
[QUOTE=thefreeman193;30944279]Line 56 in pastebin: if (!SERVER) then retrun end; Change 'retrun' to 'return' :v:[/QUOTE] Yep thanks, just noticed the error line 59. It's always the simplest errors. Is there a way to stop this from appearing on my hud? [gamemodes\bizrp\entities\weapons\custom_weapon\shared.lua:69] attempt to call field 'Owner' (a userdata value) SOLVED!
I would rename your file to shared.lua not sha red.lua
It was just a copy from the console so when it wrapped the text it added it. It is shared.lua but thanks. No need to bump plz.
Sorry, you need to Log In to post a reply to this thread.