Works from what i tried from TB, i even changed it to give ammo, still works, so i have no clue what your doing wrong.
In garrysmod\garrysmod\lua\entities Make a folder called body_armor, and in that folder make 3 lua files cl_init, init, and shared.
They should look somewhat like this.
cl_init.lua
[code]
ENT.Spawnable = true
ENT.AdminSpawnable = true
include('shared.lua')
function ENT:Initialize()
end
function ENT:Draw()
self.Entity:DrawModel()
end
[/code]
init.lua
[code]
function ENT:SpawnFunction( ply, tr )
if ( !tr.Hit ) then return end
local SpawnPos = tr.HitPos + tr.HitNormal * 16
local ent = ents.Create( "body_armor" )
ply:SetHealth(200)
ent:EmitSound("items/smallmedkit1.wav", 100, 100)
ent:Spawn()
return ent
end
function ENT:Initialize()
self.Entity:SetModel( "models/Items/hevsuit.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.Entity:Remove()
end
[/code]
shared.lua
[code]
ENT.Base = "base_anim"
ENT.Type = "anim"
ENT.PrintName = "Body Armor"
ENT.Author = "Unknown"
ENT.Spawnable = true
ENT.AdminSpawnable = true
[/code]
I don't know how you can go wrong now. If it still doesn't work paste the console here.
A cooler bulletproof vest would be if a bullet hits you in your chest area then you don't take damage. Like this:
[lua]local function FindPlayer(str)
for _,v in ipairs(player.GetAll()) do if string.match(v:Name(),str) then return v end end
end
function GiveBodyArmor(ply,cmd,args)
local TO_GIVE = FindPlayer(args[1])
hook.Add("ScalePlayerDamage",TO_GIVE:SteamID().."bodyarmor",function(pl,hit,dmg)
if pl == TO_GIVE then
if hit == HITGROUP_CHEST then
dmg:SetDamage(0)
end
end
end)
end
concommand.Add("bodyarmor",GiveBodyArmor)[/lua]
Hmm just curious, but what tag did you use in the [] [/] because I can't see it. I have fully updated IE 8(I don't want to hear anything about that either. I have my reasons).
He used /lua wich... doesnt work so here =3
[code]local function FindPlayer(str)
for _,v in ipairs(player.GetAll()) do if string.match(v:Name(),str) then return v end end
end
function GiveBodyArmor(ply,cmd,args)
local TO_GIVE = FindPlayer(args[1])
hook.Add("ScalePlayerDamage",TO_GIVE:SteamID().."bodyarmor",function(pl,hit,dmg)
if pl == TO_GIVE then
if hit == HITGROUP_CHEST then
dmg:SetDamage(0)
end
end
end)
end
concommand.Add("bodyarmor",GiveBodyArmor)[/code]
This should help me a lil aswell, didnt know you could use Hitgroups for damage sets, This i will have to experiment with >:3
I accidentily rated myself dumb HAHAHAHAHA! "Why must it be so close to the edit button =3"
Sorry I have been away for a couple days, but I copy + pasted everything you said into init shared and cl_init and im still getting no results, does not show up in the entity tab in game, etc.
Oh, if it's what I said then it's not an entity, it's a concommand (made it in a few secs). Type "bodyarmor mishappp" in console.
No, it was the other one that -TB- posted his latest post.
If you cant get -TB-'s code to work, Just use Entoros' code.
It's Armour damn it. we gave you that sodding language, now stop abusing it!
[QUOTE=cyberpunk;16734121]It's Armour damn it. we gave you that sodding language, now stop abusing it![/QUOTE]
This.
Doesnt matter what language you use... And i tried both codes, still works fine for me.
[QUOTE=Jamie932;16733242]If you cant get -TB-'s code to work, Just use Entoros' code.[/QUOTE]
No because this is not what I need, I havent the slightest idea why it is not taking effect, I guess ill have to look else where for now and in regards to the people about how to pronounce armo(u)r go to general chat, im having issues with this and dont need the random posting.
Prepares for the random dumb ranks to appear.
I got it to work adding this,
[CODE]
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( "shared.lua" )[/CODE]
but it does not work when they try and buy it through the rp menu, I was thinking since when you buy things through the F4 menu they spawn where you look at a certain distance, is it possible instead of picking it up could just go on the person who summoned the ent, all of this may seem stupid to you if you know lua, I do not im just suggesting something that crossed my mind.
Ahh yea I dunno why I didn't paste that also. The last code I posted automaticly gives it your just gonna have to add lose 3 lines to the init.lua i posted.
I did copy + paste yours and those are my results it deducts money but does not give the armor.
[CODE]AddEntity("Body Armor", "armor", "models/items/hevsuit.mdl", 200, 1, "/armor")[/CODE]
I changed the name from body_Armor to armor, also it does work when I spawn it from the sents tab, just not buying it.
[QUOTE=-TB-;16708110]Hmm just curious, but what tag did you use in the [] [/] because I can't see it. I have fully updated IE 8(I don't want to hear anything about that either. I have my reasons).[/QUOTE]
IE (no matter what version) doesn't like garry's edited [lua ] tags...
[QUOTE=The-Stone;16829593]IE (no matter what version) doesn't like garry's edited [lua ] tags...[/QUOTE]
The [noparse][lua][/lua][/noparse] tags use javascript and it throws an error ( you need to enable debugging to see it, though ).
[img]http://filesmelt.com/downloader/wryyyy.png[/img]
Either garry needs to fix this or you need to switch browsers. Might be more errors, but that's the game breaker for my IE8 when I loaded it up on a page that had Lua tags in it.
Yeah I figured out if I right click and view source and search through it I can read what it says.
I'm not sure about dark RP I've never played it or seen it, so I can't help you there. If you try it in sandbox it should work fine so it must be something with darkrp.
[QUOTE=Kogitsune;16830061]The [noparse][lua][/lua][/noparse] tags use javascript and it throws an error ( you need to enable debugging to see it, though ).
[img]http://filesmelt.com/downloader/wryyyy.png[/img]
Either garry needs to fix this or you need to switch browsers. Might be more errors, but that's the game breaker for my IE8 when I loaded it up on a page that had Lua tags in it.[/QUOTE]
I know, this is the only problem... Where did you get those Dev tools?
[QUOTE=The-Stone;16830600]I know, this is the only problem... Where did you get those Dev tools?[/QUOTE]
[img]http://filesmelt.com/downloader/tulls.png[/img]
To get it to prompt you with the js error ( although I advise turning this back on if you visit a lot of websites that have js errors ), go to internet options > advanced, and under the browsing tree node, uncheck "Disable Script Debugging ( Internet Explorer )".
Although this is off topic, so if you want to continue this discussion beyond here, please PM me so we don't hijack this thread :).
Sorry, you need to Log In to post a reply to this thread.