Is there a when clicking on a prop ( Example : models/props_lab/workspace002.mdl ) to open a derma screen?
You could make an entity, and use the built-in serverside ENT:Use() function. You can network it for clientside stuff like derma screens.
[url]http://wiki.garrysmod.com/page/ENTITY/Use[/url]
I'd recommend setting the use type to SIMPLE_USE as well
[url]http://wiki.garrysmod.com/page/Entity/SetUseType[/url]
Cant get it to work....
Can you add me on steam? So you can help me privately
[URL="http://steamcommunity.com/id/J-avs/"]http://steamcommunity.com/id/J-avs/[/URL]
The functions you gave above are for a self-made entity, you've to use the gamemode use hook.
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerUse]GM:PlayerUse[/url]
check if its props_physics, and check if its the desired model, then send a net message to the user, opening the menu.
[QUOTE=whitestar;51223137]
check if its props_physics, and check if its the desired model, then send a net message to the user, opening the menu.[/QUOTE]
Perhaps I was doing something wrong but it doesn't seem like you can USE on props_physics. (That or my game is broken?)
Are you running the code in singleplayer, or on a real server?
[QUOTE=whitestar;51226237]Are you running the code in singleplayer, or on a real server?[/QUOTE]
I've tried both (not an actual dedicated server but local server via gmod menu).
Anyways, only some props_physics can be picked up. For example, I can pick up "models/props_c17/canister_propane01a.mdl" but not "models/props_borealis/bluebarrel001.mdl".
I've never actually thought about this, but now I'm curious. How/where is it decided for which props_physics you can pick up? I know in Hammer there's a flag that will generate output on +USE.
[IMG]http://i.imgur.com/0MstsMQ.png[/IMG]
How would you make it so you could USE on the bluebarrel0001 prop (while still keeping it a props_physics entity)? Is there a way to give a "prop_physics" entity the "generate output on +USE" flag?
Sorry for so many questions. :huh:
[code]
util.AddNetworkString('dermamenuprop')
hook.Add('PlayerUse', 'DermaShit', function(ply, ent)
if ent:GetClass() == 'prop_physics' and ent:GetModel() == 'models/props_borealis/bluebarrel001.mdl' then
net.Start('dermamenuprop')
net.Send(ply)
print('Prints if USE works')
end
end)
-- This command gets the Spawnflags using the official function and through keyvalues (Keyvalues dont seem to update though)
concommand.Add('proptest', function(ply)
for k, v in pairs(ents.FindByClass('prop_physics')) do
if v:GetModel() == 'models/props_borealis/bluebarrel001.mdl' then
print(v:GetKeyValues()['spawnflags'])
print('-->'..v:GetSpawnFlags())
end
end
end)
-- This command SETS the 'Generate output' spawnflag on the borealis barrel prop, allowing the use of the PlayerUse Hook
concommand.Add('proptest2', function(ply)
for k, v in pairs(ents.FindByClass('prop_physics')) do
if v:GetModel() == 'models/props_borealis/bluebarrel001.mdl' then
v:SetKeyValue('spawnflags', '256')
end
end
end)
[/code]
I tested this code, works fine, use 'proptest2' to set the [B]Generate output keyvalue[/B], then the hook works, if you're good 'nuff, you'll find a way to apply this on any wanted prop, and even when they get newly spawned by the player or so.
[editline]19th October 2016[/editline]
Spawnflags as IDs can be found here: [url]https://developer.valvesoftware.com/wiki/Prop_physics[/url]
Not sure why you wouldn't make it a custom entity
[QUOTE=Skere_;51226798]Not sure why you wouldn't make it a custom entity[/QUOTE]
Maybe he wants something to apply on ALL props on the map with a specific model? time will tell!
Sorry, you need to Log In to post a reply to this thread.