ULX

Author Topic: Player:SetTeam() Not Working?  (Read 2961 times)

0 Members and 1 Guest are viewing this topic.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Player:SetTeam() Not Working?
« on: June 21, 2014, 12:49:35 PM »
So, I'm remaking one of my gamemodes, and I'm starting from scratch redoing everything. I've now run into an issue with setting teams.

Code: [Select]
-- Create Teams From Database
function CreateTeams()

local CreateTeamInfoAll = sql.Query( "SELECT * FROM apple_tdm_teamcreation19" )
if CreateTeamInfoAll == nil then return end
for k, v in pairs( CreateTeamInfoAll ) do
team.SetUp(tonumber(v['ID']), tostring(v['Name']), Color(tonumber(v['CRed']),tonumber(v['CGreen']),tonumber(v['CBlue']),255), true)
util.PrecacheModel( tostring(v['Models']) )
end
PrintTable(team.GetAllTeams( ))
end


Basically in there, it grabs the teams from the database, and turns it into teams. Well that works all fine and well, but when I try to set team to one of the IDs, it works fine which you're most likely thinking well then what's the issue? Well the issue here is that the team doesn't really "set" or something, it shows it set the team, I made a command to check what team, and name of team I am on, and that works, but it's not setting colour, or name of team IG (sui_scoreboard or chattags addon), but in console its showing I'm in that team...

Any suggestions?
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Player:SetTeam() Not Working?
« Reply #1 on: June 21, 2014, 02:41:19 PM »
Are you spawning players with self.BaseClass:PlayerSpawn()?

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Player:SetTeam() Not Working?
« Reply #2 on: June 22, 2014, 03:19:40 AM »
Are you spawning players with self.BaseClass:PlayerSpawn()?


No, spawning them with GM:PlayerInitialSpawn(ply). If anyone wants the entire gamemode (it's really nothing atm), then you can see for yourself. The gamemode is entirely commented, so you'll be able to see what it does, and you'll see what I mean by it not working correctly.


http://puu.sh/9Ew2h/94986a5016.zip
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Player:SetTeam() Not Working?
« Reply #3 on: June 23, 2014, 08:39:09 AM »
Alright, so I found something interesting, and still doesn't work. I'll be looking into this, and I'll record the issue so you can see it for yourself, and find out why it's not working.
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Player:SetTeam() Not Working?
« Reply #4 on: June 23, 2014, 11:22:09 AM »
Alright, this is the new code here:
http://www.puu.sh/9GRB1/dfe6c555fb.zip

That is everything, and it should be working, I spoke to many people now trying to find out why it does this, and no one can answer me... if anyone can help me thanks guys. WATCH THIS VIDEO, this will explain the issue I am having, and it will make more sense. Watch in HD, or you won't see the code

https://www.youtube.com/watch?v=8d66TYrwT-c
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Player:SetTeam() Not Working?
« Reply #5 on: June 23, 2014, 02:47:46 PM »
Resolved
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Player:SetTeam() Not Working?
« Reply #6 on: June 23, 2014, 02:54:54 PM »

No, spawning them with GM:PlayerInitialSpawn(ply). If anyone wants the entire gamemode (it's really nothing atm), then you can see for yourself. The gamemode is entirely commented, so you'll be able to see what it does, and you'll see what I mean by it not working correctly.


http://puu.sh/9Ew2h/94986a5016.zip
No, I meant like how you handle the actual spawning of players. But you got it sorted out so it's all good.
For instance, here's how I do it in my init.lua (look at GM:PlayerSpawn): http://puu.sh/9Hb9B/735fd41d19.lua
« Last Edit: June 23, 2014, 02:58:25 PM by Cobalt »