ULX

Author Topic: User created teams plugin.  (Read 2909 times)

0 Members and 1 Guest are viewing this topic.

Offline Eb

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
User created teams plugin.
« on: March 20, 2008, 01:18:17 PM »
I've had an idea for a long while, have a player be able to create their own team, invite other players into the team, or allow others in via a join password. This wouldn't be like UTeam because the players would be able to make their own teams, not have their teams set as their user group. Team chat would only display messages to the team, and team members would be able to tell between their teammates and others via some sort of visual. I've been thinking of somehow scripting it, but I'm nearly clueless when it comes to lua, but i think it'd be a good place to start out. If there is a mod that does this, please point me in it's direction, if not, please help me code it; thanks in advance.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: User created teams plugin.
« Reply #1 on: March 20, 2008, 03:33:42 PM »
Eb, though I personally don't see a need for this, I do think it is an interesting idea. Some of the neatest modules come from ingenuity like this.

Any 'team' script already written, including UTeam, would show you a basis for how teams are changed/created/set when players join.

The problem with your idea lies in the fact that many scripts, including UTeam and sui_scoreboard to name but a few, rely on actual teams.
Perhaps you could create your own player object table name to indicate to your script what 'fake' team name they are a part of, so as to not modify the actual 'real' team that might affect various scripts. Though you wouldn't be able to use Source's 'Team' chat to talk to them, it wouldn't be difficult (no, really) to make your own chat prefix.

Though I'm sure it is much more in depth than what you're needing, take a look at our ulx function in chat.lua called cc_asay.
That code shows how we cycle through a table of players, check to see if they have seesasay access (basically, were given access in ULib, they may or may NOT actually be an admin) to see what text is being said after someone types @ blah blah in console.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Eb

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: User created teams plugin.
« Reply #2 on: March 20, 2008, 10:06:10 PM »
I run a small server, and have been trying to get a construction mixed with team based combat thing going inside of it, thus my interest in a team plugin. I'll look over the code for UTeam and see if i can learn anything from it. I've written some lua before, but none of it worked properly save for one swep; i hope you don't mind if i come back here if i reach a snag here and there in development.

An idea just hit me, is it possible to hook team say at all? I could just prevent it from showing in the chat buffer if at all possible (though highly doubtful) and have it run a separate chat function with the team say contents.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: User created teams plugin.
« Reply #3 on: March 21, 2008, 04:23:11 PM »
I run a small server, and have been trying to get a construction mixed with team based combat thing going inside of it, thus my interest in a team plugin. I'll look over the code for UTeam and see if i can learn anything from it.

Just remember, changing actual team names would show up in the scoreboard, and if they weren't in Uteams.txt, they'd appear as unnassigned in the scoreboard.
That's why I suggested tagging on a table element to a player object.

I've written some lua before, but none of it worked properly save for one swep; i hope you don't mind if i come back here if i reach a snag here and there in development.

Feel free. You'll learn that most of the actual dev team here won't write it for you. I know I personally will point to important notes of interest at our ULib documentation, or the Gmod wiki (or Lua wiki if it's something for straight Lua).
If you catch our member Kyzer's attention, he likes to write code for everyone. (Yes Kyzer, I'm picking on you)

An idea just hit me, is it possible to hook team say at all? I could just prevent it from showing in the chat buffer if at all possible (though highly doubtful) and have it run a separate chat function with the team say contents.[/color]

 Yes, but be extremely careful. Use a 'command' at the front of the team chat for your script, or hooking 'any' team chat and not returning it will break every script that monitors chat for commands, including ULX. (Example. JamminR> !EbTeamChat Hi guys.) Only prevent text after !EpTeamChat from going out. Not just any team say.
I strongly recommend what I suggested before, make a normal chat monitoring function that determines what fake team the player is on, then cycles through each player to match teams, and then places the 'chat' in thier hud and console.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline spbogie

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 456
  • Karma: 41
Re: User created teams plugin.
« Reply #4 on: March 21, 2008, 05:02:54 PM »
If you are going to be allowing clients to set the name of their own team, then make sure you sanitize the string if you are using SendLua. You can do this with a call to
Code: [Select]
teamname = string.sub( string.format( "%q", teamname ), 2, -2 ) or by sending the information to the clients using usermessages instead.
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