• Set player's model
    5 replies, posted
I want it so when you press "E" on the entity it sets your playermodel to the one specified and then removes the entity but it doesn't seem to be working, can you help me out. Inside clothing_store >> lua >> entities >> suit, I have this: [B]cl_init.lua[/B] include('shared.lua') function ENT:Draw() self:DrawModel() end [B]init.lua[/B] AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include('shared.lua') util.PrecacheModel( "models/player/suits/male_07_closed_tie.mdl" ) function ENT:Initialize() self:SetModel( "models/player/suits/male_07_closed_tie.mdl" ) self:PhysicsInit( SOLID_VPHYSICS ) self:SetMoveType( MOVETYPE_VPHYSICS ) self:SetSolid( SOLID_VPHYSICS ) local phys = self:GetPhysicsObject() if (phys:IsValid()) then phys:Wake() end end function ENT:Use( activator, caller ) ply:SetModel( "models/player/suits/male_07_closed_tie.mdl" ) Entity:Remove() end [B]shared.lua[/B] ENT.Type = "anim" ENT.Base = "base_gmodentity" ENT.PrintName = "Suit" ENT.Author = "Flaow" ENT.Contact = "" ENT.Purpose = "" ENT.Instructions = "" ENT.Spawnable = true ENT.AdminSpawnable = false ENT.Category = "Flaow Clothing"
First of all, wrap your code in [code] tags for easier readability. Second of all you have to use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetUseType]Entity:SetUseType[/url] to make using available on the entity. Call it through ENT:Initialize() Finally, you have some syntax issues here: [code]function ENT:Use( activator, caller ) ply:SetModel( "models/player/suits/male_07_closed_tie.mdl" ) -- PLY ISN'T DEFINED, USE activator:SetModel() Entity:Remove() -- ONCE AGAIN, CHANGE ENTITY TO self:Remove() end[/code]
--Snip-- comment above me covered what I said..
Also, if your gamemode is based on sandbox, then you should be running [CODE] RunConsoleCommand( "cl_playermodel", "models/player/suits/male_07_closed_tie.mdl" ) [/CODE]
[QUOTE=MPan1;49780791]Also, if your gamemode is based on sandbox, then you should be running [CODE] RunConsoleCommand( "cl_playermodel", "models/player/suits/male_07_closed_tie.mdl" ) [/CODE][/QUOTE] That just makes the player model choice permanent. He wants it to basically work like an outfit if I understand correctly
[QUOTE=solid_jake;49779645]First of all, wrap your code in [code] tags for easier readability. Second of all you have to use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetUseType]Entity:SetUseType[/url] to make using available on the entity. Call it through ENT:Initialize() Finally, you have some syntax issues here: [code]function ENT:Use( activator, caller ) ply:SetModel( "models/player/suits/male_07_closed_tie.mdl" ) -- PLY ISN'T DEFINED, USE activator:SetModel() Entity:Remove() -- ONCE AGAIN, CHANGE ENTITY TO self:Remove() end[/code][/QUOTE] Thank you! It now works!
Sorry, you need to Log In to post a reply to this thread.