Entitiy / Weapon spawning

I was wondering if its possible to make a very simple line of code to make a jb_primary_m4a1 to spawn were a weapon_m4a1 would on a map. I’m not bothered about replacing it just spawning in the same place. It used to happen on a server I was a administrator on and now its closed I have started to work on my own server (as you can probably tell -_-). Its something I have just thought of doing and will be a lot less trouble them making them spawn by putting cords in :stuck_out_tongue:

Thank you very much for the help!

So basically, a ‘make for me’ thread ?

You can probably get away with something along the lines of:



function weapons.Alias( old, new )
  local t = weapons.Get( old )
  weapons.Register( t, new )
end

weapons.Alias( "weapon_m4a1", "jb_primary_m4a1" )

Not tested, but you get the idea.

Just rename jb_primary_m4a1 to weapon_m4a1 or create and entity named weapon_m4a1 that spawns jb_primary_m4a1. I don’t believe there is “a simple line of code” to fix it.

No… No its not Netheous. Its a question on what line of code would be used if there is one.

There’s no built-in single line solution without renaming files or folders.

Thanks for the help Kogitsune but I couldn’t get it to work. I think Robots idea would work but how I would setup the shared.lua of the entitiy?

Just create a file named weapon_m4a1.lua and spawn jb_primary_m4a1 from ENT:Initialize and remove the weapon_m4a1.

[editline]19th October 2013[/editline]

in lua/entities/ obviously.

So something like



function ENT:Initialize()
jb_primary_m4a1
end


Would work? It doesn’t look like it would.

C’mon man, stop getting spoon-fed, you post so many threads every day. Try and learn something yourself for once.

I am trying… This is why I am asking. I am asking to learn. I understand it looks like that, but I am trying as hard as I can. I spend hours just trying to get little things like this to work. I’m sorry if you think I expect people to do everything for me. Its just little things I get stuck on.

Ever heard of self-learning? Ever tried to google? We are not going to write the whole code for you. You gotta try to learn to do so yourself, try to look how other peoples code does this or that, try to look in gmods lua files.

I do search. I do self-learn. Its just things I’m trying to make that I have never seen in code.

You do search? How come you can’t even come up with a code to create an entity? It’s like search for ‘gmod create entity lua’ and the first result will give you the answer. What is wrong with you?

Jeez, just looked at the list of threads you have started Satoshi. There is no way you’re searching for answers whether it’s Google or other code. That’s 65 threads and 95% are lua questions.

I don’t know what this subforum would be without Noah, Snorlaxs, and yourself.

Forgot me :v:

-_-. Not everything I have done has come from things people have shown me on here.

-Snip-

I still can’t get this to work.

What gamemode are you using? Do these weapons need to be changed every round or only once?