• Code to Change Player Model with ulx groups
    13 replies, posted
i have this code [CODE]function changeplayermodel(ply) ply:SetModel("models/player/gman_high.mdl") end concommand.Add("changeplayermodel", changeplayermodel)[/CODE] But i need the command to work with certian ulx groups.
Have a look into [URL="http://wiki.garrysmod.com/page/GM/PlayerSpawn"]GM/PlayerSpawn[/URL] and [URL="http://wiki.garrysmod.com/page/Player/IsUserGroup"]Player/IsUserGroup[/URL]
The documentation to create a ulx command is [url=http://ulyssesmod.net/docs/files/lua/ulib/shared/commands-lua.html]here[/url].
[QUOTE=Promptitude;49770384]The documentation to create a ulx command is [url=http://ulyssesmod.net/docs/files/lua/ulib/shared/commands-lua.html]here[/url].[/QUOTE] i dont need to make a ulx command i want to make a console command for donator's to change to a custom playermodel
[code]if ply:GetNWString( "usergroup" ) == "donator" then ply:SetModel("models/player/gman_high.mdl") end[/code] that will work I'm pretty sure. server-side script.
[QUOTE=Percipience;49770460][code]if ply:GetNWString( "usergroup" ) == "donator" then ply:SetModel("models/player/gman_high.mdl") end[/code] that will work I'm pretty sure. server-side script.[/QUOTE] pretty sure it would work but i need a console command for it though
[QUOTE=ItsMoney;49770482]pretty sure it would work but i need a console command for it though[/QUOTE] -snip- didn't understand what he was trying to say.
[QUOTE=Percipience;49770487]there's no way you're going to be able to do that[/QUOTE] Wow, its possible. [URL="https://wiki.garrysmod.com/page/Net_Library_Usage"]https://wiki.garrysmod.com/page/Net_Library_Usage[/URL]
this should work for you. [CODE] local modelPaths = { {"donator","models/path"}, // first string is player's ulx group to check, other one is the model to change. {"admin","models/path"}, {"superadmin","models/path"} } hook.Add("PlayerSpawn", "_getSpawnedUser", function(ply) for k,v in pairs(modelPaths) do if(modelPaths[k][1] == string.lower(ply:GetUserGroup())) then ply:SetModel(modelPaths[v][2]) end end end) [/CODE]
[QUOTE=SteppuFIN;49770925]Wow, its possible. [URL="https://wiki.garrysmod.com/page/Net_Library_Usage"]https://wiki.garrysmod.com/page/Net_Library_Usage[/URL][/QUOTE] Or just use concommand.Add serverside?????
Wait, are you saying you want them to become a certain playermodel on command? If so: [code] concommand.Add( "changemodel", function( ply ) if ply:GetUserGroup() == "donator" then ply:SetModel( "models/player/gman_high.mdl" ) else ply:SendLua( "notification.AddLegacy( 'You must be a Donator to access this feature', 1, 2 )" ) end end ) [/code] Tested, and working. You're welcome.
or you could just make a chat command [CODE] local playerMeta = FindMetaTable('Player') function playerMeta:isGroup(group) return self:IsUserGroup(string.lower(group)) end hook.Add("PlayerSay","_onPlayerTypeSomething",function(ply,text) if( ply:isGroup("donator") && text == "!changemodel") then ply:SetModel( "models/player/gman_high.mdl" ) ply:SendLua( [[ chat.AddText(Color(0,180,255), '[SERVER] ', Color(0,255,0), 'You have succesfully changed your model.') ]] ) return false elseif(text == "!changemodel" && !ply:isGroup("donator")) then ply:SendLua( [[ chat.AddText(Color(0,180,255), '[SERVER] ', Color(255,0,0), 'You are not allowed to do this.') ]] ) return false end end) [/CODE]
I think, I think I get what you mean. You want a player to type something like this in his console "ChaneModel_OrWhatever modelName", and have his model be set to modelName? If so, you can either translate the actual .mdl file names (gman_high, p2_chell, etc) into understandable names (G-Man, That girl from Portal 2, etc) in a table. Then have the concommand print a list of models in case the model specified is invalid, and actually set the model if the model is valid. If this is not what you meant you should really be more specific. (Also simply add a ply:IsUserGroup or LocalPlayer():IsUserGroup test to see if he's in the correct ulx group)
[QUOTE=JasonMan34;49778002]I think, I think I get what you mean. You want a player to type something like this in his console "ChaneModel_OrWhatever modelName", and have his model be set to modelName? If so, you can either translate the actual .mdl file names (gman_high, p2_chell, etc) into understandable names (G-Man, That girl from Portal 2, etc) in a table. Then have the concommand print a list of models in case the model specified is invalid, and actually set the model if the model is valid. If this is not what you meant you should really be more specific. (Also simply add a ply:IsUserGroup or LocalPlayer():IsUserGroup test to see if he's in the correct ulx group)[/QUOTE] I've already told him the solution, he just wanted a handout, and now he's out. He doesn't care about replying anymore lmao.
Sorry, you need to Log In to post a reply to this thread.