Author Topic: Custom loadouts for different ranks.  (Read 2150 times)

0 Members and 1 Guest are viewing this topic.

Offline vader0146

  • Jr. Member
  • **
  • Posts: 63
  • Karma: 9
Custom loadouts for different ranks.
« on: May 30, 2009, 05:37:37 PM »
I am running on my server ULX Admin and UTeam for the teams.
I want to set it so that the group "user" spawns with all the normal (physgun,gravgun,cam,tool) but also with a "Pellet Gun", which is a weak SWEP a player of mine made. I also want the group "operator" (Police) to spawn with all that + a crowbar and pistol, and admins to spawn with all the hl2 weapons.

I tried URestrict from Team Ulysses but couldn't get it to work.
I know absolutely no lua whatsoever, and I'd be really grateful if someone could find a solution.

Thanks

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Custom loadouts for different ranks.
« Reply #1 on: May 30, 2009, 06:40:17 PM »
URestrict is the recommended method. Not sure why you had trouble with it.
If not URestrict, please see our FAQs - a question there regarding prevent spawning with certain weapons may help.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline vader0146

  • Jr. Member
  • **
  • Posts: 63
  • Karma: 9
Re: Custom loadouts for different ranks.
« Reply #2 on: May 31, 2009, 01:44:06 AM »
OK, I tried Kyzer's method.
I updated my UTeam.lua to this:
Code: [Select]
if not SERVER then return end

UTeam = {}

UTeam.BASETEAMINDEX = 20

UTeam.CONFIG = "UTeam.txt"

if not file.Exists( UTeam.CONFIG ) then
Msg( "[UTeam Error] UTeam config file missing.\n" )
return
end
local t = util.KeyValuesToTable( file.Read( UTeam.CONFIG ) )

if not t.teams then
Msg( "[UTeam Error] UTeam config teams table missing.\n" )
return
end
UTeam.teams = {}
for k,v in pairs( t.teams ) do
UTeam.teams[tonumber(k)]=v
end

if not t.gamemodes then
Msg( "[UTeam Error] UTeam config gamemodes table missing.\n" )
return
end
UTeam.gamemodes = t.gamemodes

function UTeam.checkGamemode()
for _,v in pairs( UTeam.gamemodes ) do
if string.lower(GAMEMODE.Name) == string.lower(v) then return true end
end
hook.Remove( "PlayerSpawn", "UTeamSetTeam" )
hook.Remove( "PlayerInitialSpawn", "UTeamSetupTeams" )
return false
end

function UTeam.setTeam( ply )
   if not UTeam.checkGamemode() then return end

   for k,v in ipairs( UTeam.teams ) do
      if ply:IsUserGroup( v.group ) then
         ply:SetTeam( UTeam.BASETEAMINDEX + k )
         if v.hp then ply:SetHealth( v.hp ) end
         if v.armor then ply:SetArmor( v.armor ) end
         if v.model then timer.Simple( 0.1, ply.SetModel, ply, player_manager.TranslatePlayerModel( v.model ) )end
         if v.weapons then
            timer.Simple( 0.1, function(ply, v)
               ply:StripWeapons()
               for _,v in pairs(v.weapons) do
                  ply:Give( v )
               end
               ply:SelectWeapon(v.weapons[1])
            end, ply, v)
         end
         if v.plytable then
            timer.Simple( 0.1, function(ply, v)
               for _,v in pairs(v.plytable) do
                  k = string.sub( v, 1, string.find( v, ":" ) - 1 )
                  v = string.sub( v, string.find( v, ":" ) + 1 )
                  ply:GetTable()[k] = tonumber(v) or v
               end
            end, ply, v)
         end
         break
      end
   end
end
hook.Add( "PlayerSpawn", "UTeamSetTeam", UTeam.setTeam )

function UTeam.setupTeams( ply )
if not UTeam.checkGamemode() then return end

for k,v in ipairs( UTeam.teams ) do
team.SetUp( UTeam.BASETEAMINDEX + k, v.name, v.color )
ply:SendLua( "team.SetUp(" .. UTeam.BASETEAMINDEX + k .. ",\"" .. v.name .. "\",Color(" .. v.color.r .. "," .. v.color.g .. "," .. v.color.b .. "," ..

v.color.a .. "))" )
end
end
hook.Add( "PlayerInitialSpawn", "UTeamSetupTeams", UTeam.setupTeams )

I updated my UTeam.txt to this:
Code: [Select]
"Out"
{
   "teams"
   {
      "1"
      {
         "name"      "Owner"
         "group"      "superadmin"
         "armor"      "1000"
         "hp"      "1000"
         "color"
         {
            "a"      "255"
            "B"      "85"
            "g"      "200"
            "r"      "0"
         }
"weapons"
         {
            "1"   "weapon_physgun"
            "2"   "gmod_tool"
            "3"   "gmod_camera"
    "4"   "weapon_ar2"
         }
         "plytable"
         {
            "1"      "SprintSpeed:2000"
            "2"      "WalkSpeed:1000"
         }
      }
      "2"
      {
         "name"      "Respected"
         "group"      "admin"
         "armor"      "200"
         "hp"      "200"
         "color"
         {
            "a"      "255"
            "B"      "50"
            "g"      "199"
            "r"      "255"
         }
      }
      "3"
      {
         "name"      "Regular"
         "group"      "regular"
         "armor"      "5"
         "hp"      "110"
         "color"
         {
            "a"      "255"
            "B"      "252"
            "g"      "15"
            "r"      "51"
         }
      }
      "4"
      {
         "name"      "Police"
         "group"      "operator"
         "armor"      "15"
         "hp"      "125"
         "color"
         {
            "a"      "255"
            "B"      "204"
            "g"      "255"
            "r"      "204"
         }
      }
      "5"
      {
         "name"      "Players"
         "group"      "user"
         "color"
         {
            "a"      "255"
            "B"      "255"
            "g"      "100"
            "r"      "0"
         }
         "model"      "male1"
      }
   }
   "gamemodes"
   {
      "1"      "Sandbox"
      "2"      "SpaceBuild"
   }
}

But everyone in the game shows as "Unassigned", and the loadouts don't work.
Did I put the code in right?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Custom loadouts for different ranks.
« Reply #3 on: May 31, 2009, 09:55:01 AM »
What errors related to sui_soreboard or UTeam appear in server console at startup, and/or at player join?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming