• Change playermodels model Locally and not entire servers
    10 replies, posted
How do I make it so the Playermodel sets Locally so that only the player who has this function run changes model and not everyone in the server? I basically have a gmod character creation system VIDEO: [url]https://www.youtube.com/watch?v=K2o1uNZnjKM[/url] I have this in the init.lua [CODE] function GM:PlayerSetModel( ply ) ply:SetModel( pm ) ply:SetSkin( 2 ) end [/CODE]
:snip: Aren't you already doing that? You're indexing ply (which is local)
[QUOTE=MPan1;49731593]:snip: Aren't you already doing that? You're indexing ply (which is local)[/QUOTE] Well that is what I'm doing but it still sets everyone in the servers model
Where are you running this function? Could you provide a little more code?
[CODE] GM.StartTime = SysTime(); GM.Name = "GMODLife"; GM.Author = "MrLetsPlayGames"; -- include("resources.lua"); include("cl_init.lua"); DeriveGamemode("sandbox"); //Sets Team and Default Speeds function GM:PlayerSetModel( ply ) ply:SetModel( pm ) ply:SetSkin( 2 ) end function playerSetSpeed(ply) timer.Simple(2, function() GAMEMODE:SetPlayerSpeed(ply, 160, 240) player:SetWalkSpeed( 160 ) player:SetRunSpeed( 240 ) end) end hook.Add( "PlayerSpawn", "playerSetSpeedtest", playerSetSpeed ) function male_01( ply ) -- ply:SetModel( "models/humans/modern/male_02_01.mdl" ) pm = "models/humans/modern/male_01_01.mdl" end concommand.Add( "male_01", male_01 ) function male_02( ply ) -- ply:SetModel( "models/humans/modern/male_02_01.mdl" ) pm = "models/humans/modern/male_02_01.mdl" end concommand.Add( "male_02", male_02 ) function male_03( ply ) -- ply:SetModel( "models/humans/modern/male_02_01.mdl" ) pm = "models/humans/modern/male_03_01.mdl" end concommand.Add( "male_03", male_03 ) function male_04( ply ) -- ply:SetModel( "models/humans/modern/male_02_01.mdl" ) pm = "models/humans/modern/male_04_01.mdl" end concommand.Add( "male_04", male_04 ) function male_05( ply ) -- ply:SetModel( "models/humans/modern/male_02_01.mdl" ) pm = "models/humans/modern/male_05_01.mdl" end concommand.Add( "male_05", male_05 ) function male_06( ply ) -- ply:SetModel( "models/humans/modern/male_02_01.mdl" ) pm = "models/humans/modern/male_06_01.mdl" end concommand.Add( "male_06", male_06 ) function male_07( ply ) -- ply:SetModel( "models/humans/modern/male_02_01.mdl" ) pm = "models/humans/modern/male_07_01.mdl" end concommand.Add( "male_07", male_07 ) function male_08( ply ) -- ply:SetModel( "models/humans/modern/male_02_01.mdl" ) pm = "models/humans/modern/male_08_01.mdl" end concommand.Add( "male_08", male_08 ) -- if(CLIENT) then -- function PlayerSpeed( ply ) -- ply:SetGravity( 1 ) -- ply:SetWalkSpeed( 5 ) -- ply:SetRunSpeed( 1 ) -- ply:SetCrouchedWalkSpeed( 0.3 ) -- ply:SetDuckSpeed( 0.5 ) -- ply:SetNoCollideWithTeammates( false ) -- end -- end if(SERVER) then local TEAM_CITIZEN = 1 function GM:PlayerInitialSpawn( ply ) ply:SetTeam( TEAM_CITIZEN ) ply:SetGravity( 1 ) ply:SetWalkSpeed( 5 ) ply:SetRunSpeed( 1 ) ply:SetCrouchedWalkSpeed( 0.3 ) ply:SetDuckSpeed( 0.5 ) ply:SetNoCollideWithTeammates( false ) ply:SendLua( [[chat.AddText( Color( 70, 70, 200 ), "[GMODLife] ", Color( 255, 255, 255 ), "Welcome to the server, ]] ..ply:Nick() .. [[!" )]] ) end end [/CODE] It's a little sloppy but im doing organization and cleaning later. Also this is not all of my init.lua just a little of some of the things that may be usefull
The problem with your code is that the pm variable (as well as all the male_somenumber functions) are all global variables, and they're all created and changed serverside. You need to use something like the [URL="https://wiki.garrysmod.com/page/Net_Library_Usage"]net library[/URL] to send the pm value once the client has changed it to whatever they want their model to be [editline]13th February 2016[/editline] I might post an example but I'm trying to think of a better way to do this
[QUOTE=MPan1;49731708]The problem with your code is that the pm variable (as well as all the male_somenumber functions) are all global variables, and they're all created and changed serverside. You need to use something like the [URL="https://wiki.garrysmod.com/page/Net_Library_Usage"]net library[/URL] to send the pm value once the client has changed it to whatever they want their model to be [editline]13th February 2016[/editline] I might post an example but I'm trying to think of a better way to do this[/QUOTE] Can you give an example never used net.library if you need my cl_init.lua no problem
Do you have the function/code when you run the male_somenumber functions? If you could post that, I could probably try and do an example for you
[CODE] Male01.DoClick = function( ply ) icon:SetModel( "models/humans/modern/male_01_01.mdl" ) RunConsoleCommand("male_01"); end [/CODE] this is in my cl_init.lua it runs male_01 as a concommand so it runs it through serverside Male01 is the name of the Button so if they click the button it does male_01 which is how I run in on init.lua Icon is also the name of the 3d model that shows up on the left side so dont mix that up with anything
If you just save it globally like that it will override it everytime someone runs the command, store it on the player instead. [CODE] function GM:PlayerSetModel( ply ) ply:SetModel( ply.pm ) ply:SetSkin( 2 ) end function male_01( ply ) ply.pm = "models/humans/modern/male_01_01.mdl" end concommand.Add( "male_01", male_01 ) [/CODE]
[QUOTE=ToBadForYou;49732859]If you just save it globally like that it will override it everytime someone runs the command, store it on the player instead. [CODE] function GM:PlayerSetModel( ply ) ply:SetModel( ply.pm ) ply:SetSkin( 2 ) end function male_01( ply ) ply.pm = "models/humans/modern/male_01_01.mdl" end concommand.Add( "male_01", male_01 ) [/CODE][/QUOTE] It works great Thx a lot man
Sorry, you need to Log In to post a reply to this thread.