Sex* Posted July 31, 2013 Share Posted July 31, 2013 (edited) Why doesnt it set my team? It creates the team though... It has no errors... function setTeam(_, account) local team = getAccountName ( account ) if isObjectInACLGroup ("user."..team, aclGetGroup ( "SuperModerator" ) ) then if not getTeamFromName(team) then MainTeam = createTeam(team, 255, 50, 0) end setPlayerTeam(source, MainTeam) end end addEventHandler("onPlayerLogin", root, setTeam) function setTeam2(_, account) local team = getAccountName ( account ) if isObjectInACLGroup ("user."..team, aclGetGroup ( "Admin" ) ) then if not getTeamFromName(team) then MainTeam = createTeam(team, 255, 50, 0) end setPlayerTeam(source, MainTeam) end end addEventHandler("onPlayerLogin", root, setTeam2) Edited July 31, 2013 by Guest Link to comment
Castillo Posted July 31, 2013 Share Posted July 31, 2013 Remove getPlayerAccount and use "account" at getAccountName. Link to comment
Sex* Posted July 31, 2013 Author Share Posted July 31, 2013 Well now it created a team that has my account name and moved me into there. Tried to modify it like this: function setTeam2(_, account) local team = getAccountName ( account ) if isObjectInACLGroup ("user."..team, aclGetGroup ( "Admin" ) ) then if not getTeamFromName(team) then MainTeam = createTeam( MainTeam, 255, 50, 0) end setPlayerTeam(source, MainTeam) end end addEventHandler("onPlayerLogin", root, setTeam2) But didnt work... Link to comment
Castillo Posted July 31, 2013 Share Posted July 31, 2013 Did it work or not? because you confused me, you just said that it created it, but at the same time you said it doesn't work. Link to comment
Sex* Posted July 31, 2013 Author Share Posted July 31, 2013 Did it work or not? because you confused me, you just said that it created it, but at the same time you said it doesn't work. It did but it created a team with my name on it so I found what I have done wrong so I tried to fix it but I got bad arguments: function setTeam2(_, account) local acc = getAccountName ( account ) if isObjectInACLGroup ("user."..acc, aclGetGroup ( "Admin" ) ) then if not getTeamFromName(team) then MainTeam = createTeam(team, 255, 50, 0) end setPlayerTeam(source, MainTeam) end end addEventHandler("onPlayerLogin", root, setTeam2) I had bad arguments in these lines: if not getTeamFromName(team) then MainTeam = createTeam(team, 255, 50, 0) Link to comment
Castillo Posted July 31, 2013 Share Posted July 31, 2013 You want to create a team with the name "Admin"? if so, then just replace "team" with "Admin". Link to comment
Sex* Posted August 1, 2013 Author Share Posted August 1, 2013 You want to create a team with the name "Admin"? if so, then just replace "team" with "Admin". No...Here is my full code: function createTeamsOnStart() MainTeam = createTeam("Fucking Awesome Players!", 255, 50, 0) end addEventHandler("onResourceStart", resourceRoot, createTeamsOnStart) function setTeam(_, account) local acc = getAccountName ( account ) if isObjectInACLGroup ("user."..acc, aclGetGroup ( "SuperModerator" ) ) then if not getTeamFromName(team) then MainTeam = createTeam(team, 255, 50, 0) end setPlayerTeam(source, MainTeam) end end addEventHandler("onPlayerLogin", root, setTeam) function setTeam2(_, account) local acc = getAccountName ( account ) if isObjectInACLGroup ("user."..acc, aclGetGroup ( "Admin" ) ) then if not getTeamFromName(team) then MainTeam = createTeam(team, 255, 50, 0) end setPlayerTeam(source, MainTeam) end end addEventHandler("onPlayerLogin", root, setTeam2) function unassignTeam() local team = getPlayerTeam(source) if (team and MainTeam and team == MainTeam) then setPlayerTeam(source, nil) remove(source) end end addEventHandler("onPlayerLogout", root, unassignTeam) function remove(source) if MainTeam and (countPlayersInTeam(MainTeam) == 0) then destroyElement(MainTeam) end end Link to comment
Castillo Posted August 1, 2013 Share Posted August 1, 2013 You are replacing the variable everytime. Link to comment
Sex* Posted August 2, 2013 Author Share Posted August 2, 2013 You are replacing the variable everytime. What should I do then? Link to comment
DNL291 Posted August 2, 2013 Share Posted August 2, 2013 Try this: function createTeamsOnStart() MainTeam = createTeam(":O Awesome Players!", 255, 50, 0) end addEventHandler("onResourceStart", resourceRoot, createTeamsOnStart) function setTeam(_, account) local acc = getAccountName ( account ) if isObjectInACLGroup("user."..acc, aclGetGroup( "SuperModerator" )) or isObjectInACLGroup("user."..acc, aclGetGroup( "Admin" )) then if MainTeam then setPlayerTeam(source, MainTeam) end end end addEventHandler("onPlayerLogin", root, setTeam) function unassignTeam() local team = getPlayerTeam(source) if (team and MainTeam and team == MainTeam) then setPlayerTeam(source, nil) remove(source) end end addEventHandler("onPlayerLogout", root, unassignTeam) function remove(source) if MainTeam and (countPlayersInTeam(MainTeam) == 0) then destroyElement(MainTeam) end end Link to comment
Sex* Posted August 2, 2013 Author Share Posted August 2, 2013 You forgot that my teamsaver detroys the team if it gets empty. Your script moved me into team but as soon it gets empty and destroyed it will not be recreacted. I tried something to recreate the team but no sucess: function setTeam(_, account) local acc = getAccountName ( account ) if isObjectInACLGroup("user."..acc, aclGetGroup( "SuperModerator" )) or isObjectInACLGroup("user."..acc, aclGetGroup( "Admin" )) then if MainTeam then setPlayerTeam(source, MainTeam) if not MainTeam then MainTeam = createTeam(team, 255, 50, 0) end setPlayerTeam(source, MainTeam) end end end addEventHandler("onPlayerLogin", root, setTeam) Link to comment
Castillo Posted August 2, 2013 Share Posted August 2, 2013 function createTeamsOnStart() MainTeam = createTeam(":O Awesome Players!", 255, 50, 0) end addEventHandler("onResourceStart", resourceRoot, createTeamsOnStart) function setTeam(_, account) local acc = getAccountName ( account ) if isObjectInACLGroup ("user."..acc, aclGetGroup ( "SuperModerator" ) ) then if not getTeamFromName(team) then MainTeam = createTeam(team, 255, 50, 0) end setPlayerTeam(source, MainTeam) end end addEventHandler("onPlayerLogin", root, setTeam) function setTeam2(_, account) local acc = getAccountName ( account ) if isObjectInACLGroup ("user."..acc, aclGetGroup ( "Admin" ) ) then if not getTeamFromName(team) then MainTeam = createTeam(team, 255, 50, 0) end setPlayerTeam(source, MainTeam) end end addEventHandler("onPlayerLogin", root, setTeam2) function unassignTeam ( ) local team = getPlayerTeam ( source ) if ( team ) then setPlayerTeam ( source, nil ) local players = countPlayersInTeam ( team ) if ( players == 0 ) then destroyElement ( team ) end end end addEventHandler ( "onPlayerLogout", root, unassignTeam ) Link to comment
Sex* Posted August 4, 2013 Author Share Posted August 4, 2013 function createTeamsOnStart() MainTeam = createTeam(":O Awesome Players!", 255, 50, 0) end addEventHandler("onResourceStart", resourceRoot, createTeamsOnStart) function setTeam(_, account) local acc = getAccountName ( account ) if isObjectInACLGroup ("user."..acc, aclGetGroup ( "SuperModerator" ) ) then if not getTeamFromName(team) then MainTeam = createTeam(team, 255, 50, 0) end setPlayerTeam(source, MainTeam) end end addEventHandler("onPlayerLogin", root, setTeam) function setTeam2(_, account) local acc = getAccountName ( account ) if isObjectInACLGroup ("user."..acc, aclGetGroup ( "Admin" ) ) then if not getTeamFromName(team) then MainTeam = createTeam(team, 255, 50, 0) end setPlayerTeam(source, MainTeam) end end addEventHandler("onPlayerLogin", root, setTeam2) function unassignTeam ( ) local team = getPlayerTeam ( source ) if ( team and MainTeam and team == MainTeam ) then setPlayerTeam ( source, nil ) local players = countPlayersInTeam ( team ) if ( players == 0 ) then destroyElement ( team ) end end end addEventHandler ( "onPlayerLogout", root, unassignTeam ) Doesnt work. Link to comment
Castillo Posted August 4, 2013 Share Posted August 4, 2013 local teams = { } function createTeamsOnStart ( ) local team = createTeam ( ":O Awesome Players!", 255, 50, 0 ) teams [ team ] = true end addEventHandler ( "onResourceStart", resourceRoot, createTeamsOnStart ) function setTeam ( _, account ) local acc = getAccountName ( account ) local team = "" if isObjectInACLGroup ( "user.".. acc, aclGetGroup ( "SuperModerator" ) ) then team = "Moderators" elseif isObjectInACLGroup ( "user.".. acc, aclGetGroup ( "Admin" ) ) then team = "Admins" end if ( team ~= "" ) then if ( not getTeamFromName ( team ) ) then local team = createTeam ( team, 255, 50, 0 ) teams [ team ] = true setPlayerTeam ( source, team ) end end end addEventHandler ( "onPlayerLogin", root, setTeam ) function unassignTeam ( ) local team = getPlayerTeam ( source ) if ( team and teams [ team ] ) then setPlayerTeam ( source, nil ) local players = countPlayersInTeam ( team ) if ( players == 0 ) then destroyElement ( team ) end end end addEventHandler ( "onPlayerLogout", root, unassignTeam ) Link to comment
Sex* Posted August 4, 2013 Author Share Posted August 4, 2013 (edited) local teams = { } function createTeamsOnStart ( ) local team = createTeam ( ":O Awesome Players!", 255, 50, 0 ) teams [ team ] = true end addEventHandler ( "onResourceStart", resourceRoot, createTeamsOnStart ) function setTeam ( _, account ) local acc = getAccountName ( account ) local team = "" if isObjectInACLGroup ( "user.".. acc, aclGetGroup ( "SuperModerator" ) ) then team = "Moderators" elseif isObjectInACLGroup ( "user.".. acc, aclGetGroup ( "Admin" ) ) then team = "Admins" end if ( team ~= "" ) then if ( not getTeamFromName ( team ) ) then local team = createTeam ( team, 255, 50, 0 ) teams [ team ] = true setPlayerTeam ( source, team ) end end end addEventHandler ( "onPlayerLogin", root, setTeam ) function unassignTeam ( ) local team = getPlayerTeam ( source ) if ( team and teams [ team ] ) then setPlayerTeam ( source, nil ) local players = countPlayersInTeam ( team ) if ( players == 0 ) then destroyElement ( team ) end end end addEventHandler ( "onPlayerLogout", root, unassignTeam ) Now it creates the team ":O Awesome Players" but that stays empty and dont get destroyed also. And if I login it creates team "Admins" and move me to there and if i logout it destroys the team so it works but I want it to be in the other team (Fucking awesome players) EDIT: I saw what you did solidsnake, I think you dont understand what Im trying to do. DNL291 code works good but it doesnt recreate the team. Edited August 4, 2013 by Guest Link to comment
Castillo Posted August 4, 2013 Share Posted August 4, 2013 local teamName = ":O Awesome Players!" function setTeam ( _, account ) local acc = getAccountName ( account ) if ( isObjectInACLGroup ( "user.".. acc, aclGetGroup ( "SuperModerator" ) ) or isObjectInACLGroup ( "user.".. acc, aclGetGroup ( "Admin" ) ) ) then if ( not getTeamFromName ( teamName ) ) then mainTeam = createTeam ( teamName, 255, 50, 0 ) setPlayerTeam ( source, mainTeam ) end end end addEventHandler ( "onPlayerLogin", root, setTeam ) function unassignTeam ( ) local team = getPlayerTeam ( source ) if ( team == mainTeam ) then setPlayerTeam ( source, nil ) local players = countPlayersInTeam ( team ) if ( players == 0 ) then destroyElement ( team ) end end end addEventHandler ( "onPlayerLogout", root, unassignTeam ) Link to comment
Sex* Posted August 4, 2013 Author Share Posted August 4, 2013 local teamName = ":O Awesome Players!" function setTeam ( _, account ) local acc = getAccountName ( account ) if ( isObjectInACLGroup ( "user.".. acc, aclGetGroup ( "SuperModerator" ) ) or isObjectInACLGroup ( "user.".. acc, aclGetGroup ( "Admin" ) ) ) then if ( not getTeamFromName ( teamName ) ) then mainTeam = createTeam ( teamName, 255, 50, 0 ) setPlayerTeam ( source, mainTeam ) end end end addEventHandler ( "onPlayerLogin", root, setTeam ) function unassignTeam ( ) local team = getPlayerTeam ( source ) if ( team == mainTeam ) then setPlayerTeam ( source, nil ) local players = countPlayersInTeam ( team ) if ( players == 0 ) then destroyElement ( team ) end end end addEventHandler ( "onPlayerLogout", root, unassignTeam ) Thanks works. But do you know how to make it like blink. Like its orange and then it like goes blue for a second? Link to comment
EstrategiaGTA Posted August 4, 2013 Share Posted August 4, 2013 local teamName = ":O Awesome Players!" function setTeam ( _, account ) local acc = getAccountName ( account ) if ( isObjectInACLGroup ( "user.".. acc, aclGetGroup ( "SuperModerator" ) ) or isObjectInACLGroup ( "user.".. acc, aclGetGroup ( "Admin" ) ) ) then if ( not getTeamFromName ( teamName ) ) then mainTeam = createTeam ( teamName, 255, 50, 0 ) setPlayerTeam ( source, mainTeam ) end end end addEventHandler ( "onPlayerLogin", root, setTeam ) function unassignTeam ( ) local team = getPlayerTeam ( source ) if ( team == mainTeam ) then setPlayerTeam ( source, nil ) local players = countPlayersInTeam ( team ) if ( players == 0 ) then destroyElement ( team ) end end end addEventHandler ( "onPlayerLogout", root, unassignTeam ) Thanks works. But do you know how to make it like blink. Like its orange and then it like goes blue for a second? What do you mean? Link to comment
Castillo Posted August 4, 2013 Share Posted August 4, 2013 You mean make the team blink? Link to comment
Sex* Posted August 5, 2013 Author Share Posted August 5, 2013 Yeah like make the team go to second color for a second. Link to comment
Sex* Posted August 5, 2013 Author Share Posted August 5, 2013 setTimer setTeamColor Isn't setTimer laggy? Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now