View unanswered posts | View active topics It is currently Sat Apr 27, 2024 8:09 am



Reply to topic  [ 4 posts ] 
 One shot .lua help. 
Author Message

Joined: Mon Dec 07, 2009 12:56 am
Posts: 36
Reply with quote
Post One shot .lua help.
Hey guys I'm using this script to make a gun gib after it runs out of ammo. It works if I'm the one directly controlling the actor. But if he is using the gun autonomously it just reloads like normal. Would appreciate advice on how to solve this. Thanks in advance :)

Code:
function Create(self)
end

function Update(self)
   if ToMagazine(self.Magazine).RoundCount == 0 then
      self:GibThis()
   end
end


Wed Jan 04, 2012 10:03 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: One shot .lua help.
Code:
function Create(self)
end

function Update(self)
   if ToMagazine(self.Magazine) == nil then
      self:GibThis()
   end
end


My guess is that the AI auto-reloads it, so it doesn't reach 0 ammo. Instead, you should check if the magazine still exists, and if it doesn't it gibs.

I'm not sure if the code will work though, I tend to have problems with magazines.


Last edited by Asklar on Wed Jan 04, 2012 10:19 pm, edited 1 time in total.



Wed Jan 04, 2012 10:09 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post Re: One shot .lua help.
Try:
Code:
function Create(self)
end

function Update(self)
   if self.Magazine == nil or ToMagazine(self.Magazine).RoundCount == 0 then
      self:GibThis()
   end
end


Wed Jan 04, 2012 10:18 pm
Profile

Joined: Mon Dec 07, 2009 12:56 am
Posts: 36
Reply with quote
Post Re: One shot .lua help.
CaveCricket48 wrote:
Try:
Code:
function Create(self)
end

function Update(self)
   if self.Magazine == nil or ToMagazine(self.Magazine).RoundCount == 0 then
      self:GibThis()
   end
end


That works perfect. Thanks 8)


Thu Jan 05, 2012 5:40 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.206s | 15 Queries | GZIP : Off ]