Jump to content

Use to pick up weapons?


hippokittie
 Share

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?

  • Upvote 3

Will Hall

Morphodox Studios

Link to comment
Share on other sites

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.

Asus sabertooth 990FX, AMD FX 9590 , Windows 7 Home Premium 64 Bit, 4 HDD's Western Digital Caviar Black set in Raid 0, 16 GB Crucial Ballistix Elite, Asus Radeon R9 270 X 4GB, Corsair CM750M,

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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.

 Share

×
×
  • Create New...