So, I am having an issue where I am trying to render onto the HUD the model of the player (in prophunt, so the player can see on the HUD their prop), but all that I am getting on the HUD is a cube in the place of the model, no matter what prop the player is.
This is what I get:
[url]http://i.imgur.com/KglNLZx.jpg[/url]
(Ignore the top part of the HUD at the top of the screen where it is duplicated, that was for testing purposes)
Here is the code that I am using (if you need to be able to see any more of it, just let me know):
[CODE]local icon = vgui.Create( "DModelPanel" )
icon:SetModel( LocalPlayer():GetModel() )
icon:SetSize( 100, 100 )
local mn, mx = icon.Entity:GetRenderBounds()
local size = 0
size = math.max( size, math.abs( mn.x ) + math.abs( mx.x ) )
size = math.max( size, math.abs( mn.y ) + math.abs( mx.y ) )
size = math.max( size, math.abs( mn.z ) + math.abs( mx.z ) )
icon:SetFOV( 45 )
icon:SetCamPos( Vector( size - 5, size - 10, size - 5 ) )
icon:SetLookAt( ( mn + mx ) * 0.5 )
Bar:AddItem( icon )[/CODE]
If anyone has any ideas for what could be the reasoning behind this and how I could solve it, it would be greatly appreciated if you could offer some help. I have a relatively high amount of experience with coding as a whole, but am relatively new to Lua. Thanks in advance!
Prophunt doesnt literally change the players model, it just creates a new entity and hides the player, setting the hitbox of the player to the new created entity.
If im not mistaken, you should be able to get the players prop with this function:
[CODE]
pl.ph_prop:GetModel()
[/CODE]
Make sure to also change the skin, as some models have got different skins as well.
[QUOTE=geferon;52172620]Prophunt doesnt literally change the players model, it just creates a new entity and hides the player, setting the hitbox of the player to the new created entity.
If im not mistaken, you should be able to get the players prop with this function:
[CODE]
pl.ph_prop:GetModel()
[/CODE]
Make sure to also change the skin, as some models have got different skins as well.[/QUOTE]
Tried changing it out for LocalPlayer().ph_prop:GetModel(), but it gives me an error of "ph_prop" not existing, thanks for the help anyways though, it does seem like it is along the right lines towards a solution. The way I am doing this is editing the existing fretta HUD in the fretta gamemode, could that be what is causing the issue at this point?
ph_prop is most likely not networked -- Can you post a link to the Prop Hunt gamemode?
[QUOTE=zoox;52172804]ph_prop is most likely not networked -- Can you post a link to the Prop Hunt gamemode?[/QUOTE]
[url]https://github.com/Vinzuerio/ph-enhanced[/url]
[QUOTE=zoox;52172880]try [CODE]LocalPlayer():GetNWEntity("PlayerPropEntity")[/CODE][/QUOTE]
I think that would have worked, but now I am getting an issue from what being the arguments for setting the model on the DModelPanel. The error I get is:
[CODE]
[ERROR] lua/vgui/dmodelpanel.lua:54: bad argument #1 to 'ClientsideModel' (string expected, got userdata)
[/CODE]
Any way that I could convert the data?
:SetModel takes a string, not an entity -- Use LocalPlayer():GetPlayerPropEntity():GetModel()
[QUOTE=zoox;52172908]:SetModel takes a string, not an entity -- Use LocalPlayer():GetPlayerPropEntity():GetModel()[/QUOTE]
Thanks for all the great help! Got it working perfectly now! :)
Sorry, you need to Log In to post a reply to this thread.