So, how would I go about doing this?
I know I need to change the default weapons' code by going to sh_weaponsettings.lua, however, I can't seem to find out how to change functions in that file. Could someone please help me?
[url]http://lmgtfy.com/?q=darkrp+default+weapons[/url]
(Second link. Scroll down the page, or search for "default")
[QUOTE=feldma;50185275][url]http://lmgtfy.com/?q=darkrp+default+weapons[/url]
(Second link. Scroll down the page, or search for "default")[/QUOTE]
This is something totally different from what I'm asking.
[quote]change the default weapons[/quote]
[lua]
-- The list of weapons people spawn with.
GM.Config.DefaultWeapons = {
"keys",
"weapon_physcannon",
"gmod_camera",
"gmod_tool",
"pocket",
"weapon_physgun",
}[/lua]
Isn't that what you're asking for?
[QUOTE=feldma;50185296][lua]
-- The list of weapons people spawn with.
GM.Config.DefaultWeapons = {
"keys",
"weapon_physcannon",
"gmod_camera",
"gmod_tool",
"pocket",
"weapon_physgun",
}[/lua]
Isn't that what you're asking for?[/QUOTE]
there we go, sorry. I clarified what I'm looking for in the OP
I don't see any changes?
then [quote]change the default weapons[/quote]
now [quote]change the default weapons' code[/quote]
Ah.
Right.
What would you be trying to change? I'll give you an example.
[QUOTE=feldma;50185475]Ah.
Right.
What would you be trying to change? I'll give you an example.[/QUOTE]
the swep:initialize() function
I mean, what part of the weapon are you trying to change.
Damage? Name? Description?
[QUOTE=feldma;50185520]I mean, what part of the weapon are you trying to change.
Damage? Name? Description?[/QUOTE]
the function... swep:initialize()
What do you mean by the function SWEP:Initialize()
That's built in. Are you trying to edit what happens inside of the Initialize?
[QUOTE=feldma;50185667]What do you mean by the function SWEP:Initialize()
That's built in. Are you trying to edit what happens inside of the Initialize?[/QUOTE]
Yes
What weapon / tool, exactly, are you trying to change?
stick_base
Okay, what specific part of that weapon are you trying to change? Not the function, the actual thing.
E.g Damage.
[QUOTE=feldma;50189319]Okay, what specific part of that weapon are you trying to change? Not the function, the actual thing.
E.g Damage.[/QUOTE]
You are very confused.
You're trying to change a function?
What are you actually trying to change about it?
[QUOTE=feldma;50190755]You're trying to change a function?
What are you actually trying to change about it?[/QUOTE]
I'm trying to delete contents of the function.
Reading your comments makes me sick.
[code]
function SWEP:Initialize()
self:SetHoldType("normal")
if SERVER then return end
CreateMaterial("darkrp/" .. self:GetClass(), "VertexLitGeneric", {
["$basetexture"] = "models/debug/debugwhite",
["$surfaceprop"] = "metal",
["$envmap"] = "env_cubemap",
["$envmaptint"] = "[ .5 .5 .5 ]",
["$selfillum"] = 0,
["$model"] = 1
}):SetVector("$color2", self.StickColor:ToVector())
end
[/code]
This is the SWEP:Initialize() function inside of stick_base, what exactly do you want to change here?
*took me 5 seconds to find it*
[QUOTE=Invule;50190909]Reading your comments makes me sick.
[code]
function SWEP:Initialize()
self:SetHoldType("normal")
if SERVER then return end
CreateMaterial("darkrp/" .. self:GetClass(), "VertexLitGeneric", {
["$basetexture"] = "models/debug/debugwhite",
["$surfaceprop"] = "metal",
["$envmap"] = "env_cubemap",
["$envmaptint"] = "[ .5 .5 .5 ]",
["$selfillum"] = 0,
["$model"] = 1
}):SetVector("$color2", self.StickColor:ToVector())
end
[/code]
This is the SWEP:Initialize() function inside of stick_base, what exactly do you want to change here?
*took me 5 seconds to find it*[/QUOTE]
Why does it even matter? I'm trying to find out how to edit the function?
Also - no shit, it's easy to find. If I didn't know where this was I wouldn't be asking how to edit it's contents, now would I?
Because you asked for an example. Since there is already an example on the lua file, we are unsure as to what you are actually asking.
Lets say you wanted to change the damage of the stunstick, you would do:
[code]weapon "stunstick".PrintName = "Bash baton"[/code]
This came straight out of the lua file. I don't know what you are trying to do to stick_base, but I personally wouldn't recommend changing that since it is evidently a base file.
[QUOTE=feldma;50191130]Because you asked for an example. Since there is already an example on the lua file, we are unsure as to what you are actually asking.
Lets say you wanted to change the damage of the stunstick, you would do:
[code]weapon "stunstick".PrintName = "Bash baton"[/code]
This came straight out of the lua file. I don't know what you are trying to do to stick_base, but I personally wouldn't recommend changing that since it is evidently a base file.[/QUOTE]
I understand, however, you are able to change functions through the addon.
I understand how to edit the basic SWEP variables. However, I want to edit a function.
Take a look here - "Technically you can set any field of the weapon. Advanced users can even override e.g. PrimaryAttack with this." - Straight from the file's comment.
Okay, so give an example of what you would want to change.
I've never technically changed an entire function. Perhaps:
[code]
weapon stunstick.PrimaryAttack = code() code () code () [/code]
[QUOTE=feldma;50191155]Okay, so give an example of what you would want to change.
I've never technically changed an entire function. Perhaps:
[code]
weapon stunstick.PrimaryAttack = code() code () code () [/code][/QUOTE]
[code]
weapon "stick_base".Initialize = function SWEP:Initialize()
self:SetHoldType("normal")
if SERVER then return end
-- I'd like to comment out all of this:
CreateMaterial("darkrp/" .. self:GetClass(), "VertexLitGeneric", {
["$basetexture"] = "models/debug/debugwhite",
["$surfaceprop"] = "metal",
["$envmap"] = "env_cubemap",
["$envmaptint"] = "[ .5 .5 .5 ]",
["$selfillum"] = 0,
["$model"] = 1
}):SetVector("$color2", self.StickColor:ToVector())
-- And end the comment here
end
[/code]
Something of that sort, is what I'm looking for
Try
[CODE]
weapon "stick_base".Initialize = function( self )
self:SetHoldType("normal")
if SERVER then return end
end
[/CODE]
[QUOTE=MPan1;50191182]Try
[CODE]
weapon "stick_base".Initialize = function( self )
self:SetHoldType("normal")
if SERVER then return end
end
[/CODE][/QUOTE]
This is amazing. MPan1, you're the man, bro!
-- if SERVER then return end is redundant at this point
final code -
weapon "stick_base".Initialize = function(self) self:SetHoldType("normal") end
[QUOTE=Percipience;50191141]I understand, however, you are able to change functions through the addon.
I understand how to edit the basic SWEP variables. However, I want to edit a function.
Take a look here - "Technically you can set any field of the weapon. Advanced users can even override e.g. PrimaryAttack with this." - Straight from the file's comment.[/QUOTE]
You haven't really done a good job of explaining what you want, If Im understanding this thread correctly you want a way to edit a weapons function without changing weapons actual file. My first idea would be to just copy the weapons file and change the name, that way you wont overwrite your changes when you update DarkRP. This would work pretty good considering most DarkRP weapons hardly ever get updated [url]https://github.com/FPtje/DarkRP/tree/master/entities/weapons[/url] . The other way and the way I think you are looking for uses this function to get the weapon table [url]https://wiki.garrysmod.com/page/weapons/GetStored[/url] . Once you have that you can overwrite anything you want on the weapon.
[code]
MyWeaponBullshit.Initialize = function(self) --some more bullshit end
--or probably? Like this
function MyWeaponBullshit:Initialize()
-- even more bullshit here
end
[/code]
Edit
Some beat me to it
[QUOTE=TheEmp;50191207]You haven't really done a good job of explaining what you want, If Im understanding this thread correctly you want a way to edit a weapons function without changing weapons actual file. My first idea would be to just copy the weapons file and change the name, that way you wont overwrite your changes when you update DarkRP. This would work pretty good considering most DarkRP weapons hardly ever get updated [url]https://github.com/FPtje/DarkRP/tree/master/entities/weapons[/url] . The other way and the way I think you are looking for uses this function to get the weapon table [url]https://wiki.garrysmod.com/page/weapons/GetStored[/url] . Once you have that you can overwrite anything you want on the weapon.
[code]
MyWeaponBullshit.Initialize = function(self) --some more bullshit end
--or probably? Like this
function MyWeaponBullshit:Initialize()
-- even more bullshit here
end
[/code]
Edit
Some beat me to it[/QUOTE]
Ninja'd - lol
But none-the-less, thanks bro!
Sorry, you need to Log In to post a reply to this thread.