-.Paradox.- Posted July 19, 2013 Share Posted July 19, 2013 Hello, i'm trying to set player team by a command like example /invite [playername] [teamname] for set player team and /dismiss [playername] [teamname] for remove player from team. i searched on the wiki and i found this https://wiki.multitheftauto.com/wiki/SetPlayerTeam but it set team only for me not for other players function assignNewTeam ( source, commandName, teamName ) local theTeam = createTeam ( teamName ) if theTeam then setPlayerTeam ( source, theTeam ) end end addCommandHandler ( "invite", assignNewTeam ) function unassignTeam ( source, commandName ) local theTeam = getPlayerTeam ( source ) if theTeam then setPlayerTeam ( source, nil ) end end addCommandHandler ( "dismiss", unassignTeam ) Link to comment
Jaysds1 Posted July 19, 2013 Share Posted July 19, 2013 (edited) try this: --Thanks TAPL for Useful Function!!! function getPlayerFromNamePart(name) if name then for i, player in ipairs(getElementsByType("player")) do if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then return player end end end return false end function assignNewTeam ( source, _, playername, teamname ) if not playername then outputChatBox("Please enter in the player's name that you would like to remove from team!",source,255,0,0) return end local player = getPlayerFromName(playername) if not player then player = getPlayerFromNamePart(playername) end if not player or isElement(player) then outputChatBox("Sorry, player doesn't exist!",source,255,0,0) return end local theTeam = getTeamFromName ( teamname ) if not theTeam then theTeam = createTeam ( teamName ) end setPlayerTeam ( source, theTeam ) end addCommandHandler ( "invite", assignNewTeam ) function unassignTeam ( source, _, playername, teamname ) if not playername then outputChatBox("Please enter in the player's name that you would like to remove from team!",source,255,0,0) return end local player = getPlayerFromName(playername) if not player then player = getPlayerFromNamePart(playername) end if not player or isElement(player) then outputChatBox("Sorry, player doesn't exist!",source,255,0,0) return end local theTeam = getPlayerTeam ( player ) if not theTeam then outputChatBox("Player isn't on a team!",source,255,0,0) return end setPlayerTeam ( player, nil ) end addCommandHandler ( "dismiss", unassignTeam ) Edited July 19, 2013 by Guest Link to comment
-.Paradox.- Posted July 19, 2013 Author Share Posted July 19, 2013 Ok i'm gonna try but what about function assignNewTeam ( source, commandName, teamName ) local theTeam = createTeam ( teamName ) if theTeam then setPlayerTeam ( source, theTeam ) end end addCommandHandler ( "invite", assignNewTeam ) thanks for help Link to comment
Jaysds1 Posted July 19, 2013 Share Posted July 19, 2013 Sorry, just updated the code again Link to comment
-.Paradox.- Posted July 19, 2013 Author Share Posted July 19, 2013 (edited) Sorry i didn't saw it Edited July 19, 2013 by Guest Link to comment
-.Paradox.- Posted July 19, 2013 Author Share Posted July 19, 2013 Server side or client side? Link to comment
-.Paradox.- Posted July 19, 2013 Author Share Posted July 19, 2013 Working perfect Thanks alot 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