Garry's Mod

Garry's Mod

[CW 2.0] Cases (Unofficial)
 이 토론은 고정되었습니다. 중요해서 그렇겠죠?
Kindred Flame  [개발자] 2016년 6월 28일 오후 7시 41분
Permissions and making your own CW 2.0 weapon case
Permissions:
To begin, use anything you want from this pack. However if you are using anything case model related please credit tigg for his modeling work on the cases. With regrades to the code, use whatever you like, you do not have to credit me but I will be happy if you do. I also ask you to not redistribute the base and rename taken models in order to avoid conflicts with this addon.

Making your own case:
The base that is included with this addon handles the client and server side tasks. In Order to make your own case you got to add a few pieces of information in the shared.lua. I will make a proper documentation of this, but this is basically the important things you need, this example is for the AR-15:

ENT.BodyGroupCoverMain = 1 -- the main bodygroup section that the cover bodygroup is located
ENT.BodyGroupOpenSet = 1 -- the open case cover bodygroup index
ENT.BodyGroupCloseSet = 0 -- the close case cover bodygroup index

ENT.WeaponUsed= "cw_ar15" -- name of the swep that the case is for

ENT.GunsNum = 2 -- number of guns in the case

Below are tables, each index on the table represents the number amount of the guns in the case for example wepBGGunsTableMain = {2,3,4,5}, this means that there are 4 guns in this case and for gun 1 its value is 2, for 2 it is 3, for 3 it is 4, and for 4 it is 5.

ENT.wepBGGunsTableMain = {2,3} -- the main bodygroup sections that the guns are
ENT.wepBGAmmoTableMain = {4,5} -- the main bodygroup sections that the magazines are

ENT.wepBGGunsTableStored = {0,0} -- the stored guns bodygroup indexs
ENT.wepBGAmmoTableStored = {0,0} -- the stored magazine bodygroup indexs

ENT.wepBGGunsTableGone = {1,1} -- the taken (gone) guns bodygroup indexs
ENT.wepBGAmmoTableGone = {1,1} -- the taken (gone) magazines bodygroup indexs

If your model does not have any bodygroups, then set all your values to zero.
Kindred Flame 님이 마지막으로 수정; 2022년 8월 12일 오후 2시 05분
< >
전체 댓글 9개 중 1~9개 표시 중
sрy 2016년 7월 1일 오전 3시 45분 
you can simplify a lot of this and reduce the amount of code necessary for people to write

ENT.WeaponUsed= "cw_ar15" -- name of the swep that the case is for
^ this variable already lets us know what weapon class it is, so you can just get it's data by doing:

local wepData = weapons.GetStored(self.WeaponUsed)

and then assign SwepName, AmmoUsed and AmmoAmountToGive like this:

self.SwepName = wepData.PrintName
self.AmmoUsed = wepData.Primary.Ammo
self.AmmoAmountToGive = wepData.Primary.ClipSize

you'd need to put this in a shared ENT:Initialize hook, the entire code snippet (which is pseudo-code, but it should work) would look like this:

ENT:Initialize()
-- do stuff that your cases do

local wepData = weapons.GetStored(self.WeaponUsed)

self.SwepName = wepData.PrintName
self.AmmoUsed = wepData.Primary.Ammo
self.AmmoAmountToGive = wepData.Primary.ClipSize
end

and bam, now you only have to enter 1 variable (instead of 4), and the rest would be handled for you

this way you'll reduce the amount of code needed to enter to just 1 variable, and it also means that if there are changes to the weapon code at any time in the base CW 2.0 pack or elsewhere (ie. weapon name change, mag size change, caliber change, etc.) you don't have to change anything at all in your case code
sрy 님이 마지막으로 수정; 2016년 7월 1일 오전 3시 49분
Kindred Flame  [개발자] 2016년 7월 1일 오전 11시 03분 
just 님이 먼저 게시:
you can simplify a lot of this and reduce the amount of code necessary for people to write

ENT.WeaponUsed= "cw_ar15" -- name of the swep that the case is for
^ this variable already lets us know what weapon class it is, so you can just get it's data by doing:

local wepData = weapons.GetStored(self.WeaponUsed)

and then assign SwepName, AmmoUsed and AmmoAmountToGive like this:

self.SwepName = wepData.PrintName
self.AmmoUsed = wepData.Primary.Ammo
self.AmmoAmountToGive = wepData.Primary.ClipSize

you'd need to put this in a shared ENT:Initialize hook, the entire code snippet (which is pseudo-code, but it should work) would look like this:

ENT:Initialize()
-- do stuff that your cases do

local wepData = weapons.GetStored(self.WeaponUsed)

self.SwepName = wepData.PrintName
self.AmmoUsed = wepData.Primary.Ammo
self.AmmoAmountToGive = wepData.Primary.ClipSize
end

and bam, now you only have to enter 1 variable (instead of 4), and the rest would be handled for you

this way you'll reduce the amount of code needed to enter to just 1 variable, and it also means that if there are changes to the weapon code at any time in the base CW 2.0 pack or elsewhere (ie. weapon name change, mag size change, caliber change, etc.) you don't have to change anything at all in your case code

This is perfect, thank you just, I will defenitly use this. I am still new to lua so I will accept all advice given, even to a professional such as yourself.
Mexican Bart Simpson 2016년 7월 5일 오후 11시 49분 
aye, is it possible to use my own case models?
Agent Orange Juice 2016년 7월 6일 오전 6시 28분 
Any ETA on when the new code will be implemented?
Kindred Flame  [개발자] 2016년 7월 7일 오전 7시 49분 
BridgeJumper3000 님이 먼저 게시:
Any ETA on when the new code will be implemented?

The new code is already implemented, go nuts.
Volcanic163 2016년 7월 13일 오후 12시 39분 
Hey Snow, can you make a special case that stores 1 of any weapon, WITH attachments, in it?
Ejou 2017년 10월 17일 오전 7시 15분 
Can this be used for making FAS 2.0 SWEPS?
GopnikCommissar 2021년 8월 15일 오후 5시 51분 
Hey, i modified your code so you can't pull from the case if the player already has one, removed all the code for body groups, removed all functionality for opening and closing the case and the variables self.hark; self.empty; self.open; self.fristTimeOpen, and the tables for the weapons in the case
i ask permission to upload this for use as an pseudo-shipment of sorts.
Kindred Flame  [개발자] 2021년 8월 15일 오후 7시 03분 
Sure thing, go right ahead. :steamthumbsup:
< >
전체 댓글 9개 중 1~9개 표시 중
페이지당 표시 개수: 1530 50