• Entitly don't move with physgun
    9 replies, posted
Hello, I have entlies like cars, money printers, drug labs that I don't want to be able to use physgun on it. I searched on gmod wiki and found this: [lua] function physgunPickup( ply, ent ) if ent:GetClass() == "player" then return false // Don't allow them to pick up players!! else return false // If not a player, allow them to pick up the item. end end hook.Add( "PhysgunPickup", "physgunPickup", physgunPickup ); [/lua] When I paste that in the entitly lua file, it works [b]but now it's set on all the props.[/b] How can I fix it so it only affect that single entitly
Both are returning false. [lua] 1. function physgunPickup( ply, ent ) 2. if ent:GetClass() == "player" then 3. return false // Don't allow them to pick up players!! 4. else 5. return true // If not a player, allow them to pick up the item. 6. end 7. end 8. 9. hook.Add( "PhysgunPickup", "physgunPickup", physgunPickup ); [/lua]
It needs to be both false because the first one is that you can't pick up players and the second one is that you can't pickup entitly/item. Isn't it?
[lua]local NoPickup = { "druglabentityname", "moneyprinterentityname" } hook.Add( "PhysgunPickup", "NoPickup", function( ply, ent ) return !table.HasValue( NoPickup, ent:GetClass( ) ) end )[/lua]
Ok thanks for your help :), where i have to put it? edit dont work
[QUOTE=Overv;16944902][lua]local NoPickup = { "druglabentityname", "moneyprinterentityname" } hook.Add( "PhysgunPickup", "NoPickup", function( ply, ent ) return !table.HasValue( NoPickup, ent:GetClass( ) ) end )[/lua][/QUOTE] You continually put returns in hooks where there should be done. With that code, any entity other than `druglabentityname`s or `moneyprinterentityname`s will be able to be physgunned, regardless of what any other hook or the gamemode thinks about it. [lua]local NoPickup = { "druglabentityname", "moneyprinterentityname" } hook.Add( "PhysgunPickup", "NoPickup", function( ply, ent ) if table.HasValue( NoPickup, ent:GetClass( ) ) then return false end end )[/lua]
Ah yes, sorry.
Ok works perfect on moneyprinter and drug lab. On vehicle it dont work because i dont know what entitlie it is, i used "prop_vehicle_jeep_old" but didn't work
prop_vehicle_jeep
Thanks for the nice support. Working!
Sorry, you need to Log In to post a reply to this thread.