Author Topic: UTeam - Set teams based on usergroup.  (Read 316709 times)

0 Members and 1 Guest are viewing this topic.

Offline spbogie

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 456
  • Karma: 41
UTeam - Set teams based on usergroup.
« on: January 13, 2007, 12:53:47 PM »
Description:
UTeam allows you to set a player's team (and a few other things) based on their current usergroup.

Features:
  • Set teams with custom color and name.
  • Optionaly set health, armor, and player model for each team.
  • Specify which gamemodes to load on.

Notes:
  • Usergroups can be set through Garry's default file (garrysmod/settings/users.txt), or through ULib/ULX.
  • Groups take priority based on their order(1 is highest priority). Set your teams based on decending group level so users don't get put on a lower team. (ie. If admin is before superadmin, superadmins will end up on admin team instead of superadmin team)
  • Use group "user" as your last team to catch everyone who wasn't put on another team.

ChangeLog:
  • Version 1.1
    +Added support for setting variables on the player table (ie. SprintSpeed)
    *Fixed errors when running on gamemodes not in list
    *Gamemodes are based off name in scoreboare, but are no longer case-sensitive

UTeam_readme.txt
Code: [Select]
UTeam
  By: spbogie [Ulysses Team]

Installation:
  place UTeam.txt in garrysmod/data
  place UTeam.lua in garrysmod/lua/autorun

ChangeLog:
 version 1.1
  +Added support for setting variables on the player table (ie. SprintSpeed)
  *Fixed errors when running on gamemodes not in list
  *Gamemodes are based off name in scoreboare, but are no longer case-sensitive

Config Format (UTeam.txt):
"Out"
{
"teams"
{
"1" //Team index. Start at 1 and go up. Team priority lowest first.
{
"name" "Name" //Name of the team.
"group" "usergroup" //Usergroup required for the team. Works with garry's default and UCL.
"color" //The team's color
{
"r" "255" //Red value
"g" "100" //Green Value
"b" "0" //Blue Value
"a" "255" //Alpha Value
}
"hp" "500" //(*Optional*) Player's initial health.
"armor" "500" //(*Optional*) Player's initial armor.
"model" "gman" //(*Optional*) Player's model. (None if undefined, Kleiner if invalid) Valid models listed below
"plytable" //(*Optional*) Set values on the Player's table.
{ //Format is key:value

"1" "SprintSpeed:1000" //Set the player's sprint speed (Def. 500)
"2" "WalkSpeed:500" //Set the player's walk speed (Def. 250)
}
}
}
"gamemodes" //Gamemodes to load on
{
"1" "Sandbox" //To add additional increase number each time
}
}

Valid player Models:
  alyx
  barney
  breen
  charple
  combine
  corpse
  eli
  female1
  female2
  female3
  gman
  kleiner
  male1
  male2
  male3
  monk
  mossman
  odessa
  police
  prison
  super
  zombie

Download:

See http://html-color-codes.com/rgb.html for good list of RGB color combinations
« Last Edit: July 18, 2009, 10:22:52 AM by JamminR »
I have not failed. I've just found 10,000 ways that won't work. - Thomas A. Edison
I reject your reality and substitute my own. - Adam Savage

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: UTeam - Set teams based on usergroup.
« Reply #1 on: January 13, 2007, 01:14:31 PM »
Lua king'd :)
Experiencing God's grace one day at a time.

Offline maaarten

  • Newbie
  • *
  • Posts: 16
  • Karma: 0
Re: UTeam - Set teams based on usergroup.
« Reply #2 on: January 13, 2007, 05:22:07 PM »
where do i put it?

in the lua/ulib/modules folder?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: UTeam - Set teams based on usergroup.
« Reply #3 on: January 13, 2007, 05:57:39 PM »
where do i put it?

in the lua/ulib/modules folder?

Quote from: UTeam_readme.txt
Installation:
  place UTeam.txt in garrysmod/data
  place UTeam.lua in garrysmod/lua/autorun

Though, modules would work too.
I think this script isn't reliant on ULib, so, it can just be put in autorun.
Personally, I like putting all of my U-scripts in modules. Only others I put there are ones that I have trouble with, or have had to modify for whatever reason or other (compatibility, gamemode checking, etc)
« Last Edit: January 14, 2007, 09:01:38 AM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline maaarten

  • Newbie
  • *
  • Posts: 16
  • Karma: 0
Re: UTeam - Set teams based on usergroup.
« Reply #4 on: January 14, 2007, 04:29:27 AM »
thanks ;D

Offline EscudoDenali

  • Newbie
  • *
  • Posts: 24
  • Karma: 0
Re: UTeam - Set teams based on usergroup.
« Reply #5 on: February 01, 2007, 09:58:05 PM »
Hey, will this work now that Gmod has this funky new scoreboard?
"What I lack in skill, I make up for in stupidity." - EscudoDenali
Escudo's Non-Tolerance Server <--- FUN

Offline Mank

  • Full Member
  • ***
  • Posts: 209
  • Karma: 9
    • Ulysses Mod!
Re: UTeam - Set teams based on usergroup.
« Reply #6 on: February 02, 2007, 02:55:03 PM »
Hey, will this work now that Gmod has this funky new scoreboard?

I doubt Garry changed the Lua -> Scoreboard functions, I'm pretty sure [[it's be compatibly] - Wow, I can't spell], Garry tries to make sure he doesn't change fundamental things that ruin scripts in each version. =)
« Last Edit: February 03, 2007, 09:57:24 AM by Mank »
If you doubt your powers you bring powers to your doubts.

Offline spbogie

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 456
  • Karma: 41
Re: UTeam - Set teams based on usergroup.
« Reply #7 on: February 03, 2007, 07:07:09 AM »
The script still works, however the new scoreboard doesn't grab any team info. If you use the script you will still be set to the proper team, your name will still appear the right color in chat. You will still be setup with the right model, health, and armor. You just won't see teams in the default scoreboard. That being said there are a few new custom scoreboards that have added back in support for showing teams. I would recomend sui_scoreboard, but there are others.
I have not failed. I've just found 10,000 ways that won't work. - Thomas A. Edison
I reject your reality and substitute my own. - Adam Savage

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: UTeam - Set teams based on usergroup.
« Reply #8 on: March 04, 2007, 08:18:26 PM »
Can you make it set the player speed too please? :)

To do this, just change the appropriate variable in the player's table.
Experiencing God's grace one day at a time.

Offline jjb123

  • Newbie
  • *
  • Posts: 14
  • Karma: 0
Re: UTeam - Set teams based on usergroup.
« Reply #9 on: March 15, 2007, 01:34:20 PM »
For some reason it is not recognizing one of my custom groups, a vip group.  It doesn't apply custom health, or color. Whats wrong?

Offline spbogie

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 456
  • Karma: 41
Re: UTeam - Set teams based on usergroup.
« Reply #10 on: March 15, 2007, 01:51:42 PM »
How are you adding users to this custom group. If you are adding them using the settings/users.txt, and have ULib installed, then you may encounter problems trying to use custom user groups. Instead try adding your users to /data/ULib/users.txt. The format is different' but shouldn't be too difficult to understand if you already have some other users in there (admins and superadmins from /settings/users.txt are added there automatically).

If you are using the list in /data/ULib/users.txt, then please check for any errors on startup/connect (both server and clientside), and post your /data/ULib/users.txt & /data/ULib/groups.txt files.
I have not failed. I've just found 10,000 ways that won't work. - Thomas A. Edison
I reject your reality and substitute my own. - Adam Savage

Offline jjb123

  • Newbie
  • *
  • Posts: 14
  • Karma: 0
Re: UTeam - Set teams based on usergroup.
« Reply #11 on: March 16, 2007, 02:15:09 PM »
Yep, only added the user to the data/ulib files. Here is my users file

Code: [Select]
"Out"
{
"jjb123"
{
"type" "steamid"
"groups"
{
"1" "superadmin"
"2" "immunity"
}
"ID" "xxxxxxxxxx"
}
"Patty"
{
"ID" "xxxxxxxxxx"
"type" "steamid"
"groups"
{
"1" "vip"
}
}
}

and my groups file

Code: [Select]
"Out"
{
"Admin"
{
"deny"
{
"1" "ulx ban"
"3" "ulx exec"
"2" "ulx cexec"
}
}
"vip"
{
"allow"
{
"1" "ulx noclip"
"3" "ulx god"
"2" "ulx gimp"
"5" "ulx ungod"
"6" "ulx goto"
}
}
}



Offline spbogie

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 456
  • Karma: 41
Re: UTeam - Set teams based on usergroup.
« Reply #12 on: March 16, 2007, 02:56:39 PM »
Shouldn't be a problem, but you missed 4 in vip allow.
Could you also post your UTeam.txt, and the output of "status" and "lua_run PrintTable(ULib.ucl)" in server console while both you and your VIP are on the server.
I have not failed. I've just found 10,000 ways that won't work. - Thomas A. Edison
I reject your reality and substitute my own. - Adam Savage

Offline jjb123

  • Newbie
  • *
  • Posts: 14
  • Karma: 0
Re: UTeam - Set teams based on usergroup.
« Reply #13 on: March 16, 2007, 04:31:59 PM »
Sure, here is my uteam file

Code: [Select]
"Out"
{
"teams"
{
"1"
{
"name" "SuperAdmins"
"group" "superadmin"
"armor" "1000"
"hp" "1000"
"color"
{
"a" "255"
"B" "85"
"g" "200"
"r" "0"
}
}
"2"
{
"name" "Admins"
"group" "admin"
"armor" "500"
"hp" "500"
"color"
{
"a" "255"
"B" "50"
"g" "50"
"r" "255"
}
}
"3"
{
"name" "Players"
"group" "user"
"color"
{
"a" "255"
"B" "255"
"g" "100"
"r" "0"
}
}
"4"
{
"name" "VIP"
"group" "vip"
"armor" "500"
"hp" "500"
"color"
{
"a" "255"
"B" "44"
"g" "211"
"r" "255"
}
}
}
"gamemodes"
{
"1" "Sandbox"
"2" "SpaceBuild"
}
}

and the output of status (of course, xxxxxxx is id)

Code: [Select]
hostname:  gbserver
version : 1.0.0.0/7 3048 secure
udp/ip  :  192.168.0.101:27015
map     :  gm_battle_arena_v5 at: -1567 x, -752 y, 832 z
players :  2 (8 max)

# userid name uniqueid connected ping loss state adr
#  2 "jjb123" xxxxxxxxxxx 02:41 35 0 active 127.0.0.1:27005
#  3 "patty" xxxxxxxxxxx 01:25 81 0 active 69.246.72.184:27005

and here is the return of ua_run PrintTable(ULib.ucl)

Code: [Select]

> PrintTable(ULib.ucl)...
passTimeout = function: 01D05A98
addAccessCallback = function: 01D05AC8
checkAuth = function: 01D05A80
callbacks:
1 = function: 019090B4
2 = function: 01D06050
groups:
immunity:
allow:
deny:
superadmin:
allow:
deny:
admin:
allow:
deny:
1 = ulx ban
3 = ulx exec
2 = ulx cexec
vip:
allow:
1 = ulx noclip
3 = ulx god
2 = ulx gimp
5 = ulx ungod
6 = ulx goto
deny:
addUser = function: 01D05A20
awaitingauth:
addGroup = function: 01D05A08
authed:
Player [1][jjb123]:
deny:
type = steamid
groups:
1 = superadmin
2 = immunity
account = jjb123
id = xxxxxxxxx
allow:
uniqueid = 3121351647
Player [2][patty]:
deny:
type = steamid
groups:
1 = vip
account = patty
id = xxxxxxxxx
allow:
uniqueid = 632034427
users:
jjb123:
deny:
type = steamid
groups:
1 = superadmin
2 = immunity
id = xxxxxxxxxxxxx
pass =
allow:
patty:
deny:
type = steamid
groups:
1 = vip
id = xxxxxxxxxxxx
pass =
allow:
query = function: 01D05AE0
removeUser = function: 01D05A38
probe = function: 01D05A50
checkPass = function: 01D05A68
callCallbacks = function: 01D05AB0

Offline spbogie

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 456
  • Karma: 41
Re: UTeam - Set teams based on usergroup.
« Reply #14 on: March 16, 2007, 08:01:44 PM »
Ah, found the problem. Teams take priority based on order, and all players have usergroup user. Change the user and vip teams around (make vip 3 and user 4).
I have not failed. I've just found 10,000 ways that won't work. - Thomas A. Edison
I reject your reality and substitute my own. - Adam Savage