• one entity only *Help*
    5 replies, posted
Hello so iv gone and got some code from a thing i have downloaded but i whant to modify it so that i can only put "spawend_money" in it if you could help me out that would be great... here is the code soz its so long [lua] AddCSLuaFile( "cl_init.lua" ) // Make sure clientside AddCSLuaFile( "shared.lua" ) // and shared scripts are sent. include('shared.lua') --setting up function ENT:Initialize() util.PrecacheSound("common/wpn_hudoff.wav") util.PrecacheSound("items/ammo_pickup.wav") util.PrecacheSound("common/null.wav") self.Entity:SetModel( "models/props_c17/oildrum001.mdl") -- self.Entity:SetModel( "models/props_junk/metalgascan.mdl") self.Entity:PhysicsInit( SOLID_VPHYSICS ) // Make us work with physics, self.Entity:SetMoveType( MOVETYPE_VPHYSICS ) // after all, gmod is a physics self.Entity:SetSolid( SOLID_VPHYSICS ) // Toolbox local phys = self.Entity:GetPhysicsObject() if (phys:IsValid()) then phys:Wake() end self.max = 15 --max number of items per pack, fiddle with this all you like --don't touch any of this crap self.contains = {} self.used = false self.pickedup = false self.player = nil self.touched = false self.Entity:SetNetworkedInt( "number", 0 ) end --spawnit! function ENT:SpawnFunction( ply, tr ) if ( !tr.Hit ) then return end local SpawnPos = tr.HitPos + tr.HitNormal * 16 local ent = ents.Create( "sent_backpack" ) ent:SetPos( SpawnPos ) ent:Spawn() ent:Activate() return ent end --for getting things in and out of, currently you can do this while it's on someones back. Pickpocketing anyone? function ENT:Use(activator) if (!self.used) then local p = self.Entity:GetNetworkedInt( "number") if (p > 0) then p = p - 1 self.Entity:SetNetworkedInt( "number", p ) local ang = self.Entity:GetAngles() local SpawnPos = self.Entity:GetPos() + self.Entity:GetForward() * -20 SpawnPos.z = SpawnPos.z + 70 local ent = ents.Create( self.contains[1].class ) ent:SetModel(self.contains[1].model) ent:SetPos( SpawnPos ) ent:SetAngles(ang) ent:Spawn() ent:Activate() self.contains[1].tab.Entity = ent ent:SetTable(self.contains[1].tab) table.remove(self.contains,1) local phys = ent:GetPhysicsObject() if (phys:IsValid()) then phys:Wake() end self.used = true timer.Simple(0.3,unuse,self) end end end --stops use firing a million times function unuse(self) self.used = false end --Put things into it with the physics gun, or pick it up by walking into it function ENT:Touch(activator) if (!self.touched) then local p = self.Entity:GetNetworkedInt( "number") local r = activator:GetClass() if (activator:IsPlayerHolding( )) and (p < self.max) then local m = activator:GetModel() if (util.IsValidModel(m)) then local g = {} g.model = m g.tab = activator:GetTable() g.class = r table.insert(self.contains, g) activator:Remove() p = p + 1 self.Entity:SetNetworkedInt( "number", p ) self.touched = true timer.Simple(0.3,untouch,self) else --play error sound if the model doesn't work, it happens sometimes but this way we don't loose the prop or get an annoying error marker self.Entity:EmitSound( "common/null.wav", 500, 100 ) end elseif (p == self.max) then self.Entity:EmitSound( "common/null.wav", 500, 100 ) end if (activator:IsPlayer()) then local a = ents.FindByClass("sent_backpack") local found = false local n = nil for k,v in ipairs(a) do if (v.player == activator) then found = true end end if (!found) then --don't let the bastards have more than one pack self.Entity:SetOwner(activator) --self.Entity:GetPhysicsObject():EnableCollisions(false) local a = activator:GetAngles() local k = activator:GetAimVector() local f = k:Angle() f.p = a.p f.r = a.r local d = f:Forward() local r = activator:GetPos() r.z = r.z + 31 a.p = a.p + 8 r = r + d * -13 self.Entity:SetPos(r) self.Entity:SetAngles(a) self.Entity:SetGravity(0) self.Entity:SetParent(activator) self.player = activator self.pickedup = true self.Entity:EmitSound( "items/ammo_pickup.wav", 500, 100 ) else self.Entity:EmitSound( "common/null.wav", 500, 100 ) end self.touched = true timer.Simple(0.3,untouch,self) end end end --stops the damn touch function firing a million times function untouch(self) self.touched = false end --if the fool's dead or disconnected have him drop it. Or he can drop it on his own by crouching --From what I can work out, disconnecting destroys the pack and anything inside it :/ function ENT:Think() if (self.pickedup) then if (self.player:KeyDown(IN_DUCK) ) or (!self.player:Alive()) then self.Entity:SetOwner() self.Entity:SetGravity(1) self.Entity:SetParent() -- self.Entity:GetPhysicsObject():EnableCollisions(true) local a = self.player:GetAngles() local d = self.player:GetForward() local r = self.player:GetPos() r.z = r.z + 20 r = r + d * -50 self.Entity:SetPos(r) self.Entity:SetAngles(a) self.pickedup = false self.player = nil self.used = true timer.Simple(0.3,unuse,self) self.touched = true timer.Simple(0.3,untouch,self) self.Entity:GetPhysicsObject():Wake() self.Entity:EmitSound( "common/wpn_hudoff.wav", 500, 100 ) end end end [/lua] Edit: thx for that i forgot to put that Edit: i think this is the part of code that needs changeing but meh what do i know ... lol [lua] --Put things into it with the physics gun, or pick it up by walking into it function ENT:Touch(activator) if (!self.touched) then local p = self.Entity:GetNetworkedInt( "number") local r = activator:GetClass() if (activator:IsPlayerHolding( )) and (p < self.max) then local m = activator:GetModel() if (util.IsValidModel(m)) then local g = {} g.model = m g.tab = activator:GetTable() g.class = r table.insert(self.contains, g) activator:Remove() p = p + 1 self.Entity:SetNetworkedInt( "number", p ) self.touched = true timer.Simple(0.3,untouch,self) else [/lua] Edit: ok so this is the line i think that i need to add there [lua] if (m = "spawend_money") then g.model = m else return "" end [/lua]
Use lua tags so, [lua]Code Here[ /lua] without the space.
[lua] if r != "spawend_money" then return end [/lua]
That dident help at all now i carnt evan get that in there ...... Maby iv got rong thing but i used the spawend_money (from DarkRp) and also the model of the spawend money and it dident work so if someone could help that would be great
son, you have a spelling mistake. its spawned_money
[QUOTE=raklatif;34709542]son, you have a spelling mistake. its spawned_money[/QUOTE] *Checks post date* [quote]29th June 2010[/quote] *Checks current date* [quote]15th February 2012[/quote] Hm...
Sorry, you need to Log In to post a reply to this thread.