Old 08-14-2008   #1 (permalink)
Member
 
willthemage's Avatar
 

Join Date: Jun 2008
Location: Cassadaga, New York
Posts: 81
willthemage is an unknown quantity at this point
Post Ammo Remover

Well the last 2 weeks I been working in lua and I need help figure out how to use util codes so been working on this Ranger thing. When a player hits the beam they lose all of there ammo I wondering if I did it right. Don't worry about the input Clk because I want to know if I use util right.

AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( "shared.lua" )

ENT.WireDebugName = "Ammo Remover"

function Ammo Remover() --this just makes sure everything runs

function ENT:Initialize --sets up Entity (Phys,Inputs)

self.Entity:PhysicsInit( SOLID_VPHYSCIS )
self.Entity:SetMoveType( MOVETYPE_VPHYSCIS )
self.Entity:SetSolid( SOLID_VPHYSCIS )

local phys = self.Entity:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
end

self.Inputs = Wire_CreateInputs(self.Entity, { "Clk", "BeamLenght"})

end

function ENTraw() -- makes beam
local pos = self.Entity:GetShootPos()
local ang = self.Entity:GetAimVector()
local tracedata = {}
tracedata.start = pos
tracedata.endpos = pos+ (ang*BeamLenght)
tracedata.filter = self.Owner
local trace = util.TraceLine(tracedata)
if trace.HitNonWorld then
target = trace.Entity
if Entity:IsPlayer(trace.Entity) then
Player:RemoveAllAmmo(trace.Entity)
end
end
end

For some reason its saying function ENT:raw() but its ENT: Draw and I did use spacing but it doesn't show
__________________
92% of teens have moved onto rap. If you are part of the 8% that still listen to real music, copy and paste this into your signature.
98% of teens smoke, or have smoked before in their life. If you are part of the 2% that hasn't/doesn't, copy this into your sig.

[url=http://ubanimator.com][img]http://img98.imageshack.us/img98/9400/userbar668015aq1.gif[/img][/url]

Last edited by willthemage; 08-14-2008 at 04:02 PM..
willthemage is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Old 08-14-2008   #2 (permalink)
UWSVN Contributor
 
Hitman271's Avatar
 

Join Date: Feb 2008
Location: Alabama, USA
Posts: 385
Hitman271 is on a distinguished road
Send a message via Yahoo to Hitman271
Default Re: Ammo Remover

Code:
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( "shared.lua" )

ENT.WireDebugName = "Ammo Remover"

function Ammo_Remover() --this just makes sure everything runs
end

function ENT:Initialize() 
                self.Entity:SetModel( "models/props_c17/oildrum001.mdl" ) 	
	self.Entity:PhysicsInit( SOLID_VPHYSICS )
	self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
	self.Entity:SetSolid( SOLID_VPHYSICS )

	local phys = self.Entity:GetPhysicsObject()
	if (phys:IsValid()) then
		phys:Wake()
	end

	self.Inputs = Wire_CreateInputs(self.Entity, { "Clk", "BeamLength"})

end

 function ENT:Draw()  //Put this clientside 
	local pos = self.Entity:GetShootPos()
	local ang = self.Entity:GetAimVector()
	local tracedata = {}
	tracedata.start = pos
	tracedata.endpos = pos+ (ang*BeamLenght)
	tracedata.filter = self.Owner
	local trace = util.TraceLine(tracedata)
	 if trace.HitNonWorld then
	     target = trace.Entity
		 if target:IsPlayer then
			 target:RemoveAllAmmo()
		 end
	 end
end
For one you had numerous spelling errors which would stop you prematurely. Second, ENTraw is clientside so put that in the client file. I also corrected the spelling errors as well.
Also remember to put code tags for easier reading and put the function marks () after every functions.
__________________
Quote:
Originally Posted by Anticept View Post
It is not some place where you can toss your dick around and expect people to suck it.
Quote:
Originally Posted by Black Phoenix on Fixing the Gpu
When I get laid
READ AND GET SEXAH PRONZ OR DONT AN GET BANNED

IF ALL ELSE FAILS THEN READ THIS BEFORE MAKING A HELP THREAD

Remember to ask me for cpu help if you need it, just pm me with your situation and/or problem code

Last edited by Hitman271; 08-14-2008 at 07:39 PM..
Hitman271 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-14-2008   #3 (permalink)
Member
 
willthemage's Avatar
 

Join Date: Jun 2008
Location: Cassadaga, New York
Posts: 81
willthemage is an unknown quantity at this point
Default Re: Ammo Remover

thz and yes I suck at grammer and spelling
__________________
92% of teens have moved onto rap. If you are part of the 8% that still listen to real music, copy and paste this into your signature.
98% of teens smoke, or have smoked before in their life. If you are part of the 2% that hasn't/doesn't, copy this into your sig.

[url=http://ubanimator.com][img]http://img98.imageshack.us/img98/9400/userbar668015aq1.gif[/img][/url]
willthemage is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-14-2008   #4 (permalink)
Advanced Member
 
itsbth's Avatar
 

Join Date: Feb 2007
Location: Norway
Posts: 280
itsbth is on a distinguished road
Send a message via MSN to itsbth
Default Re: Ammo Remover

You are trying to remove ammo (which is server-side) in the draw hook (which is client-side)... The draw loop is for... guess what, drawing the entity. Everything else should be in the think hook.
__________________
Wire developer. Currently working at: Topaz (A scripting language written in Lua)
<Fox682> itsbot: follow the white rabbit
<ITSBOT> i don't want to follow that.
itsbth is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-14-2008   #5 (permalink)
Member
 
willthemage's Avatar
 

Join Date: Jun 2008
Location: Cassadaga, New York
Posts: 81
willthemage is an unknown quantity at this point
Default Re: Ammo Remover

k I'm a Lua noob so WTF is server and client and why is it so important to have them serapted
__________________
92% of teens have moved onto rap. If you are part of the 8% that still listen to real music, copy and paste this into your signature.
98% of teens smoke, or have smoked before in their life. If you are part of the 2% that hasn't/doesn't, copy this into your sig.

[url=http://ubanimator.com][img]http://img98.imageshack.us/img98/9400/userbar668015aq1.gif[/img][/url]
willthemage is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-15-2008   #6 (permalink)
Advanced Member
 
moogle_man's Avatar
 

Join Date: Jul 2008
Location: Gumdrop LN, Candy Land
Posts: 141
moogle_man is on a distinguished road
Default Re: Ammo Remover

Lolz, it would be alot easier to just use the anti-noclip tool and set it to strip weapons, then do some coding to force noclip them through it, but hey, you got it working so it doesn't matter now.
__________________
92% of teens have moved onto rap. If you are part of the 8% that still listen to real music, copy and paste this into your signature.
My IQ is 153 - Free-IQTest.net - Free IQ Test
moogle_man- He keeps the USA running! The clever way...
moogle_man is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-15-2008   #7 (permalink)
<3

 
IEF015's Avatar
 

Join Date: Feb 2008
Location: London, ON (Canada, eh?)
Posts: 765
IEF015 has a spectacular aura aboutIEF015 has a spectacular aura about
Default Re: Ammo Remover

I'll keep this simple:
Client-side means that only one person (usually the owner) will notice things. (IE: Derma GUI)
Server-side means that everyone in a server will be able to notice (IE: Fire)
__________________
Signature:
WIREMOD WILL NOT WORK ON A PIRATED GMOD!


MY COLOUR IS BLUE.
Post your expressions here: www.wiredexpressions.tk
It's my favourite country song. And I hate it.
IEF015's got his own website :3
IEF015 is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-15-2008   #8 (permalink)
Member
 
willthemage's Avatar
 

Join Date: Jun 2008
Location: Cassadaga, New York
Posts: 81
willthemage is an unknown quantity at this point
Post Re: Ammo Remover

thz guys

Quote:
Originally Posted by moogle_man View Post
Lolz, it would be alot easier to just use the anti-noclip tool and set it to strip weapons, then do some coding to force noclip them through it, but hey, you got it working so it doesn't matter now.
Well I'm not going to use it I'm just working on my lua skills
__________________
92% of teens have moved onto rap. If you are part of the 8% that still listen to real music, copy and paste this into your signature.
98% of teens smoke, or have smoked before in their life. If you are part of the 2% that hasn't/doesn't, copy this into your sig.

[url=http://ubanimator.com][img]http://img98.imageshack.us/img98/9400/userbar668015aq1.gif[/img][/url]

Last edited by willthemage; 08-15-2008 at 07:10 PM..
willthemage is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -7. The time now is 12:02 AM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.

Page top