|
| | #1 (permalink) |
| Member ![]() Join Date: Jun 2008 Location: Cassadaga, New York
Posts: 81
![]() | 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 ENT raw() -- makes beamlocal 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.. |
| | |
| Sponsored Links | |
| | #2 (permalink) | ||
| UWSVN Contributor ![]() | 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
raw 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:
Quote:
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.. | ||
| | |
| | #3 (permalink) |
| Member ![]() Join Date: Jun 2008 Location: Cassadaga, New York
Posts: 81
![]() | 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] |
| | |
| | #4 (permalink) |
| Advanced Member ![]() | 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. |
| | |
| | #5 (permalink) |
| Member ![]() Join Date: Jun 2008 Location: Cassadaga, New York
Posts: 81
![]() | 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] |
| | |
| | #6 (permalink) |
| Advanced Member ![]() Join Date: Jul 2008 Location: Gumdrop LN, Candy Land
Posts: 141
![]() | 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... |
| | |
| | #7 (permalink) |
| <3 ![]() ![]() Join Date: Feb 2008 Location: London, ON (Canada, eh?)
Posts: 765
![]() ![]() | 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 |
| | |
| | #8 (permalink) |
| Member ![]() Join Date: Jun 2008 Location: Cassadaga, New York
Posts: 81
![]() | thz guys 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.. |
| | |
| Sponsored Links | |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|