Jump to content
hippokittie

Use to pick up weapons?

Recommended Posts

So I have a weapon pick up code (from Piller's youtube video). Now I like it, think it works alright; but I want to know if there is a way to edit it for "if used" but have no clue how that would work. I am not the strongest programmer. Also would it remove the currently equipped weapon? Like "if weapon == true, drop weapon.pickup"(weapon.pick up to drop the currently carried weapon and spawn a pick up identified in the weapons code infront of the player). It may be to much to ask just seeing if it is possible. I have other programming questions but will just try this for now (as it is very important). Thanks all and here is the code that I currently have.

Script.vwepfile=""--path "VWep" "Prefab (*pfb):pfb|Prefabs"
--Script.vwep=nil--entity
function Script:Start()
if self.vwepfile~="" then
local prefab = Prefab:Load(self.vwepfile)
if prefab~=nil then
if prefab.script~=nil then
self.vwep = prefab.script
else
prefab:Release()
end
end
end
end
function Script:Use(player)
if self.vwep then
if type(player.AddWeapon)=="function" then
if player.weapons~=nil then
if player.weapons[self.index]==nil then
 player:AddWeapon(self.vwep)
 self.entity:Hide()
end
end
end
end
end
function Script:Collision(entity, position, normal, speed)
if self.vwep then
if entity.script~=nil then self:Use(entity.script) end
end
end

 

Edit# the build in pick up code works kinda but if you already have a weapon then it wont let me switch to the pick-ed up weapon. So maybe just an edit to that to fix that? Like having an inventory or something?

Share this post


Link to post

This would be useful and especially if one could carry 2 weapons. primary and secondary weapon and if another weapon is picked up, the other of that "class" would be removed. carrying an entire armory just isnt feasible.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...