• Client side script, checking which team the player is on..?
    10 replies, posted
Well I created a Derma Menu, I want to make that the client side checks whether the player is Team A or Team B and open the proper menu of that team. Any ideas how can I call a check on that from the gamemode? Appreciate the help! //Vash Baldeus
if ply:Team() == 1 then //Stuff elseif ply:Team() == 2 then //Stuff2 else //otherwise end
[QUOTE=Xaotic;46230896]if ply:Team() == 1 then //Stuff elseif ply:Team() == 2 then //Stuff2 else //otherwise end[/QUOTE] This will get players team state and do something accordignly? Thanks!
[QUOTE=VashBaldeus;46230907]This will get players team state and do something accordignly? Thanks![/QUOTE] Yup. If you do not know the ids of the teams run this: [CODE] for k,team in pairs(team.GetAllTeams()) do print("Name: "..team:GetName(team).." | ID: "..team) end [/CODE]
for clients, it's LocalPlayer():Team()
[QUOTE=Xaotic;46230932]Yup. If you do not know the ids of the teams run this: [CODE] for k,team in pairs(team.GetAllTeams()) do print("Name: "..team:GetName(team).." | ID: "..team) end [/CODE][/QUOTE] I get this error when trying to get the team id: [code][ERROR] lua/autorun/client/phtm_client.lua:648: attempt to call method 'GetName' (a nil value) 1. _func - lua/autorun/client/phtm_client.lua:648 2. v - lua/autorun/client/phtm_client.lua:671 3. unknown - lua/includes/modules/hook.lua:84 [/code] The code: [code] function GetTeam() print("GetTeam() was Called") for k,team in pairs(team.GetAllTeams()) do print("Name: "..team:GetName(team).." | ID: "..team) end end[/code]
It's team[b].[/b]GetName
Yeah, sorry use . instead of :
[QUOTE=DEFCON1;46231233]It's team[b].[/b]GetName[/QUOTE] Same error... [code][ERROR] lua/autorun/client/phtm_client.lua:649: attempt to call field 'GetName' (a nil value) 1. _func - lua/autorun/client/phtm_client.lua:649 2. v - lua/autorun/client/phtm_client.lua:674 3. unknown - lua/includes/modules/hook.lua:84 [/code] the code as it looks now after fixing the typeout: [code] print("GetTeam() was Called") for k,team in pairs(team.GetAllTeams()) do print("Name: "..team.GetName(team).." | ID: "..team) end[/code]
Oh i am sorry, i defined team as a key and its probably more intelligent to use the key instead of the vlaue. Dumb me Try this [Code] print("GetTeam() was Called") for k,v in pairs(team.GetAllTeams()) do print("Name: "..team.GetName(k).." | ID: "..k) end [/code]
[QUOTE=Xaotic;46231285]Oh i am sorry, i defined team as a key and its probably more intelligent to use the key instead of the vlaue. Dumb me Try this [Code] print("GetTeam() was Called") for k,v in pairs(team.GetAllTeams()) do print("Name: "..team.GetName(k).." | ID: "..k) end [/code][/QUOTE] Thanks allot for the help, works!
Sorry, you need to Log In to post a reply to this thread.