Jump to content

weapon pick up script


Imchasinyou
 Share

Recommended Posts

Rick, ive tried this over and over. Im not seeing my error.

 

Ive followed you line by line. The box disappears but im not getting the weapon prefab set in the vmodel.

 

If you have a minute to look over the scripts and see if you see my issue, Id appreciate it greatly. The tutorials are great for us noob non coders.

 

I have included the FPSPlayer, FPSWeapon, FPSGun and the Pick up script in my drop box to reduce the clutter here in the forums.

 

https://www.dropbox.com/sh/6woj1ju95d95gxl/AACXJ2Kdfbw2B_WOnx_Z433oa?dl=0

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

Your LoadWeapon function:

function Script:LoadWeapon()
   --Load the default weapon, if one is set
   if self.weaponfile=="" then
       local entity = Prefab:Load (self.weaponfile)
       if entity ~=nil then
           System:Print("weapon file loaded")
           if entity.script~=nil then
               entity.script:Start()
               entity.script.player = self
               self.weapon = entity.script
               self.weapon.entity:SetParent(self.camera)
               self.weapon.entity:SetRotation(0,0,0)
               if self.weapon.offset~=nil then
                   self.weapon.entity:SetPoint(self.weapon.offset)
               else
                   self.weapon.entity:SetPosition(0,0,0)
               end
           end
       end
   end
end

The second line is:

if self.weaponfile=="" then

Shouldn't it be ~= instead of ==?

Also, I suggest you making it like this:

if self.weaponfile=="" then return end

This will stop the function if wapon file path is empty.

Link to comment
Share on other sites

Ill have to look at the tutorial again to see if that is what was used. Maybe I didnt see it.

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

I did find tyhat but didnt make any differance. Would it matter that i do not actually use a camera, I use the prefab player.

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

My output screen is all greyed out. If you are referring to the window that opens when you run the game with the actual window created by the game

 

Id be happy to teamview this to find the error if your interested. You can add me on steam by searchign Gen - Imchasinyou

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

getting better, i atleast have a small bit of lag as if its trying to load something with that change

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

something has occurred to me. I have seperate weapon scripts for each of my weapons. So, Im wondering if that has anythignt odo with my issues and if it does, Ill feel totally retarded!

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

Once upon a time, I had that very same window. I havnt seen it in some time. Ill see if its something I can find/fix

 

Managed to get that back. . . . . Lemme see if I can find what you mentioned above

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

Loading component "C:/Users/Andrew/Documents/Leadwerks/Projects/Zombies/scripts/objects/triggers/weaponpickup.lua..."

Executing file "C:/Users/Andrew/Documents/Leadwerks/Projects/Zombies/scripts/objects/triggers/weaponpickup.lua"

Loading component "C:/Users/Andrew/Documents/Leadwerks/Projects/Zombies/scripts/objects/player/fpsplayer.lua..."

Executing file "C:/Users/Andrew/Documents/Leadwerks/Projects/Zombies/scripts/objects/player/fpsplayer.lua"

 

Something like that? Im going to make a quick map, import the scripts over and see if anything changes from this level to a fresh level

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

Same results here too. Here is the consoles log.

Executing "C:\Users\Andrew\Documents\Leadwerks\Projects\GunTutorial\GunTutorial.exe"...
Initializing Lua...
Lua sandboxing enabled.
Executing file "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Scripts/Error.lua"
Executing file "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Scripts/App.lua"
Initializing OpenGL4 graphics driver...
OpenGL version 431
GLSL version 430
Device: ASUS R9 270X Series
Loading map "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Maps/start.map"...
Loading material "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/materials/developer/bluegrid.mat"...
Loading texture "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/materials/developer/BlueGrid.tex"...
Loading shader "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Shaders/Model/diffuse.shader"...
Loading texture "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Materials/Common/bfn.tex"...
Loading component "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/scripts/objects/player/fpsplayer.lua..."
Executing file "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/scripts/objects/player/fpsplayer.lua"
Executing file "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Scripts/Functions/ReleaseTableObjects.lua"
Loading component "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/scripts/objects/triggers/weaponpickup.lua..."
Executing file "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/scripts/objects/triggers/weaponpickup.lua"
Loading shader "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Shaders/Terrain/stamp.shader"...
Loading shader "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Shaders/Terrain/updatenormals.shader"...
Loading shader "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Shaders/Terrain/clear.shader"...
Loading shader "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Shaders/Terrain/clipmap.shader"...
Loading shader "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Shaders/Terrain/terrain.shader"...
Loading texture "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/materials/nature/terrain_savannah_dirt.tex"...
Loading texture "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Materials/HUD/crosshair.tex"...
Loading texture "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Materials/HUD/use.tex"...
Loading texture "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Materials/HUD/blood1.tex"...
Loading texture "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Materials/HUD/blood2.tex"...
Loading texture "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Materials/HUD/blood3.tex"...
Loading texture "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Materials/HUD/blood4.tex"...
Loading sound "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Sound/Player/flashlight_02_on.wav..."
Loading sound "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Sound/Impact/body_punch_03.wav..."
Loading sound "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Sound/Impact/body_punch_04.wav..."
Loading sound "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Sound/Player/pickupammo.wav..."
Loading sound "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Sound/Footsteps/Concrete/step1.wav..."
Loading sound "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Sound/Footsteps/Concrete/step2.wav..."
Loading sound "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Sound/Footsteps/Concrete/step3.wav..."
Loading sound "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Sound/Footsteps/Concrete/step4.wav..."
Loading sound "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Sound/Footsteps/Concrete/jump.wav..."
weapon file =
Loading shader "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Shaders/Model/default.shader"...
Loading shader "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Shaders/Misc/occlusionquery.shader"...
Loading shader "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Shaders/Lighting/ambientlight.shader"...
Loading prefab "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Prefabs/Weapons/PPSH.pfb"...
Loading model "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/models/weapons/ppsh/ppsh.mdl"
Loading material "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/models/weapons/ppsh/ppsh.mat"...
Loading shader "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Shaders/Model/Animated/diffuse+normal.shader"...
Loading shader "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Shaders/Model/Shadow/shadow+animation.shader"...
Loading texture "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/models/weapons/ppsh/ppsh.tex"...
Loading texture "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/models/weapons/ppsh/ppsh_dot3.tex"...
Loading component "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/scripts/objects/weapons/ppsh.lua..."
Executing file "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/scripts/objects/weapons/ppsh.lua"
Executing file "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Scripts/AnimationManager.lua"
Loading sound "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Sound/Ricochet/bullet_impact_dirt_01.wav..."
Loading sound "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Sound/Ricochet/bullet_impact_dirt_02.wav..."
Loading sound "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Sound/Ricochet/bullet_impact_dirt_03.wav..."
Loading material "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Materials/Effects/tracer.mat"...
Loading texture "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Materials/Effects/tracer.tex"...
Loading sound "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Sound/Weapons/Autopistol/revolver_dry_fire_01.wav..."
Loading sound "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Sound/Weapons/Autopistol/gun_357mag_01.wav..."
Loading sound "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Sound/Weapons/Autopistol/gun_357mag_02.wav..."
Loading sound "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Sound/Weapons/Autopistol/gun_357mag_05.wav..."
Loading sound "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Sound/Weapons/Autopistol/bullet_load_into_chamber_02.wav..."
Loading material "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Materials/Effects/muzzleflash.mat"...
Loading shader "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/shaders/model/flat/diffuse.shader"...
Loading texture "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Materials/Effects/muzzleflash.tex"...
Loading material "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Materials/Effects/default.mat"...
Loading shader "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/shaders/particles/default.shader"...
Loading texture "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Materials/Effects/default.tex"...
Loading material "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Materials/Effects/smoke.mat"...
Loading texture "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Materials/Effects/smoke_particle.tex"...
Loading material "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Materials/Effects/bloodspatter.mat"...
Loading texture "C:/Users/Andrew/Documents/Leadwerks/Projects/GunTutorial/Materials/Effects/bloodspatter.tex"...
weapon file loaded
Setting breakpad minidump AppID = 251810
Steam_SetMinidumpSteamID:  Caching Steam ID:  76561198039260066 [API loaded no]
Process Complete.

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

Tried that, if this is what you meant.

function Script:LoadWeapon()
--Load the default weapon, if one is set
if self.weaponfile~="" then
 local entity = Prefab:Load(self.weaponfile)
 if entity~=nil then
  System:Print("weapon file loaded")
  if entity.script~=nil then
   entity.script:Start()
   entity.script.player = self
   self.weapon = entity.script
   self.weapon.entity:SetParent(self.camera)
   self.weapon.entity:SetRotation(0,0,0)
   self.weapon.entity:SetPosition(0,0,100)
   end
  end
 end
end

 

That didnt work. Its just not loading that prefab weapon. Its like it knows it needs to but cant find it or something.

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

Are you sure you have correct file path and correct prefab? "weapon file loaded" shows and it means something is loaded. If you want to use teamviewer ask Rick or someone else, I can't help you with that, sorry.

Or send me the whole project dirrectory and I'll look into it tomorrow.

Link to comment
Share on other sites

Im going to export this map and post it to my drop box. If you dot mind, take a look at it and see if everything is there.

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

https://www.dropbox.com/sh/0dvu1s6yuwhbnnl/AAC5HHuFpB7s58oXq-Tycjgda?dl=0

 

This contains my empty map with the weapon pick up script if any one is so inclined to have a peek to see why it wont work.

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

Ok, so you were using Rick's weapon loading mechanism with with weapons that already have this mechanism programmed. In the end of the start function of FPSPlayer script you have these lines:

if self.weaponfile~="" then
		 local prefab = Prefab:Load(self.weaponfile)
		 if prefab~=nil then
				 if prefab.script~=nil then
						 self:AddWeapon(prefab.script)
				 else
						 prefab:Release()
				 end
		 end
 end

This is how loading of these weapons work (they have everything else in their start function). And this is what your LoadWeapon function should be. So I simply commented out your LoadWeapon function and added new one with this code. And I have commented out this code from player start function so the weapon won't be loaded at start twice.

Here is the link to modified FPSPlayer.lua: http://pastebin.com/UNyPvtim

Link to comment
Share on other sites

This works perfectly. Now can the player carry 2 weapons and choose between them or is that a seperate function? man I need a dedicated scripter to help me :/. . . .

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

The FPS weapons pack has examples of this. Due out very very soon.

 

Come on! Stop teasing me and just give it up already.

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

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...