Author Topic: Restricting player models?  (Read 11567 times)

0 Members and 1 Guest are viewing this topic.

server4u

  • Guest
Restricting player models?
« on: October 04, 2010, 03:00:02 AM »
Hello, i tried searching the forums but didnt really find anything...

I am planning to have special models for the admins (or atleast for myself so people can recognize me better)
I know there are scripts to restrict changing models for some ranks but i want to have a lua that will deny all users except for me (by steam ID or rank)

Does anyone have an example script of something like it so i can mod it?
I am not good enough with lua to make something from scratch but am master at modding it to do what i need :d

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Restricting player models?
« Reply #1 on: October 04, 2010, 05:02:10 PM »
Our ULX SVN now includes UTeam, which lets you set player model by team grouping.
http://forums.ulyssesmod.net/index.php/topic,4782.0.html

UTeam release for non-SVN ULX also does same (but I'm not sure it works anymore with all the Gmod changes over past 2 years)
http://forums.ulyssesmod.net/index.php/topic,663.0.html

Not sure UTeam prevents others from changing models though.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Restricting player models?
« Reply #2 on: October 05, 2010, 10:41:30 AM »
If you set a players model with UTeam this is the only model they will spawn with regardless of what model they choose. It is because it forces their model after they spawn.

If you are looking for a way to allow players to freely choose their model while restricting certain models to certain groups then UTeam is not for you.

I have in my head a way to do it, but it would require a little digging for the right hooks and functions... here is some pseudo-code in case anyone is interested in picking this project up...


**DISCLAIMER: THE BELOW IS NOT REAL LUA... THIS WILL NOT WORK AS IS... IT IS JUST A DESIGN FOR A SCRIPT THAT WOULD WORK FOR THIS SITUATION...**
Code: [Select]

modeltable = { "modelpath1", "modelpath2" } --These are models that are restricted.
grouptable = { "admin", "superadmin", "any other groups you want to allow" } --These are the groups that can use the above models.


function PlayerSpawnFunction()
loop through (grouptable)
if PlayerIsGroup(currentgroupfromloop) then
return
end
end

loop through (modeltable)
if FunctionToGetPlayerModel(currentplayer) == currentlyloopedmodelfromthetable then
SetPlayerModel(kliener or some other default model)
PrintMessageToPlayer("This model is restricted")
return
end
end
end

**DISCLAIMER: THE ABOVE IS NOT REAL LUA... THIS WILL NOT WORK AS IS... IT IS JUST A DESIGN FOR A SCRIPT THAT WOULD WORK FOR THIS SITUATION...**

Offline sweetone

  • Jr. Member
  • **
  • Posts: 63
  • Karma: 2
Re: Restricting player models?
« Reply #3 on: January 22, 2012, 04:43:17 PM »
sorry for opening real old topic but this could be useful

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Restricting player models?
« Reply #4 on: January 22, 2012, 05:29:17 PM »
Megiddo had (ulx v1?) code lying around for this at one time, we used to use it to change into the fox/tails model (kinda hedgehog lookin, but with a tail) player model.
We'd offer permission to do it as a feature for donators.
Not granted permission, then no ability to do it.

Maybe he's still got it laying around somewhere? If so Megiddo, post it, perhaps one of us can hack it for the modern era.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Restricting player models?
« Reply #5 on: January 23, 2012, 09:54:49 AM »
Pretty sure that code is lost to the Ether at this point. It wasn't very complicated though. I just checked via a hook or overriding a command to make sure those without permission did not use the model.
Experiencing God's grace one day at a time.

Offline sweetone

  • Jr. Member
  • **
  • Posts: 63
  • Karma: 2
Re: Restricting player models?
« Reply #6 on: January 24, 2012, 04:30:00 AM »
Pretty sure that code is lost to the Ether at this point. It wasn't very complicated though. I just checked via a hook or overriding a command to make sure those without permission did not use the model.

Any chance you could make it again? (:

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Restricting player models?
« Reply #7 on: January 24, 2012, 06:12:19 AM »
No time sorry... :(
Experiencing God's grace one day at a time.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Restricting player models?
« Reply #8 on: January 24, 2012, 01:34:19 PM »
Try something like this:
Code: [Select]
hook.Add( "PlayerSetModel", "SetModels", function( ply )

if ply:IsAdmin() or ply:SteamID() == "BOT" then
ply:SetModel( "models/<some model here>.mdl" )
end

if ply:GetModel() == "models/breen.mdl" and ply:IsSuperAdmin() then
ply:SetModel( "models/breen.mdl" )
end

end )
I didn't test it, but if you can manage some simple Lua it won't be hard to change.